From 26a220bd312ae42b4b1b1833ed01242963ebcaf5 Mon Sep 17 00:00:00 2001 From: Hugo Locurcio Date: Thu, 7 Mar 2024 17:40:19 +0100 Subject: [PATCH] Make Overdraw, Lighting and Shadow Splits debug draw modes ignore decals This also makes the Overdraw and Shadow Splits debug draw modes ignore fog. The Lighting debug draw mode still displays fog as that debug draw mode is intended to preview scene lighting, and fog has an impact on how lighting is perceived. --- drivers/gles3/rasterizer_scene_gles3.cpp | 6 +++--- .../scene_shader_forward_clustered.cpp | 10 +++++----- .../forward_mobile/scene_shader_forward_mobile.cpp | 10 +++++----- .../rendering/renderer_rd/renderer_scene_render_rd.cpp | 9 ++++++++- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/drivers/gles3/rasterizer_scene_gles3.cpp b/drivers/gles3/rasterizer_scene_gles3.cpp index f9af86e19b51..09edc1211233 100644 --- a/drivers/gles3/rasterizer_scene_gles3.cpp +++ b/drivers/gles3/rasterizer_scene_gles3.cpp @@ -4075,7 +4075,7 @@ RasterizerSceneGLES3::RasterizerSceneGLES3() { scene_globals.default_shader = material_storage->shader_allocate(); material_storage->shader_initialize(scene_globals.default_shader); material_storage->shader_set_code(scene_globals.default_shader, R"( -// Default 3D material shader. +// Default 3D material shader (Compatibility). shader_type spatial; @@ -4100,11 +4100,11 @@ void fragment() { scene_globals.overdraw_shader = material_storage->shader_allocate(); material_storage->shader_initialize(scene_globals.overdraw_shader); material_storage->shader_set_code(scene_globals.overdraw_shader, R"( -// 3D editor Overdraw debug draw mode shader. +// 3D editor Overdraw debug draw mode shader (Compatibility). shader_type spatial; -render_mode blend_add, unshaded; +render_mode blend_add, unshaded, fog_disabled; void fragment() { ALBEDO = vec3(0.4, 0.8, 0.8); diff --git a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp index 55c6c420eb58..0b504eca0a99 100644 --- a/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp +++ b/servers/rendering/renderer_rd/forward_clustered/scene_shader_forward_clustered.cpp @@ -737,7 +737,7 @@ void SceneShaderForwardClustered::init(const String p_defines) { default_shader = material_storage->shader_allocate(); material_storage->shader_initialize(default_shader); material_storage->shader_set_code(default_shader, R"( -// Default 3D material shader (clustered). +// Default 3D material shader (Forward+). shader_type spatial; @@ -768,11 +768,11 @@ void fragment() { material_storage->shader_initialize(overdraw_material_shader); // Use relatively low opacity so that more "layers" of overlapping objects can be distinguished. material_storage->shader_set_code(overdraw_material_shader, R"( -// 3D editor Overdraw debug draw mode shader (clustered). +// 3D editor Overdraw debug draw mode shader (Forward+). shader_type spatial; -render_mode blend_add, unshaded; +render_mode blend_add, unshaded, fog_disabled; void fragment() { ALBEDO = vec3(0.4, 0.8, 0.8); @@ -792,11 +792,11 @@ void fragment() { debug_shadow_splits_material_shader = material_storage->shader_allocate(); material_storage->shader_initialize(debug_shadow_splits_material_shader); material_storage->shader_set_code(debug_shadow_splits_material_shader, R"( -// 3D debug shadow splits mode shader(mobile). +// 3D debug shadow splits mode shader (Forward+). shader_type spatial; -render_mode debug_shadow_splits; +render_mode debug_shadow_splits, fog_disabled; void fragment() { ALBEDO = vec3(1.0, 1.0, 1.0); diff --git a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp index 3592ee2f6d12..95ba76a707df 100644 --- a/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp +++ b/servers/rendering/renderer_rd/forward_mobile/scene_shader_forward_mobile.cpp @@ -641,7 +641,7 @@ void SceneShaderForwardMobile::init(const String p_defines) { default_shader = material_storage->shader_allocate(); material_storage->shader_initialize(default_shader); material_storage->shader_set_code(default_shader, R"( -// Default 3D material shader (mobile). +// Default 3D material shader (Mobile). shader_type spatial; @@ -671,11 +671,11 @@ void fragment() { material_storage->shader_initialize(overdraw_material_shader); // Use relatively low opacity so that more "layers" of overlapping objects can be distinguished. material_storage->shader_set_code(overdraw_material_shader, R"( -// 3D editor Overdraw debug draw mode shader (mobile). +// 3D editor Overdraw debug draw mode shader (Mobile). shader_type spatial; -render_mode blend_add, unshaded; +render_mode blend_add, unshaded, fog_disabled; void fragment() { ALBEDO = vec3(0.4, 0.8, 0.8); @@ -696,11 +696,11 @@ void fragment() { material_storage->shader_initialize(debug_shadow_splits_material_shader); // Use relatively low opacity so that more "layers" of overlapping objects can be distinguished. material_storage->shader_set_code(debug_shadow_splits_material_shader, R"( -// 3D debug shadow splits mode shader(mobile). +// 3D debug shadow splits mode shader (Mobile). shader_type spatial; -render_mode debug_shadow_splits; +render_mode debug_shadow_splits, fog_disabled; void fragment() { ALBEDO = vec3(1.0, 1.0, 1.0); diff --git a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp index 62ecec39919e..e61bb9eae82f 100644 --- a/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp +++ b/servers/rendering/renderer_rd/renderer_scene_render_rd.cpp @@ -1153,12 +1153,19 @@ void RendererSceneRenderRD::render_scene(const Ref &p_render PagedArray empty; - if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED) { + if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED || get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_OVERDRAW) { render_data.lights = ∅ render_data.reflection_probes = ∅ render_data.voxel_gi_instances = ∅ } + if (get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_UNSHADED || + get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_OVERDRAW || + get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_LIGHTING || + get_debug_draw_mode() == RS::VIEWPORT_DEBUG_DRAW_PSSM_SPLITS) { + render_data.decals = ∅ + } + Color clear_color; if (p_render_buffers.is_valid() && p_reflection_probe.is_null()) { clear_color = texture_storage->render_target_get_clear_request_color(rb->get_render_target());