Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2019-08-30 04:12:45 +0300
committerClément Foucault <foucault.clem@gmail.com>2019-09-02 17:41:06 +0300
commite13f5cc5aea6ec851ea4ea41a1057853505a6801 (patch)
tree911044989cbb56aa7310b42b93960da22b47a624
parent278d174e358d9028c27a2b0e6030aa8db59ea6c8 (diff)
Eevee: Shadow: Speedup: Only render shadow cube face needed
This reduce the number of face to render to 5 in the case of area lights and 5 or 1 for spotlights. Spotlights that have a spot size less than 90 degrees only need 1 face and are the fastest.
-rw-r--r--source/blender/draw/engines/eevee/eevee_lights.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c
index 6a7376db557..76e7340a20f 100644
--- a/source/blender/draw/engines/eevee/eevee_lights.c
+++ b/source/blender/draw/engines/eevee/eevee_lights.c
@@ -688,12 +688,13 @@ static void eevee_shadow_cube_setup(Object *ob,
Light *la = (Light *)ob->data;
normalize_m4_m4(cube_data->shadowmat, ob->obmat);
- copy_v3_v3(cube_data->position, ob->obmat[3]);
if (linfo->soft_shadows) {
shadow_cube_random_position_set(evli, la, sample_ofs, cube_data->shadowmat[3]);
}
+ copy_v3_v3(cube_data->position, cube_data->shadowmat[3]);
+
invert_m4(cube_data->shadowmat);
ubo_data->bias = 0.05f * la->bias;
@@ -1212,6 +1213,7 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView
/* Render each shadow to one layer of the array */
for (i = 0; (ob = linfo->shadow_cube_ref[i]) && (i < MAX_SHADOW_CUBE); i++) {
EEVEE_LightEngineData *led = EEVEE_light_data_ensure(ob);
+ Light *la = (Light *)ob->data;
if (!led->need_update || !cube_visible[i]) {
continue;
@@ -1233,6 +1235,17 @@ void EEVEE_draw_shadows(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata, DRWView
* The only time it's more beneficial is when the CPU culling overhead
* outweigh the instancing overhead. which is rarely the case. */
for (int j = 0; j < 6; j++) {
+ /* Optimization: Only render the needed faces. */
+ /* Skip all but -Z face. */
+ if (la->type == LA_SPOT && la->spotsize < DEG2RADF(90.0f) && j != 5)
+ continue;
+ /* Skip +Z face. */
+ if (la->type != LA_LOCAL && j == 4)
+ continue;
+ /* TODO(fclem) some cube sides can be invisible in the main views. Cull them. */
+ // if (frustum_intersect(g_data->cube_views[j], main_view))
+ // continue;
+
DRW_view_set_active(g_data->cube_views[j]);
int layer = i * 6 + j;
GPU_framebuffer_texture_layer_attach(