Allow non-power-of-two directional shadow size in 3D

This allows for more finegrained performance/quality tuning, especially
at higher sizes. Any number can be used. 3072 and 6144 are sensible
shadow sizes that can be used if the default 4096 is too slow or
too low-resolution for a large scene.

This also updates the point light shadow atlas size property hint
to reflect that it can be changed without restarting the engine.
Nonetheless, it's still rounded to the next power of 2 since the
atlas relies on dimensions being powers of 2.
This commit is contained in:
Hugo Locurcio 2021-10-20 20:50:54 +02:00
parent d65f06652e
commit dd86d50770
No known key found for this signature in database
GPG key ID: 39E8F8BE30B0A49C
5 changed files with 6 additions and 6 deletions

View file

@ -1297,7 +1297,7 @@
If [code]true[/code], performs a previous depth pass before rendering materials. This increases performance in scenes with high overdraw, when complex materials and lighting are used.
</member>
<member name="rendering/quality/directional_shadow/size" type="int" setter="" getter="" default="4096">
The directional shadow's size in pixels. Higher values will result in sharper shadows, at the cost of performance. The value will be rounded up to the nearest power of 2.
The directional shadow's size in pixels. Higher values will result in sharper shadows, at the cost of performance.
</member>
<member name="rendering/quality/directional_shadow/size.mobile" type="int" setter="" getter="" default="2048">
Lower-end override for [member rendering/quality/directional_shadow/size] on mobile devices, due to performance concerns or driver support.
@ -1403,7 +1403,7 @@
Subdivision quadrant size for shadow mapping. See shadow mapping documentation.
</member>
<member name="rendering/quality/shadow_atlas/size" type="int" setter="" getter="" default="4096">
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.
</member>
<member name="rendering/quality/shadow_atlas/size.mobile" type="int" setter="" getter="" default="2048">
Lower-end override for [member rendering/quality/shadow_atlas/size] on mobile devices, due to performance concerns or driver support.

View file

@ -266,7 +266,7 @@
</member>
<member name="shadow_atlas_size" type="int" setter="set_shadow_atlas_size" getter="get_shadow_atlas_size" default="0">
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 0, point light shadows won't be visible. Since user-created viewports default to a value of 0, this value must be set above 0 manually. [DirectionalLight] shadows will still be visible regardless of [member shadow_atlas_size].
</member>
<member name="sharpen_intensity" type="float" setter="set_sharpen_intensity" getter="get_sharpen_intensity" default="0.0">
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].

View file

@ -3990,7 +3990,7 @@ void RasterizerSceneGLES2::initialize() {
// directional shadows
directional_shadow.light_count = 0;
directional_shadow.size = next_power_of_2(GLOBAL_GET("rendering/quality/directional_shadow/size"));
directional_shadow.size = GLOBAL_GET("rendering/quality/directional_shadow/size");
if (directional_shadow.size > storage->config.max_viewport_dimensions[0] || directional_shadow.size > storage->config.max_viewport_dimensions[1]) {
WARN_PRINT("Cannot set directional shadow size larger than maximum hardware supported size of (" + itos(storage->config.max_viewport_dimensions[0]) + ", " + itos(storage->config.max_viewport_dimensions[1]) + "). Setting size to maximum.");

View file

@ -5037,7 +5037,7 @@ void RasterizerSceneGLES3::initialize() {
{
//directional light shadow
directional_shadow.light_count = 0;
directional_shadow.size = next_power_of_2(GLOBAL_GET("rendering/quality/directional_shadow/size"));
directional_shadow.size = GLOBAL_GET("rendering/quality/directional_shadow/size");
glGenFramebuffers(1, &directional_shadow.fbo);
glBindFramebuffer(GL_FRAMEBUFFER, directional_shadow.fbo);
glGenTextures(1, &directional_shadow.depth);

View file

@ -2602,7 +2602,7 @@ VisualServer::VisualServer() {
GLOBAL_DEF_RST("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"));
GLOBAL_DEF_RST("rendering/quality/shadow_atlas/size", 4096);
GLOBAL_DEF("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);