GS: Fix up wave filter shaders.

This commit is contained in:
lightningterror 2022-06-10 15:23:58 +02:00
parent 7718feedd5
commit d2904c1fd5
4 changed files with 12 additions and 31 deletions

View File

@ -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;
}

View File

@ -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;
}

View File

@ -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

View File

@ -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));
}