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.
This commit is contained in:
Clément Foucault 2017-09-02 02:27:28 +02:00
parent f46b908cc5
commit 6c17348e91
6 changed files with 22 additions and 8 deletions

View File

@ -763,6 +763,7 @@ class RENDER_PT_eevee_shadows(RenderButtonsPanel, Panel):
col = layout.column()
col.prop(props, "shadow_method")
col.prop(props, "shadow_size")
col.prop(props, "shadow_high_bitdepth")
classes = (

View File

@ -309,6 +309,7 @@ class RENDERLAYER_PT_eevee_shadows(RenderLayerButtonsPanel, Panel):
col = layout.column()
col.template_override_property(layer_props, scene_props, "shadow_method")
col.template_override_property(layer_props, scene_props, "shadow_size")
col.template_override_property(layer_props, scene_props, "shadow_high_bitdepth")
classes = (

View File

@ -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);

View File

@ -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;

View File

@ -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. */

View File

@ -2660,6 +2660,7 @@ RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_border_fade)
RNA_LAYER_ENGINE_EEVEE_GET_SET_FLOAT(ssr_firefly_fac)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(shadow_method)
RNA_LAYER_ENGINE_EEVEE_GET_SET_INT(shadow_size)
RNA_LAYER_ENGINE_EEVEE_GET_SET_BOOL(shadow_high_bitdepth)
/* object engine */
RNA_LAYER_MODE_OBJECT_GET_SET_BOOL(show_wire)
@ -6568,6 +6569,12 @@ static void rna_def_scene_layer_engine_settings_eevee(BlenderRNA *brna)
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
prop = RNA_def_property(srna, "shadow_high_bitdepth", PROP_BOOLEAN, PROP_NONE);
RNA_def_property_boolean_funcs(prop, "rna_LayerEngineSettings_Eevee_shadow_high_bitdepth_get", "rna_LayerEngineSettings_Eevee_shadow_high_bitdepth_set");
RNA_def_property_ui_text(prop, "High Bitdepth", "Use 32bit shadows");
RNA_def_property_flag(prop, PROP_CONTEXT_UPDATE);
RNA_def_property_update(prop, NC_SCENE | ND_LAYER_CONTENT, "rna_SceneLayerEngineSettings_update");
RNA_define_verify_sdna(1); /* not in sdna */
}