[XCX] Replace broken sharpen pass in AA with configurable version

This commit is contained in:
getdls 2018-02-28 00:49:05 +01:00
parent 681ff3e42b
commit 3c49e8617a

View File

@ -7,6 +7,7 @@ $scaleFactorY = always_decimal_format($fullHeight / 720.0);
?>
#version 420
#extension GL_ARB_texture_gather : enable
const float sharpen_strength = 0.1;
// shader 59df1c7e1806366c
// aa-restore. Intial version
//To - do //R2i.xyzw is possible a cemu bug. Replace with Alex FXAA
@ -19,6 +20,40 @@ layout(location = 0) in vec4 passParameterSem0;
layout(location = 1) in vec4 passParameterSem1;
layout(location = 0) out vec4 passPixelColor0;
vec3 blurSample(in vec2 uv, in vec2 xoff, in vec2 yoff)
{
vec3 v11 = texture(textureUnitPS1, uv + xoff).rgb;
vec3 v12 = texture(textureUnitPS1, uv + yoff).rgb;
vec3 v21 = texture(textureUnitPS1, uv - xoff).rgb;
vec3 v22 = texture(textureUnitPS1, uv - yoff).rgb;
return (v11 + v12 + v21 + v22 + 2.0 * texture(textureUnitPS1, uv).rgb) * 0.166667;
}
vec3 edgeStrength(in vec2 uv)
{
const float spread = 0.5;
vec2 offset = vec2(1.0) / textureSize(textureUnitPS0, 0);
vec2 up = vec2(0.0, offset.y) * spread;
vec2 right = vec2(offset.x, 0.0) * spread;
const float frad = 3.0;
vec3 v11 = blurSample(uv + up - right, right, up);
vec3 v12 = blurSample(uv + up, right, up);
vec3 v13 = blurSample(uv + up + right, right, up);
vec3 v21 = blurSample(uv - right, right, up);
vec3 v22 = blurSample(uv, right, up);
vec3 v23 = blurSample(uv + right, right, up);
vec3 v31 = blurSample(uv - up - right, right, up);
vec3 v32 = blurSample(uv - up, right, up);
vec3 v33 = blurSample(uv - up + right, right, up);
vec3 laplacian_of_g = v11 * 0.0 + v12 * 1.0 + v13 * 0.0
+ v21 * 1.0 + v22 * -4.0 + v23 * 1.0
+ v31 * 0.0 + v32 * 1.0 + v33 * 0.0;
laplacian_of_g = laplacian_of_g * 1.0;
return laplacian_of_g.xyz;
}
uniform vec2 uf_fragCoordScale;
int clampFI32(int v)
{
@ -218,6 +253,11 @@ R4i.x = ((PV0i.w == 0)?(R127i.x):(R127i.z));
R4i.y = ((PV0i.w == 0)?(R127i.w):(R126i.y));
R4i.z = ((PV0i.w == 0)?(R126i.z):(R126i.w));
}
vec2 uv = gl_FragCoord.xy / textureSize(textureUnitPS0, 0);
vec4 sharpColour = vec4(texture(textureUnitPS1, uv).xyz - edgeStrength(uv) * sharpen_strength, 1.0);
// export
passPixelColor0 = vec4(intBitsToFloat(R4i.x), intBitsToFloat(R4i.y), intBitsToFloat(R4i.z), intBitsToFloat(R4i.w));
//passPixelColor0 = vec4(intBitsToFloat(R4i.x), intBitsToFloat(R4i.y), intBitsToFloat(R4i.z), intBitsToFloat(R4i.w));
passPixelColor0 = mix(sharpColour, vec4(intBitsToFloat(R4i.x), intBitsToFloat(R4i.y), intBitsToFloat(R4i.z), intBitsToFloat(R4i.w)), 0.5);
}