From d2904c1fd5625e127ae7e8c79c3361bf62f18c13 Mon Sep 17 00:00:00 2001 From: lightningterror <18107717+lightningterror@users.noreply.github.com> Date: Fri, 10 Jun 2022 15:23:58 +0200 Subject: [PATCH] GS: Fix up wave filter shaders. --- bin/resources/shaders/dx11/present.fx | 10 ++++------ bin/resources/shaders/opengl/present.glsl | 12 ++---------- bin/resources/shaders/vulkan/present.glsl | 6 ++---- pcsx2/GS/Renderers/Metal/present.metal | 15 ++++----------- 4 files changed, 12 insertions(+), 31 deletions(-) diff --git a/bin/resources/shaders/dx11/present.fx b/bin/resources/shaders/dx11/present.fx index 648bb59ab6..2456fff3a2 100644 --- a/bin/resources/shaders/dx11/present.fx +++ b/bin/resources/shaders/dx11/present.fx @@ -135,12 +135,10 @@ PS_OUTPUT ps_filter_complex(PS_INPUT input) // triangular { PS_OUTPUT output; - float2 texdim, halfpixel; - Texture.GetDimensions(texdim.x, texdim.y); - if (ddy(input.t.y) * input.t.y > 0.5) - output.c = sample_c(input.t); - else - output.c = (0.9 - 0.4 * cos(2 * PI * input.t.y * texdim.y)) * sample_c(float2(input.t.x, (floor(input.t.y * texdim.y) + 0.5) / texdim.y)); + float2 texdim; + Texture.GetDimensions(texdim.x, texdim.y); + + output.c = (0.9 - 0.4 * cos(2 * PI * input.t.y * texdim.y)) * sample_c(float2(input.t.x, (floor(input.t.y * texdim.y) + 0.5) / texdim.y)); return output; } diff --git a/bin/resources/shaders/opengl/present.glsl b/bin/resources/shaders/opengl/present.glsl index 37076f8bfc..911dd01f4a 100644 --- a/bin/resources/shaders/opengl/present.glsl +++ b/bin/resources/shaders/opengl/present.glsl @@ -119,18 +119,10 @@ void ps_filter_triangular() // triangular #ifdef ps_filter_complex void ps_filter_complex() { - const float PI = 3.14159265359f; - vec2 texdim = vec2(textureSize(TextureSampler, 0)); - - vec4 c; - if (dFdy(PSin_t.y) * PSin_t.y > 0.5f) { - c = sample_c(); - } else { - float factor = (0.9f - 0.4f * cos(2.0f * PI * PSin_t.y * texdim.y)); - c = factor * texture(TextureSampler, vec2(PSin_t.x, (floor(PSin_t.y * texdim.y) + 0.5f) / texdim.y)); - } + float factor = (0.9f - 0.4f * cos(2.0f * PI * PSin_t.y * texdim.y)); + vec4 c = factor * texture(TextureSampler, vec2(PSin_t.x, (floor(PSin_t.y * texdim.y) + 0.5f) / texdim.y)); SV_Target0 = c; } diff --git a/bin/resources/shaders/vulkan/present.glsl b/bin/resources/shaders/vulkan/present.glsl index 8523e3014f..68c1d438e5 100644 --- a/bin/resources/shaders/vulkan/present.glsl +++ b/bin/resources/shaders/vulkan/present.glsl @@ -106,10 +106,8 @@ void ps_filter_complex() // triangular { const float PI = 3.14159265359f; vec2 texdim = vec2(textureSize(samp0, 0)); - if (dFdy(v_tex.y) * v_tex.y > 0.5) - o_col0 = sample_c(v_tex); - else - o_col0 = (0.9 - 0.4 * cos(2 * PI * v_tex.y * texdim.y)) * sample_c(vec2(v_tex.x, (floor(v_tex.y * texdim.y) + 0.5) / texdim.y)); + + o_col0 = (0.9 - 0.4 * cos(2 * PI * v_tex.y * texdim.y)) * sample_c(vec2(v_tex.x, (floor(v_tex.y * texdim.y) + 0.5) / texdim.y)); } #endif diff --git a/pcsx2/GS/Renderers/Metal/present.metal b/pcsx2/GS/Renderers/Metal/present.metal index ff5a600b6e..179b38f7f8 100644 --- a/pcsx2/GS/Renderers/Metal/present.metal +++ b/pcsx2/GS/Renderers/Metal/present.metal @@ -66,15 +66,8 @@ fragment float4 ps_filter_triangular(ConvertShaderData data [[stage_in]], Conver fragment float4 ps_filter_complex(ConvertShaderData data [[stage_in]], ConvertPSRes res) { float2 texdim = float2(res.texture.get_width(), res.texture.get_height()); - - if (dfdy(data.t.y) * texdim.y > 0.5) - { - return res.sample(data.t); - } - else - { - float factor = (0.9f - 0.4f * cos(2.f * M_PI_F * data.t.y * texdim.y)); - float ycoord = (floor(data.t.y * texdim.y) + 0.5f) / texdim.y; - return factor * res.sample(float2(data.t.x, ycoord)); - } + float factor = (0.9f - 0.4f * cos(2.f * M_PI_F * data.t.y * texdim.y)); + float ycoord = (floor(data.t.y * texdim.y) + 0.5f) / texdim.y; + + return factor * res.sample(float2(data.t.x, ycoord)); }