
#version 420
#extension GL_ARB_texture_gather : enable
const float sharpen_strength = 0.2;  //0 off, 1 full (edge haloing) note, off = use only blur aa
// shader 59df1c7e1806366c 
// aa-restore + sharpen pass. AA removal will override any setting here
const float resScale = 4.5;
uniform ivec4 uf_remappedPS[2];
layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf4e12000 res 1280x720x1 dim 1 tm: 4 format 0001 compSel: 0 4 4 5 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 0
layout(binding = 1) uniform sampler2D textureUnitPS1;// Tex1 addr 0xf470a000 res 1280x720x1 dim 1 tm: 4 format 0816 compSel: 0 1 2 5 mipView: 0x0 (num 0x1) sliceView: 0x0 (num 0x1) Sampler1 ClampX/Y/Z: 2 2 2 border: 0
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)
{
if( v == 0x7FFFFFFF )
	return floatBitsToInt(1.0);
else if( v == 0xFFFFFFFF )
	return floatBitsToInt(0.0);
return floatBitsToInt(clamp(intBitsToFloat(v), 0.0, 1.0));
}
float mul_nonIEEE(float a, float b){ return min(a*b,min(abs(a)*3.40282347E+38F,abs(b)*3.40282347E+38F)); }
void main()
{
ivec4 R0i = ivec4(0);
ivec4 R1i = ivec4(0);
ivec4 R2i = ivec4(0);
ivec4 R3i = ivec4(0);
ivec4 R4i = ivec4(0);
ivec4 R123i = ivec4(0);
ivec4 R126i = ivec4(0);
ivec4 R127i = ivec4(0);
int backupReg0i, backupReg1i, backupReg2i, backupReg3i, backupReg4i;
ivec4 PV0i = ivec4(0), PV1i = ivec4(0);
int PS0i = 0, PS1i = 0;
ivec4 tempi = ivec4(0);
float tempResultf;
int tempResulti;
ivec4 ARi = ivec4(0);
bool predResult = true;
bool activeMaskStack[2];
bool activeMaskStackC[3];
activeMaskStack[0] = false;
activeMaskStackC[0] = false;
activeMaskStackC[1] = false;
activeMaskStack[0] = true;
activeMaskStackC[0] = true;
activeMaskStackC[1] = true;
vec3 cubeMapSTM;
int cubeMapFaceId;
R0i = floatBitsToInt(passParameterSem0);
R1i = floatBitsToInt(passParameterSem1);
if( activeMaskStackC[1] == true ) {
//R2i.xyzw = floatBitsToInt(textureGather(textureUnitPS0, intBitsToFloat(R0i.zw)).xyzw); // cemu bug? Review later
//R0i.x = floatBitsToInt(texture(textureUnitPS0, intBitsToFloat(R1i.xy)).x); // edge blur/chromatic
}
if( activeMaskStackC[1] == true ) {
activeMaskStack[1] = activeMaskStack[0];
activeMaskStackC[2] = activeMaskStackC[1];
// 0
backupReg0i = R2i.x;
R2i.x = floatBitsToInt(intBitsToFloat(backupReg0i) + intBitsToFloat(0x3aaaaaab)); //0.0026041667 / 2 0x3aaaaaab
PV0i.x = R2i.x;
R127i.y = floatBitsToInt(max(intBitsToFloat(R2i.y), intBitsToFloat(R2i.w)));
R127i.z = floatBitsToInt(min(intBitsToFloat(R2i.y), intBitsToFloat(R2i.w)));
// 1
PV1i.y = floatBitsToInt(min(intBitsToFloat(R2i.z), intBitsToFloat(PV0i.x)));
PV1i.w = floatBitsToInt(max(intBitsToFloat(R2i.z), intBitsToFloat(PV0i.x)));
// 2
R4i.y = floatBitsToInt(max(intBitsToFloat(R127i.y), intBitsToFloat(PV1i.w)));
PV0i.y = R4i.y;
R4i.z = floatBitsToInt(min(intBitsToFloat(R127i.z), intBitsToFloat(PV1i.y)));
PV0i.z = R4i.z;
// 3
backupReg0i = R0i.x;
backupReg0i = R0i.x;
PV1i.x = floatBitsToInt(intBitsToFloat(PV0i.y) * intBitsToFloat(uf_remappedPS[0].x)/resScale);
PV1i.y = floatBitsToInt(max(intBitsToFloat(backupReg0i), intBitsToFloat(PV0i.y)));
PV1i.z = floatBitsToInt(min(intBitsToFloat(backupReg0i), intBitsToFloat(PV0i.z)));
// 4
R0i.x = floatBitsToInt(-(intBitsToFloat(PV1i.z)) + intBitsToFloat(PV1i.y));
R0i.w = floatBitsToInt(max(intBitsToFloat(PV1i.x), intBitsToFloat(uf_remappedPS[0].y)));
// 5
backupReg0i = R0i.x;
predResult = (intBitsToFloat(R0i.w) > intBitsToFloat(backupReg0i));
activeMaskStack[1] = predResult;
activeMaskStackC[2] = predResult == true && activeMaskStackC[1] == true;
}
else {
activeMaskStack[1] = false;
activeMaskStackC[2] = false;
}
if( activeMaskStackC[2] == true ) {
// 0
if(  (0 == 0)) discard;
}
activeMaskStackC[1] = activeMaskStack[0] == true && activeMaskStackC[0] == true;
if( activeMaskStackC[1] == true ) {
// 0
R127i.x = floatBitsToInt(dot(vec4(intBitsToFloat(R2i.x),intBitsToFloat(R2i.y),intBitsToFloat(R2i.z),intBitsToFloat(R2i.w)),vec4(-(1.0),1.0,1.0,-(1.0))));
PV0i.x = R127i.x;
PV0i.y = R127i.x;
PV0i.z = R127i.x;
PV0i.w = R127i.x;
R127i.z = 0;
PS0i = R127i.z;
// 1
tempi.x = floatBitsToInt(dot(vec4(intBitsToFloat(R2i.x),intBitsToFloat(R2i.y),intBitsToFloat(R2i.z),intBitsToFloat(R2i.w)),vec4(-(1.0),1.0,-(1.0),1.0)));
PV1i.x = tempi.x;
PV1i.y = tempi.x;
PV1i.z = tempi.x;
PV1i.w = tempi.x;
R127i.y = tempi.x;
R4i.w = 0x3f800000;
PS1i = R4i.w;
// 2
tempi.x = floatBitsToInt(dot(vec4(intBitsToFloat(R127i.x),intBitsToFloat(PV1i.x),intBitsToFloat(R127i.z),-0.0),vec4(intBitsToFloat(R127i.x),intBitsToFloat(PV1i.x),intBitsToFloat(R127i.z),0.0)));
PV0i.x = tempi.x;
PV0i.y = tempi.x;
PV0i.z = tempi.x;
PV0i.w = tempi.x;
// 3
tempResultf = 1.0 / sqrt(intBitsToFloat(PV0i.x));
PS1i = floatBitsToInt(tempResultf);
// 4
backupReg0i = R127i.x;
R127i.x = floatBitsToInt(intBitsToFloat(backupReg0i) * intBitsToFloat(PS1i));
PV0i.x = R127i.x;
R127i.w = floatBitsToInt(intBitsToFloat(R127i.y) * intBitsToFloat(PS1i));
PV0i.w = R127i.w;
// 5
PV1i.x = floatBitsToInt(max(intBitsToFloat(PV0i.x), -(intBitsToFloat(PV0i.x))));
PV1i.y = floatBitsToInt(intBitsToFloat(PV0i.w) * intBitsToFloat(uf_remappedPS[1].y)/ resScale);
PV1i.z = floatBitsToInt(intBitsToFloat(PV0i.x) * intBitsToFloat(uf_remappedPS[1].x)/ resScale);
PV1i.w = floatBitsToInt(max(intBitsToFloat(PV0i.w), -(intBitsToFloat(PV0i.w))));
// 6
R0i.x = floatBitsToInt(intBitsToFloat(R1i.x) + -(intBitsToFloat(PV1i.z)));
R0i.y = floatBitsToInt(intBitsToFloat(R1i.y) + -(intBitsToFloat(PV1i.y)));
PV0i.z = floatBitsToInt(min(intBitsToFloat(PV1i.x), intBitsToFloat(PV1i.w)));
R2i.w = floatBitsToInt(intBitsToFloat(R1i.x) + intBitsToFloat(PV1i.z));
R2i.y = floatBitsToInt(intBitsToFloat(R1i.y) + intBitsToFloat(PV1i.y));
PS0i = R2i.y;
// 7
PV1i.y = floatBitsToInt(intBitsToFloat(PV0i.z) * intBitsToFloat(uf_remappedPS[0].z)/ resScale);
// 8
PS0i = floatBitsToInt(1.0 / intBitsToFloat(PV1i.y));
// 9
PV1i.z = floatBitsToInt(intBitsToFloat(R127i.w) * intBitsToFloat(PS0i));
PV1i.w = floatBitsToInt(intBitsToFloat(R127i.x) * intBitsToFloat(PS0i));
// 10
PV0i.x = floatBitsToInt(max(intBitsToFloat(PV1i.z), intBitsToFloat(0xc0000000)));
PV0i.y = floatBitsToInt(max(intBitsToFloat(PV1i.w), intBitsToFloat(0xc0000000)));
// 11
PV1i.z = floatBitsToInt(min(intBitsToFloat(PV0i.x), 2.0));
PV1i.w = floatBitsToInt(min(intBitsToFloat(PV0i.y), 2.0));
// 12
PV0i.x = floatBitsToInt(intBitsToFloat(PV1i.z) * intBitsToFloat(uf_remappedPS[1].w)/ resScale);
PV0i.w = floatBitsToInt(intBitsToFloat(PV1i.w) * intBitsToFloat(uf_remappedPS[1].z)/ resScale);
// 13
backupReg0i = R1i.x;
backupReg1i = R1i.y;
backupReg0i = R1i.x;
backupReg1i = R1i.y;
R1i.x = floatBitsToInt(intBitsToFloat(backupReg0i) + -(intBitsToFloat(PV0i.w)));
R1i.y = floatBitsToInt(intBitsToFloat(backupReg1i) + -(intBitsToFloat(PV0i.x)));
R0i.z = floatBitsToInt(intBitsToFloat(backupReg0i) + intBitsToFloat(PV0i.w));
R0i.w = floatBitsToInt(intBitsToFloat(backupReg1i) + intBitsToFloat(PV0i.x));
}
if( activeMaskStackC[1] == true ) {
R1i.xyz = floatBitsToInt(texture(textureUnitPS1, intBitsToFloat(R1i.xy)).xyz);
R3i.xyz = floatBitsToInt(texture(textureUnitPS1, intBitsToFloat(R0i.zw)).xyz);
R0i.xyz = floatBitsToInt(texture(textureUnitPS1, intBitsToFloat(R0i.xy)).xyz);
R2i.xyz = floatBitsToInt(texture(textureUnitPS1, intBitsToFloat(R2i.wy)).xyz);
}
if( activeMaskStackC[1] == true ) {
// 0
R127i.x = floatBitsToInt(intBitsToFloat(R1i.z) + intBitsToFloat(R3i.z));
PV0i.y = floatBitsToInt(intBitsToFloat(R1i.y) + intBitsToFloat(R3i.y));
PV0i.z = floatBitsToInt(intBitsToFloat(R1i.x) + intBitsToFloat(R3i.x));
// 1
backupReg0i = R0i.x;
PV1i.x = floatBitsToInt(intBitsToFloat(backupReg0i) + intBitsToFloat(R2i.x));
R127i.y = floatBitsToInt(intBitsToFloat(R0i.z) + intBitsToFloat(R2i.z));
PV1i.z = floatBitsToInt(intBitsToFloat(PV0i.y) * 0.25);
PV1i.w = floatBitsToInt(intBitsToFloat(R0i.y) + intBitsToFloat(R2i.y));
PS1i = floatBitsToInt(intBitsToFloat(PV0i.z) * 0.25);
// 2
backupReg0i = R127i.x;
R127i.x = floatBitsToInt((intBitsToFloat(PV1i.x) * 0.25 + intBitsToFloat(PS1i)));
PV0i.y = floatBitsToInt(intBitsToFloat(backupReg0i) * 0.25);
R127i.z = PV1i.x;
R127i.z = floatBitsToInt(intBitsToFloat(R127i.z) / 2.0);
R127i.w = floatBitsToInt((intBitsToFloat(PV1i.w) * 0.25 + intBitsToFloat(PV1i.z)));
PV0i.w = R127i.w;
R126i.y = PV1i.w;
R126i.y = floatBitsToInt(intBitsToFloat(R126i.y) / 2.0);
PS0i = R126i.y;
// 3
PV1i.x = ((intBitsToFloat(PV0i.w) > intBitsToFloat(R4i.y))?int(0xFFFFFFFF):int(0x0));
PV1i.y = ((intBitsToFloat(R4i.z) > intBitsToFloat(PV0i.w))?int(0xFFFFFFFF):int(0x0));
R126i.z = floatBitsToInt((intBitsToFloat(R127i.y) * 0.25 + intBitsToFloat(PV0i.y)));
R126i.w = R127i.y;
R126i.w = floatBitsToInt(intBitsToFloat(R126i.w) / 2.0);
// 4
R123i.w = ((PV1i.y == 0)?(PV1i.x):(int(-1)));
PV0i.w = R123i.w;
// 5
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(textureUnitPS1, 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 = mix(sharpColour, vec4(intBitsToFloat(R4i.x), intBitsToFloat(R4i.y), intBitsToFloat(R4i.z), intBitsToFloat(R4i.w)), 0.5);

}
