From ffff60882c99b9ab051e62114c906af6d4b8173a Mon Sep 17 00:00:00 2001 From: Panos Karabelas Date: Sun, 22 Oct 2023 19:34:39 +0100 Subject: [PATCH] [Renderer] Fixed an issue where FSR 2 would ghost if any transparent object was rendered --- runtime/Rendering/Renderer_Passes.cpp | 5 ++++- runtime/Rendering/Renderer_Resources.cpp | 6 +++--- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/runtime/Rendering/Renderer_Passes.cpp b/runtime/Rendering/Renderer_Passes.cpp index e59a8ae4c..99abb9fcd 100644 --- a/runtime/Rendering/Renderer_Passes.cpp +++ b/runtime/Rendering/Renderer_Passes.cpp @@ -585,6 +585,9 @@ namespace Spartan // deduce depth-stencil state RHI_DepthStencilState* depth_stencil_state = depth_prepass ? GetDepthStencilState(Renderer_DepthStencilState::Depth_read).get() : GetDepthStencilState(Renderer_DepthStencilState::Depth_read_write_stencil_read).get(); + // note: if is_transparent_pass is true we could simply clear the RTs, however we don't do this as fsr + // can be enabled, and if it is, it will expect the RTs to contain both the opaque and transparent data + uint32_t start_index = !is_transparent_pass ? 0 : 2; uint32_t end_index = !is_transparent_pass ? 2 : 4; bool is_first_pass = true; @@ -605,7 +608,7 @@ namespace Spartan pso.rasterizer_state = rasterizer_state; pso.depth_stencil_state = depth_stencil_state; pso.render_target_color_textures[0] = tex_albedo; - pso.clear_color[0] = (!is_first_pass || pso.instancing) ? rhi_color_load : Color::standard_transparent; + pso.clear_color[0] = (!is_first_pass || pso.instancing || is_transparent_pass) ? rhi_color_load : Color::standard_transparent; pso.render_target_color_textures[1] = tex_normal; pso.clear_color[1] = pso.clear_color[0]; pso.render_target_color_textures[2] = tex_material; diff --git a/runtime/Rendering/Renderer_Resources.cpp b/runtime/Rendering/Renderer_Resources.cpp index 97910c3ef..6ae062c57 100644 --- a/runtime/Rendering/Renderer_Resources.cpp +++ b/runtime/Rendering/Renderer_Resources.cpp @@ -303,7 +303,7 @@ namespace Spartan shader(Renderer_Shader::quad_p)->Compile(RHI_Shader_Pixel, shader_dir + "quad.hlsl", async); } - // vedlight depth + // light depth { shader(Renderer_Shader::depth_light_v) = make_shared(); shader(Renderer_Shader::depth_light_v)->Compile(RHI_Shader_Vertex, shader_dir + "depth_light.hlsl", async, RHI_Vertex_Type::PosUvNorTan); @@ -460,13 +460,13 @@ namespace Spartan shader(Renderer_Shader::temporal_filter_c) = make_shared(); shader(Renderer_Shader::temporal_filter_c)->Compile(RHI_Shader_Compute, shader_dir + "temporal_filter.hlsl", async); - // AMD FidelityFX CAS - Contrast Adaptive Sharpening + // amd fidelityfx cas - Contrast Adaptive Sharpening shader(Renderer_Shader::ffx_cas_c) = make_shared(); shader(Renderer_Shader::ffx_cas_c)->Compile(RHI_Shader_Compute, shader_dir + "amd_fidelity_fx\\cas.hlsl", async); // compiled immediately, they are needed the moment the engine starts. { - // AMD FidelityFX SPD - Single Pass Downsample + // amd fidelityfx spd - single pass downsample shader(Renderer_Shader::ffx_spd_c) = make_shared(); shader(Renderer_Shader::ffx_spd_c)->Compile(RHI_Shader_Compute, shader_dir + "amd_fidelity_fx\\spd.hlsl", false);