From 6c17348e9160e412e13e17cad996fe50c1ffcbe9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Sat, 2 Sep 2017 02:27:28 +0200 Subject: Eevee: Shadow: Add high bitdepth option. This option is here for reducing the memory usage of shadow maps. Also lower bitdepth are quicker to process. --- source/blender/draw/engines/eevee/eevee_engine.c | 1 + source/blender/draw/engines/eevee/eevee_lights.c | 19 +++++++++++-------- source/blender/draw/engines/eevee/eevee_private.h | 1 + 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'source/blender/draw') diff --git a/source/blender/draw/engines/eevee/eevee_engine.c b/source/blender/draw/engines/eevee/eevee_engine.c index 735c3a77c5d..8d3d749d55a 100644 --- a/source/blender/draw/engines/eevee/eevee_engine.c +++ b/source/blender/draw/engines/eevee/eevee_engine.c @@ -312,6 +312,7 @@ static void EEVEE_scene_layer_settings_create(RenderEngine *UNUSED(engine), IDPr BKE_collection_engine_property_add_int(props, "shadow_method", SHADOW_ESM); BKE_collection_engine_property_add_int(props, "shadow_size", 512); + BKE_collection_engine_property_add_bool(props, "shadow_high_bitdepth", false); } static const DrawEngineDataSize EEVEE_data_size = DRW_VIEWPORT_DATA_SIZE(EEVEE_Data); diff --git a/source/blender/draw/engines/eevee/eevee_lights.c b/source/blender/draw/engines/eevee/eevee_lights.c index b70cfcb01dc..0033670528a 100644 --- a/source/blender/draw/engines/eevee/eevee_lights.c +++ b/source/blender/draw/engines/eevee/eevee_lights.c @@ -97,13 +97,19 @@ void EEVEE_lights_init(EEVEE_SceneLayerData *sldata) int sh_method = BKE_collection_engine_property_value_get_int(props, "shadow_method"); int sh_size = BKE_collection_engine_property_value_get_int(props, "shadow_size"); + int sh_high_bitdepth = BKE_collection_engine_property_value_get_int(props, "shadow_high_bitdepth"); EEVEE_LampsInfo *linfo = sldata->lamps; - if ((linfo->shadow_size != sh_size) || (linfo->shadow_method != sh_method)) { + if ((linfo->shadow_size != sh_size) || + (linfo->shadow_method != sh_method) || + (linfo->shadow_high_bitdepth != sh_high_bitdepth)) + { BLI_assert((sh_size > 0) && (sh_size <= 8192)); DRW_TEXTURE_FREE_SAFE(sldata->shadow_pool); + DRW_TEXTURE_FREE_SAFE(sldata->shadow_cube_target); DRW_TEXTURE_FREE_SAFE(sldata->shadow_cascade_target); + linfo->shadow_high_bitdepth = sh_high_bitdepth; linfo->shadow_method = sh_method; linfo->shadow_size = sh_size; linfo->shadow_render_data.stored_texel_size = 1.0 / (float)linfo->shadow_size; @@ -115,11 +121,8 @@ void EEVEE_lights_init(EEVEE_SceneLayerData *sldata) CLAMP(new_cube_target_size, 1, 4096); - if (linfo->shadow_cube_target_size != new_cube_target_size) { - linfo->shadow_cube_target_size = new_cube_target_size; - DRW_TEXTURE_FREE_SAFE(sldata->shadow_cube_target); - linfo->shadow_render_data.cube_texel_size = 1.0 / (float)linfo->shadow_cube_target_size; - } + linfo->shadow_cube_target_size = new_cube_target_size; + linfo->shadow_render_data.cube_texel_size = 1.0 / (float)linfo->shadow_cube_target_size; } } @@ -279,8 +282,8 @@ void EEVEE_lights_cache_finish(EEVEE_SceneLayerData *sldata) } switch (linfo->shadow_method) { - case SHADOW_ESM: shadow_pool_format = DRW_TEX_R_32; break; - case SHADOW_VSM: shadow_pool_format = DRW_TEX_RG_32; break; + case SHADOW_ESM: shadow_pool_format = ((linfo->shadow_high_bitdepth) ? DRW_TEX_R_32 : DRW_TEX_R_16); break; + case SHADOW_VSM: shadow_pool_format = ((linfo->shadow_high_bitdepth) ? DRW_TEX_RG_32 : DRW_TEX_RG_16); break; default: BLI_assert(!"Incorrect Shadow Method"); break; diff --git a/source/blender/draw/engines/eevee/eevee_private.h b/source/blender/draw/engines/eevee/eevee_private.h index 724764b5291..1e994c8d1fa 100644 --- a/source/blender/draw/engines/eevee/eevee_private.h +++ b/source/blender/draw/engines/eevee/eevee_private.h @@ -249,6 +249,7 @@ typedef struct EEVEE_LampsInfo { int num_shadow, cache_num_shadow; int update_flag; int shadow_size, shadow_method; + bool shadow_high_bitdepth; int shadow_cube_target_size; /* List of lights in the scene. */ /* XXX This is fragile, can get out of sync quickly. */ -- cgit v1.2.3