Eevee: Shadows: Only tag as shadow caster if a shadow is cast.
authorClément Foucault <foucault.clem@gmail.com>
Tue, 1 May 2018 17:32:24 +0000 (19:32 +0200)
committerClément Foucault <foucault.clem@gmail.com>
Tue, 1 May 2018 17:39:18 +0000 (19:39 +0200)
This leads to great improvement if the scene have moving objects without
shadows (shadows disabled in the material panel).

source/blender/draw/engines/eevee/eevee_engine.c
source/blender/draw/engines/eevee/eevee_materials.c
source/blender/draw/engines/eevee/eevee_private.h
source/blender/draw/engines/eevee/eevee_render.c

index 3b48a8fa10625d979c9a47e37e2482bd473da9d2..afea335d733370dc07faa919092d74aea1a7316e 100644 (file)
@@ -140,9 +140,9 @@ static void eevee_cache_populate(void *vedata, Object *ob)
        }
 
        if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
-               EEVEE_materials_cache_populate(vedata, sldata, ob);
+               bool cast_shadow;
 
-               const bool cast_shadow = true;
+               EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow);
 
                if (cast_shadow) {
                        EEVEE_lights_cache_shcaster_object_add(sldata, ob);
index fa5deb27b29776bd1070bfef51e6140164fa893f..de65084f553e821517bb5c4710a25727ddf80389 100644 (file)
@@ -1289,7 +1289,7 @@ static void material_transparent(
        }
 }
 
-void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob)
+void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob, bool *cast_shadow)
 {
        EEVEE_PassList *psl = vedata->psl;
        EEVEE_StorageList *stl = vedata->stl;
@@ -1418,14 +1418,17 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
                                        switch (ma->blend_shadow) {
                                                case MA_BS_SOLID:
                                                        EEVEE_lights_cache_shcaster_add(sldata, stl, mat_geom[i], ob);
+                                                       *cast_shadow = true;
                                                        break;
                                                case MA_BS_CLIP:
                                                        gpumat = EEVEE_material_mesh_depth_get(scene, ma, false, true);
                                                        EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, &ma->alpha_threshold);
+                                                       *cast_shadow = true;
                                                        break;
                                                case MA_BS_HASHED:
                                                        gpumat = EEVEE_material_mesh_depth_get(scene, ma, true, true);
                                                        EEVEE_lights_cache_shcaster_material_add(sldata, psl, gpumat, mat_geom[i], ob, NULL);
+                                                       *cast_shadow = true;
                                                        break;
                                                case MA_BS_NONE:
                                                default:
@@ -1434,6 +1437,7 @@ void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sld
                                }
                                else {
                                        EEVEE_lights_cache_shcaster_add(sldata, stl, mat_geom[i], ob);
+                                       *cast_shadow = true;
                                }
                        }
                }
index a2961020f7f0eeacb8f7c1e73171f55fa88968e4..ec9cdf9b505adfdbcf22fd156d80b384780afa7e 100644 (file)
@@ -804,7 +804,7 @@ EEVEE_LampEngineData *EEVEE_lamp_data_ensure(Object *ob);
 struct GPUTexture *EEVEE_materials_get_util_tex(void); /* XXX */
 void EEVEE_materials_init(EEVEE_ViewLayerData *sldata, EEVEE_StorageList *stl, EEVEE_FramebufferList *fbl);
 void EEVEE_materials_cache_init(EEVEE_ViewLayerData *sldata, EEVEE_Data *vedata);
-void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob);
+void EEVEE_materials_cache_populate(EEVEE_Data *vedata, EEVEE_ViewLayerData *sldata, Object *ob, bool *cast_shadow);
 void EEVEE_materials_cache_finish(EEVEE_Data *vedata);
 struct GPUMaterial *EEVEE_material_world_lightprobe_get(struct Scene *scene, struct World *wo);
 struct GPUMaterial *EEVEE_material_world_background_get(struct Scene *scene, struct World *wo);
index 317d211c4e6a7237bc0777519be315bd5e99a1a9..5c4744987ddb5bdf038050fb144256084a4d9e7d 100644 (file)
@@ -149,9 +149,9 @@ void EEVEE_render_cache(
        }
 
        if (ELEM(ob->type, OB_MESH, OB_CURVE, OB_SURF, OB_FONT)) {
-               EEVEE_materials_cache_populate(vedata, sldata, ob);
+               bool cast_shadow;
 
-               const bool cast_shadow = true;
+               EEVEE_materials_cache_populate(vedata, sldata, ob, &cast_shadow);
 
                if (cast_shadow) {
                        EEVEE_lights_cache_shcaster_object_add(sldata, ob);