From 0546c8760a3d1f4f213845009babca9c6b275467 Mon Sep 17 00:00:00 2001 From: clayjohn Date: Tue, 20 Apr 2021 22:29:40 -0700 Subject: [PATCH] Add setting for shadow cubemap max size --- doc/classes/ProjectSettings.xml | 3 +++ drivers/gles2/rasterizer_scene_gles2.cpp | 2 +- drivers/gles3/rasterizer_scene_gles3.cpp | 2 +- servers/visual_server.cpp | 2 ++ 4 files changed, 7 insertions(+), 2 deletions(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 13148f25be6..1ac058a64fb 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1258,6 +1258,9 @@ Lower-end override for [member rendering/quality/shading/force_vertex_shading] on mobile devices, due to performance concerns or driver support. + + Size for cubemap into which the shadow is rendered before being copied into the shadow atlas. A higher number can result in higher resolution shadows when used with a higher [member rendering/quality/shadow_atlas/size]. Setting higher than a quarter of the [member rendering/quality/shadow_atlas/size] will not result in a perceptible increase in visual quality. + Subdivision quadrant size for shadow mapping. See shadow mapping documentation. diff --git a/drivers/gles2/rasterizer_scene_gles2.cpp b/drivers/gles2/rasterizer_scene_gles2.cpp index f2cbb88d5f2..2cfb4b07a74 100644 --- a/drivers/gles2/rasterizer_scene_gles2.cpp +++ b/drivers/gles2/rasterizer_scene_gles2.cpp @@ -4006,7 +4006,7 @@ void RasterizerSceneGLES2::initialize() { // cubemaps for shadows if (storage->config.support_shadow_cubemaps) { //not going to be used - int max_shadow_cubemap_sampler_size = CLAMP(int(next_power_of_2(GLOBAL_GET("rendering/quality/shadow_atlas/size")) >> 1), 256, storage->config.max_cubemap_texture_size); + int max_shadow_cubemap_sampler_size = MIN(int(GLOBAL_GET("rendering/quality/shadow_atlas/cubemap_size")), storage->config.max_cubemap_texture_size); int cube_size = max_shadow_cubemap_sampler_size; diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index 41e3165eb62..d7e46ebc1ea 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -5110,7 +5110,7 @@ void RasterizerSceneGLES3::initialize() { shadow_atlas_realloc_tolerance_msec = 500; - int max_shadow_cubemap_sampler_size = CLAMP(int(next_power_of_2(GLOBAL_GET("rendering/quality/shadow_atlas/size")) >> 1), 256, storage->config.max_cubemap_texture_size); + int max_shadow_cubemap_sampler_size = MIN(int(GLOBAL_GET("rendering/quality/shadow_atlas/cubemap_size")), storage->config.max_cubemap_texture_size); int cube_size = max_shadow_cubemap_sampler_size; diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 0f99d3c278c..5f162949c43 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -2409,6 +2409,8 @@ VisualServer::VisualServer() { GLOBAL_DEF_RST("rendering/quality/shadow_atlas/size", 4096); GLOBAL_DEF("rendering/quality/shadow_atlas/size.mobile", 2048); ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/size", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/size", PROPERTY_HINT_RANGE, "256,16384")); + GLOBAL_DEF_RST("rendering/quality/shadow_atlas/cubemap_size", 512); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/shadow_atlas/cubemap_size", PropertyInfo(Variant::INT, "rendering/quality/shadow_atlas/cubemap_size", PROPERTY_HINT_RANGE, "64,16384")); GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_0_subdiv", 1); GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_1_subdiv", 2); GLOBAL_DEF("rendering/quality/shadow_atlas/quadrant_2_subdiv", 3);