From 0012478ecbfcbca907e56471ad98de9ef78fb068 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Sun, 22 Oct 2023 00:24:03 +0200 Subject: [PATCH] Add property hint for 2D shadow size project setting Previously, it was possible to use zero or negative values, which are invalid. This also prevents crashing the engine by setting a shadow size of 0 or lower from a script. --- servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp | 2 +- servers/rendering_server.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp index ecf2c299568..0b1561939e1 100644 --- a/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_canvas_render_rd.cpp @@ -2759,7 +2759,7 @@ bool RendererCanvasRenderRD::free(RID p_rid) { } void RendererCanvasRenderRD::set_shadow_texture_size(int p_size) { - p_size = nearest_power_of_2_templated(p_size); + p_size = MAX(1, nearest_power_of_2_templated(p_size)); if (p_size == state.shadow_texture_size) { return; } diff --git a/servers/rendering_server.cpp b/servers/rendering_server.cpp index ccddaae1317..2b4fe6e01b0 100644 --- a/servers/rendering_server.cpp +++ b/servers/rendering_server.cpp @@ -3345,7 +3345,7 @@ void RenderingServer::init() { GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality", PROPERTY_HINT_ENUM, "Hard (Fastest),Soft Very Low (Faster),Soft Low (Fast),Soft Medium (Average),Soft High (Slow),Soft Ultra (Slowest)"), 2); GLOBAL_DEF("rendering/lights_and_shadows/positional_shadow/soft_shadow_filter_quality.mobile", 0); - GLOBAL_DEF("rendering/2d/shadow_atlas/size", 2048); + GLOBAL_DEF(PropertyInfo(Variant::INT, "rendering/2d/shadow_atlas/size", PROPERTY_HINT_RANGE, "128,16384"), 2048); // Number of commands that can be drawn per frame. GLOBAL_DEF_RST(PropertyInfo(Variant::INT, "rendering/gl_compatibility/item_buffer_size", PROPERTY_HINT_RANGE, "128,1048576,1"), 16384);