From 92376633f366d25f31f0cb48b1f3fa9ed7425b2b Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Wed, 2 Feb 2022 23:24:36 +0100 Subject: [PATCH] Clamp Viewport shadow atlas sizes to improve usability - Add a range hint to the Viewport `shadow_atlas_size` property. - Add range steps to the shadow resolution project settings that match the lowest allowed values (since lower increments don't make sense). --- doc/classes/ProjectSettings.xml | 2 +- doc/classes/Viewport.xml | 2 +- scene/main/viewport.cpp | 2 +- servers/visual_server.cpp | 6 +++--- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index 3cbaedd5616..41270a09994 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -1488,7 +1488,7 @@ Subdivision quadrant size for shadow mapping. See shadow mapping documentation. - Size for shadow atlas (used for OmniLights and SpotLights). See documentation. + Size for shadow atlas (used for OmniLights and SpotLights). The value will be rounded up to the nearest power of 2. See shadow mapping documentation. Lower-end override for [member rendering/quality/shadow_atlas/size] on mobile devices, due to performance concerns or driver support. diff --git a/doc/classes/Viewport.xml b/doc/classes/Viewport.xml index 070717c8e4d..9d7d0969024 100644 --- a/doc/classes/Viewport.xml +++ b/doc/classes/Viewport.xml @@ -268,7 +268,7 @@ The shadow atlas' resolution (used for omni and spot lights). The value will be rounded up to the nearest power of 2. - [b]Note:[/b] If this is set to 0, shadows won't be visible. Since user-created viewports default to a value of 0, this value must be set above 0 manually. + [b]Note:[/b] If this is set to [code]0[/code], both point [i]and[/i] directional shadows won't be visible. Since user-created viewports default to a value of [code]0[/code], this value must be set above [code]0[/code] manually (typically at least [code]256[/code]). If set to a value greater than [code]0.0[/code], contrast-adaptive sharpening will be applied to the 3D viewport. This has a low performance cost and can be used to recover some of the sharpness lost from using FXAA. Values around [code]0.5[/code] generally give the best results. See also [member fxaa]. diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index 65302b620af..ae9670c572f 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -3328,7 +3328,7 @@ void Viewport::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_disable_input"), "set_disable_input", "is_input_disabled"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "gui_snap_controls_to_pixels"), "set_snap_controls_to_pixels", "is_snap_controls_to_pixels_enabled"); ADD_GROUP("Shadow Atlas", "shadow_atlas_"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_atlas_size"), "set_shadow_atlas_size", "get_shadow_atlas_size"); + ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_atlas_size", PROPERTY_HINT_RANGE, "0,16384,256"), "set_shadow_atlas_size", "get_shadow_atlas_size"); ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_0", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 0); ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_1", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 1); ADD_PROPERTYI(PropertyInfo(Variant::INT, "shadow_atlas_quad_2", PROPERTY_HINT_ENUM, "Disabled,1 Shadow,4 Shadows,16 Shadows,64 Shadows,256 Shadows,1024 Shadows"), "set_shadow_atlas_quadrant_subdiv", "get_shadow_atlas_quadrant_subdiv", 2); diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 1eadd55cea6..66d746e3450 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -2618,12 +2618,12 @@ VisualServer::VisualServer() { GLOBAL_DEF("rendering/quality/directional_shadow/size", 4096); GLOBAL_DEF("rendering/quality/directional_shadow/size.mobile", 2048); - ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/directional_shadow/size", PropertyInfo(Variant::INT, "rendering/quality/directional_shadow/size", PROPERTY_HINT_RANGE, "256,16384")); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/directional_shadow/size", PropertyInfo(Variant::INT, "rendering/quality/directional_shadow/size", PROPERTY_HINT_RANGE, "256,16384,256")); 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")); + 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,256")); 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")); + 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,64")); 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);