From b1e24597e7d710e677d44b920889a78d7d719ffa Mon Sep 17 00:00:00 2001 From: lawnjelly Date: Mon, 1 Mar 2021 11:26:11 +0000 Subject: [PATCH] Renaming rendering/2d project settings. The rendering/quality/2d section of project settings is becoming considerably expanded in 3.2.4, and arguably was not the correct place for settings that were not really to do with quality. 3.2.4 is the last sensible opportunity we will have to move these settings, as the only existing one likely to break compatibility in a small way is `pixel_snap`, and given that the whole snapping area is being overhauled we can draw attention to the fact it has changed in the release notes. Class reference is also updated and slightly improved. `pixel_snap` is renamed to `gpu_pixel_snap` in the project settings and code to help differentiate from CPU side transform snapping. --- core/engine.cpp | 2 +- core/engine.h | 4 +- doc/classes/ProjectSettings.xml | 53 ++++++++++--------- .../gles2/rasterizer_canvas_base_gles2.cpp | 2 +- .../gles3/rasterizer_canvas_base_gles3.cpp | 2 +- .../gles_common/rasterizer_canvas_batcher.h | 6 +-- main/main.cpp | 8 +-- scene/2d/animated_sprite.cpp | 2 +- scene/2d/sprite.cpp | 4 +- servers/visual_server.cpp | 6 +-- 10 files changed, 45 insertions(+), 44 deletions(-) diff --git a/core/engine.cpp b/core/engine.cpp index 5dc10295bb1..d0f35b3b82e 100644 --- a/core/engine.cpp +++ b/core/engine.cpp @@ -227,7 +227,7 @@ Engine::Engine() { _fps = 1; _target_fps = 0; _time_scale = 1.0; - _pixel_snap = false; + _gpu_pixel_snap = false; _snap_2d_transforms = false; _physics_frames = 0; _idle_frames = 0; diff --git a/core/engine.h b/core/engine.h index 57c3368d198..66069916198 100644 --- a/core/engine.h +++ b/core/engine.h @@ -58,7 +58,7 @@ private: float _fps; int _target_fps; float _time_scale; - bool _pixel_snap; + bool _gpu_pixel_snap; bool _snap_2d_transforms; bool _snap_2d_viewports; uint64_t _physics_frames; @@ -108,7 +108,7 @@ public: bool has_singleton(const String &p_name) const; Object *get_singleton_object(const String &p_name) const; - _FORCE_INLINE_ bool get_use_pixel_snap() const { return _pixel_snap; } + _FORCE_INLINE_ bool get_use_gpu_pixel_snap() const { return _gpu_pixel_snap; } bool get_snap_2d_transforms() const { return _snap_2d_transforms; } bool get_snap_2d_viewports() const { return _snap_2d_viewports; } diff --git a/doc/classes/ProjectSettings.xml b/doc/classes/ProjectSettings.xml index f7c0671bb6c..af85d8cbf3d 100644 --- a/doc/classes/ProjectSettings.xml +++ b/doc/classes/ProjectSettings.xml @@ -435,7 +435,7 @@ Maximum number of contact points between collision shapes to display when "Visible Collision Shapes" is enabled in the Debug menu. - + Color of the collision shapes, visible when "Visible Collision Shapes" is enabled in the Debug menu. @@ -1031,6 +1031,32 @@ Fix to improve physics jitter, specially on monitors where refresh rate is different than the physics FPS. [b]Note:[/b] This property is only read when the project starts. To change the physics FPS at runtime, set [member Engine.physics_jitter_fix] instead. + + Choose between default mode where corner scalings are preserved matching the artwork, and scaling mode. + Not available in GLES3 when [member rendering/batching/options/use_batching] is off. + + + Some NVIDIA GPU drivers have a bug which produces flickering issues for the [code]draw_rect[/code] method, especially as used in [TileMap]. Refer to [url=https://github.com/godotengine/godot/issues/9913]GitHub issue 9913[/url] for details. + If [code]true[/code], this option enables a "safe" code path for such NVIDIA GPUs at the cost of performance. This option affects GLES2 and GLES3 rendering, but only on desktop platforms. + + + If [code]true[/code], performs 2D skinning on the CPU rather than the GPU. This provides greater compatibility with a wide range of hardware, and also may be faster in some circumstances. + Currently only available when [member rendering/batching/options/use_batching] is active. + [b]Note:[/b] Antialiased software skinned polys are not supported, and will be rendered without antialiasing. + + + If [code]true[/code], forces snapping of 2D viewports to the nearest whole coordinate. + Can reduce unwanted camera relative movement in pixel art styles. + + + If [code]true[/code], forces snapping of vertices to pixels in 2D rendering. May help in some pixel art styles. + This snapping is performed on the GPU in the vertex shader. + Consider using the project setting [member rendering/batching/precision/uv_contract] to prevent artifacts. + + + If [code]true[/code], forces snapping of 2D object transforms to the nearest whole coordinate. + Can help prevent unwanted relative movement in pixel art styles. + When batching is on, this regularly prints a frame diagnosis log. Note that this will degrade performance. @@ -1124,31 +1150,6 @@ Shaders have a time variable that constantly increases. At some point, it needs to be rolled back to zero to avoid precision errors on shader animations. This setting specifies when (in seconds). - - Choose between default mode where corner scalings are preserved matching the artwork, and scaling mode. - Not available in GLES3 when [member rendering/batching/options/use_batching] is off. - - - If [code]true[/code], forces snapping of 2D viewports to the nearest whole coordinate. - Can reduce unwanted camera relative movement in pixel art styles. - - - Some NVIDIA GPU drivers have a bug which produces flickering issues for the [code]draw_rect[/code] method, especially as used in [TileMap]. Refer to [url=https://github.com/godotengine/godot/issues/9913]GitHub issue 9913[/url] for details. - If [code]true[/code], this option enables a "safe" code path for such NVIDIA GPUs at the cost of performance. This option affects GLES2 and GLES3 rendering, but only on desktop platforms. - - - If [code]true[/code], forces snapping of polygons to pixels in 2D rendering. May help in some pixel art styles. - Consider using the project setting [member rendering/batching/precision/uv_contract] to prevent artifacts. - - - If [code]true[/code], performs 2D skinning on the CPU rather than the GPU. This provides greater compatibility with a wide range of hardware, and also may be faster in some circumstances. - Currently only available when [member rendering/batching/options/use_batching] is active. - [b]Note:[/b] Antialiased software skinned polys are not supported, and will be rendered without antialiasing. - - - If [code]true[/code], forces snapping of 2D object transforms to the nearest whole coordinate. - Can help prevent unwanted relative movement in pixel art styles. - If [code]true[/code], allocates the main framebuffer with high dynamic range. High dynamic range allows the use of [Color] values greater than 1. [b]Note:[/b] Only available on the GLES3 backend. diff --git a/drivers/gles2/rasterizer_canvas_base_gles2.cpp b/drivers/gles2/rasterizer_canvas_base_gles2.cpp index 7d930b54118..9cdbb5b4899 100644 --- a/drivers/gles2/rasterizer_canvas_base_gles2.cpp +++ b/drivers/gles2/rasterizer_canvas_base_gles2.cpp @@ -1074,7 +1074,7 @@ void RasterizerCanvasBaseGLES2::initialize() { state.lens_shader.init(); - state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false)); + state.canvas_shader.set_conditional(CanvasShaderGLES2::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/2d/snapping/use_gpu_pixel_snap", false)); state.using_light = NULL; state.using_transparent_rt = false; diff --git a/drivers/gles3/rasterizer_canvas_base_gles3.cpp b/drivers/gles3/rasterizer_canvas_base_gles3.cpp index 07f17482386..d0a85e0e2f0 100644 --- a/drivers/gles3/rasterizer_canvas_base_gles3.cpp +++ b/drivers/gles3/rasterizer_canvas_base_gles3.cpp @@ -1292,7 +1292,7 @@ void RasterizerCanvasBaseGLES3::initialize() { state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows); state.canvas_shadow_shader.set_conditional(CanvasShadowShaderGLES3::USE_RGBA_SHADOWS, storage->config.use_rgba_2d_shadows); - state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false)); + state.canvas_shader.set_conditional(CanvasShaderGLES3::USE_PIXEL_SNAP, GLOBAL_DEF("rendering/2d/snapping/use_gpu_pixel_snap", false)); } void RasterizerCanvasBaseGLES3::finalize() { diff --git a/drivers/gles_common/rasterizer_canvas_batcher.h b/drivers/gles_common/rasterizer_canvas_batcher.h index d0c1acf3304..0fe00f6a16c 100644 --- a/drivers/gles_common/rasterizer_canvas_batcher.h +++ b/drivers/gles_common/rasterizer_canvas_batcher.h @@ -969,7 +969,7 @@ PREAMBLE(void)::batch_constructor() { bdata.settings_use_batching = false; #ifdef GLES_OVER_GL - use_nvidia_rect_workaround = GLOBAL_GET("rendering/quality/2d/use_nvidia_rect_flicker_workaround"); + use_nvidia_rect_workaround = GLOBAL_GET("rendering/2d/options/use_nvidia_rect_flicker_workaround"); #else // Not needed (a priori) on GLES devices use_nvidia_rect_workaround = false; @@ -983,8 +983,8 @@ PREAMBLE(void)::batch_initialize() { bdata.settings_item_reordering_lookahead = GLOBAL_GET("rendering/batching/parameters/item_reordering_lookahead"); bdata.settings_light_max_join_items = GLOBAL_GET("rendering/batching/lights/max_join_items"); bdata.settings_use_single_rect_fallback = GLOBAL_GET("rendering/batching/options/single_rect_fallback"); - bdata.settings_use_software_skinning = GLOBAL_GET("rendering/quality/2d/use_software_skinning"); - bdata.settings_ninepatch_mode = GLOBAL_GET("rendering/quality/2d/ninepatch_mode"); + bdata.settings_use_software_skinning = GLOBAL_GET("rendering/2d/options/use_software_skinning"); + bdata.settings_ninepatch_mode = GLOBAL_GET("rendering/2d/options/ninepatch_mode"); // alternatively only enable uv contract if pixel snap in use, // but with this enable bool, it should not be necessary diff --git a/main/main.cpp b/main/main.cpp index d9ce57dd26c..78257855943 100644 --- a/main/main.cpp +++ b/main/main.cpp @@ -1040,7 +1040,7 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph GLOBAL_DEF("rendering/quality/driver/fallback_to_gles2", false); // Assigning here, to be sure that it appears in docs - GLOBAL_DEF("rendering/quality/2d/use_nvidia_rect_flicker_workaround", false); + GLOBAL_DEF("rendering/2d/options/use_nvidia_rect_flicker_workaround", false); GLOBAL_DEF("display/window/size/width", 1024); ProjectSettings::get_singleton()->set_custom_property_info("display/window/size/width", PropertyInfo(Variant::INT, "display/window/size/width", PROPERTY_HINT_RANGE, "0,7680,or_greater")); // 8K resolution @@ -1124,9 +1124,9 @@ Error Main::setup(const char *execpath, int argc, char *argv[], bool p_second_ph OS::get_singleton()->_allow_layered = false; } - Engine::get_singleton()->_pixel_snap = GLOBAL_DEF("rendering/quality/2d/use_pixel_snap", false); - Engine::get_singleton()->_snap_2d_transforms = GLOBAL_DEF("rendering/quality/2d/use_transform_snap", false); - Engine::get_singleton()->_snap_2d_viewports = GLOBAL_DEF("rendering/quality/2d/use_camera_snap", false); + Engine::get_singleton()->_gpu_pixel_snap = GLOBAL_DEF("rendering/2d/snapping/use_gpu_pixel_snap", false); + Engine::get_singleton()->_snap_2d_transforms = GLOBAL_DEF("rendering/2d/snapping/use_transform_snap", false); + Engine::get_singleton()->_snap_2d_viewports = GLOBAL_DEF("rendering/2d/snapping/use_camera_snap", false); OS::get_singleton()->_keep_screen_on = GLOBAL_DEF("display/window/energy_saving/keep_screen_on", true); if (rtm == -1) { rtm = GLOBAL_DEF("rendering/threads/thread_model", OS::RENDER_THREAD_SAFE); diff --git a/scene/2d/animated_sprite.cpp b/scene/2d/animated_sprite.cpp index 4d9378c47a1..6769dcc0cde 100644 --- a/scene/2d/animated_sprite.cpp +++ b/scene/2d/animated_sprite.cpp @@ -454,7 +454,7 @@ void AnimatedSprite::_notification(int p_what) { if (Engine::get_singleton()->get_snap_2d_transforms()) { ofs = ofs.round(); - } else if (Engine::get_singleton()->get_use_pixel_snap()) { + } else if (Engine::get_singleton()->get_use_gpu_pixel_snap()) { ofs = ofs.floor(); } Rect2 dst_rect(ofs, s); diff --git a/scene/2d/sprite.cpp b/scene/2d/sprite.cpp index adcabc93341..7040a1741cc 100644 --- a/scene/2d/sprite.cpp +++ b/scene/2d/sprite.cpp @@ -102,7 +102,7 @@ void Sprite::_get_rects(Rect2 &r_src_rect, Rect2 &r_dst_rect, bool &r_filter_cli if (Engine::get_singleton()->get_snap_2d_transforms()) { dest_offset = dest_offset.round(); - } else if (Engine::get_singleton()->get_use_pixel_snap()) { + } else if (Engine::get_singleton()->get_use_gpu_pixel_snap()) { dest_offset = dest_offset.floor(); } @@ -383,7 +383,7 @@ Rect2 Sprite::get_rect() const { ofs -= Size2(s) / 2; if (Engine::get_singleton()->get_snap_2d_transforms()) { ofs = ofs.round(); - } else if (Engine::get_singleton()->get_use_pixel_snap()) { + } else if (Engine::get_singleton()->get_use_gpu_pixel_snap()) { ofs = ofs.floor(); } diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index f022651a8ad..ead05d1e4b3 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -2448,9 +2448,9 @@ VisualServer::VisualServer() { GLOBAL_DEF(sz_balance_render_tree, 0.0f); ProjectSettings::get_singleton()->set_custom_property_info(sz_balance_render_tree, PropertyInfo(Variant::REAL, sz_balance_render_tree, PROPERTY_HINT_RANGE, "0.0,1.0,0.01")); - GLOBAL_DEF("rendering/quality/2d/use_software_skinning", true); - GLOBAL_DEF("rendering/quality/2d/ninepatch_mode", 0); - ProjectSettings::get_singleton()->set_custom_property_info("rendering/quality/2d/ninepatch_mode", PropertyInfo(Variant::INT, "rendering/quality/2d/ninepatch_mode", PROPERTY_HINT_ENUM, "Default,Scaling")); + GLOBAL_DEF("rendering/2d/options/use_software_skinning", true); + GLOBAL_DEF("rendering/2d/options/ninepatch_mode", 0); + ProjectSettings::get_singleton()->set_custom_property_info("rendering/2d/options/ninepatch_mode", PropertyInfo(Variant::INT, "rendering/2d/options/ninepatch_mode", PROPERTY_HINT_ENUM, "Default,Scaling")); GLOBAL_DEF("rendering/batching/options/use_batching", true); GLOBAL_DEF_RST("rendering/batching/options/use_batching_in_editor", true);