cemu_graphic_packs/Enhancements/WindWakerHD_Contrasty/c2cae30e906be2d5_0000000000001e49_ps.txt
Crementif 306da0b802
Update every graphic pack to V4
Since it's not possible to update 300+ shaders manually and automation was possible, I thought that I'd take the honor and create a script that's able to automatically convert all of the shaders to be cross-compatible with Vulkan. And change the graphic pack versions to version 4 of course.

Also, the script has some nifty testing code which compiled every shader as OpenGL and Vulkan, but for that see the details that I've written below.

**Here's the script that I've made to do all of this. No manual edits were needed:**
https://gist.github.com/Crementif/8d98a855b95f219d95298fb3db99deae
2019-11-29 04:36:05 +01:00

322 lines
11 KiB
Plaintext

#version 420
#extension GL_ARB_texture_gather : enable
#extension GL_ARB_separate_shader_objects : enable
#ifdef VULKAN
#define ATTR_LAYOUT(__vkSet, __location) layout(set = __vkSet, location = __location)
#define UNIFORM_BUFFER_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(set = __vkSet, binding = __vkLocation, std140)
#define TEXTURE_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(set = __vkSet, binding = __vkLocation)
#define SET_POSITION(_v) gl_Position = _v; gl_Position.z = (gl_Position.z + gl_Position.w) / 2.0
#define GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale.xy,gl_FragCoord.zw)
#define gl_VertexID gl_VertexIndex
#define gl_InstanceID gl_InstanceIndex
#else
#define ATTR_LAYOUT(__vkSet, __location) layout(location = __location)
#define UNIFORM_BUFFER_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(binding = __glLocation, std140)
#define TEXTURE_LAYOUT(__glLocation, __vkSet, __vkLocation) layout(binding = __glLocation)
#define SET_POSITION(_v) gl_Position = _v
#define GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale,gl_FragCoord.zw)
#endif
// This shaders was auto-converted from OpenGL to Cemu so expect weird code and possible errors.
// shader c2cae30e906be2d5
//Ao scale
#ifdef VULKAN
layout(set = 1, binding = 3) uniform ufBlock
{
uniform ivec4 uf_remappedPS[8];
uniform vec4 uf_fragCoordScale;
};
#else
uniform ivec4 uf_remappedPS[8];
uniform vec2 uf_fragCoordScale;
#endif
TEXTURE_LAYOUT(0, 1, 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf4200000 res 960x540x1 dim 1 tm: 4 format 0806 compSel: 0 4 4 5 mipView: 0x0 (num 0x1
TEXTURE_LAYOUT(1, 1, 1) uniform sampler2D textureUnitPS1;// Tex1 addr 0xf4200000 res 960x540x1 dim 1 tm: 4 format 0806 compSel: 0 4 4 5 mipView: 0x0 (num 0x2
TEXTURE_LAYOUT(2, 1, 2) uniform sampler2D textureUnitPS2;// Tex2 addr 0x3b5d5800 res 4x4x1 dim 1 tm: 2 format 0007 compSel: 0 1 4 5 mipView: 0x0 (num 0x1
layout(location = 0) in vec4 passParameterSem1;
layout(location = 0) out vec4 passPixelColor0;
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){ if( a == 0.0 || b == 0.0 ) return 0.0; return a*b; }
void main()
{
vec4 R0f = vec4(0.0);
vec4 R1f = vec4(0.0);
vec4 R2f = vec4(0.0);
vec4 R3f = vec4(0.0);
vec4 R4f = vec4(0.0);
vec4 R5f = vec4(0.0);
vec4 R6f = vec4(0.0);
vec4 R122f = vec4(0.0);
vec4 R123f = vec4(0.0);
vec4 R124f = vec4(0.0);
vec4 R125f = vec4(0.0);
vec4 R126f = vec4(0.0);
vec4 R127f = vec4(0.0);
float backupReg0f, backupReg1f, backupReg2f, backupReg3f, backupReg4f;
vec4 PV0f = vec4(0.0), PV1f = vec4(0.0);
float PS0f = 0.0, PS1f = 0.0;
vec4 tempf = vec4(0.0);
float tempResultf;
int tempResulti;
ivec4 ARi = ivec4(0);
bool predResult = true;
vec3 cubeMapSTM;
int cubeMapFaceId;
R0f = passParameterSem1;
R2f.x = (texture(textureUnitPS0, R0f.xy).x);
R1f.xy = (texture(textureUnitPS2, R0f.zw).xy)*$AO;
// 0
R4f.x = (R1f.y * 2.0 + -(1.0));
PV0f.x = R4f.x;
R4f.y = mul_nonIEEE(R2f.x, intBitsToFloat(uf_remappedPS[0].z));
R5f.z = (R1f.x * 2.0 + -(1.0));
PV0f.z = R5f.z;
R123f.w = (mul_nonIEEE(-(R2f.x),intBitsToFloat(uf_remappedPS[1].y)) + 1.0);
R123f.w = clamp(R123f.w, 0.0, 1.0);
PV0f.w = R123f.w;
// 1
R5f.x = mul_nonIEEE(-(PV0f.x), intBitsToFloat(uf_remappedPS[2].z));
R3f.y = mul_nonIEEE(PV0f.z, intBitsToFloat(uf_remappedPS[2].z));
R4f.z = mul_nonIEEE(PV0f.w, intBitsToFloat(uf_remappedPS[1].x));
PV1f.z = R4f.z;
// 2
R127f.x = mul_nonIEEE(PV1f.z, intBitsToFloat(uf_remappedPS[3].x));
PV0f.x = R127f.x;
R127f.y = mul_nonIEEE(PV1f.z, intBitsToFloat(uf_remappedPS[3].y));
PV0f.z = mul_nonIEEE(PV1f.z, intBitsToFloat(uf_remappedPS[4].x));
R127f.w = mul_nonIEEE(PV1f.z, intBitsToFloat(uf_remappedPS[4].y));
PS0f = 1.0 / PV1f.z;
// 3
R6f.x = mul_nonIEEE(intBitsToFloat(uf_remappedPS[5].z), PS0f);
PV1f.y = mul_nonIEEE(R3f.y, PV0f.z);
PV1f.z = mul_nonIEEE(R4f.x, PV0f.z);
R4f.w = mul_nonIEEE(intBitsToFloat(uf_remappedPS[5].z), PS0f);
PS1f = mul_nonIEEE(R3f.y, PV0f.x);
// 4
PV0f.x = mul_nonIEEE(R4f.x, R127f.x);
R126f.y = (mul_nonIEEE(R5f.x,R127f.y) + PS1f);
R123f.z = (mul_nonIEEE(R5f.z,R127f.w) + PV1f.z);
PV0f.z = R123f.z;
R123f.w = (mul_nonIEEE(R5f.x,R127f.w) + PV1f.y);
PV0f.w = R123f.w;
R3f.x = mul_nonIEEE(R4f.z, intBitsToFloat(uf_remappedPS[6].x));
PS0f = R3f.x;
// 5
R1f.xyz = vec3(R0f.x,R0f.y,R0f.x) + vec3(PV0f.w,PV0f.z,-(PV0f.w));
R1f.w = R0f.y + -(PV0f.z);
R122f.x = (mul_nonIEEE(R5f.z,R127f.y) + PV0f.x);
PS1f = R122f.x;
// 6
R2f.xyz = vec3(R0f.x,R0f.y,R0f.x) + vec3(R126f.y,PS1f,-(R126f.y));
R2f.w = R0f.y + -(PS1f);
R3f.z = mul_nonIEEE(R4f.z, intBitsToFloat(uf_remappedPS[6].y));
PS0f = R3f.z;
R1f.x = (texture(textureUnitPS1, R1f.xy).x);
R1f.y = (texture(textureUnitPS1, R1f.zw).x);
R2f.x = (texture(textureUnitPS1, R2f.xy).x);
R2f.y = (texture(textureUnitPS1, R2f.zw).x);
// 0
R127f.x = R4f.y + -(R2f.x);
PV0f.x = R127f.x;
R126f.y = R4f.y + -(R2f.y);
PV0f.z = -(R1f.y) + R4f.y;
PV0f.w = -(R1f.x) + R4f.y;
// 1
PV1f.x = mul_nonIEEE(PV0f.z, R4f.w);
PV1f.x /= 2.0;
PV1f.y = mul_nonIEEE(PV0f.w, R6f.x);
PV1f.y /= 2.0;
R126f.z = (mul_nonIEEE(-(PV0f.w),intBitsToFloat(uf_remappedPS[1].z)) + 1.0);
R126f.z = clamp(R126f.z, 0.0, 1.0);
R125f.w = (mul_nonIEEE(-(PV0f.z),intBitsToFloat(uf_remappedPS[1].z)) + 1.0);
R125f.w = clamp(R125f.w, 0.0, 1.0);
PS1f = mul_nonIEEE(PV0f.x, R6f.x);
PS1f /= 2.0;
// 2
R126f.x = (mul_nonIEEE(PS1f,intBitsToFloat(uf_remappedPS[3].z)) + 0.5);
R126f.x = clamp(R126f.x, 0.0, 1.0);
PV0f.y = mul_nonIEEE(R126f.y, R4f.w);
PV0f.y /= 2.0;
R127f.z = (mul_nonIEEE(PV1f.x,intBitsToFloat(uf_remappedPS[4].z)) + 0.5);
R127f.z = clamp(R127f.z, 0.0, 1.0);
PV0f.z = R127f.z;
R127f.w = (mul_nonIEEE(PV1f.y,intBitsToFloat(uf_remappedPS[4].z)) + 0.5);
R127f.w = clamp(R127f.w, 0.0, 1.0);
PV0f.w = R127f.w;
R126f.w = mul_nonIEEE(R3f.y, R3f.x);
PS0f = R126f.w;
// 3
R125f.x = (mul_nonIEEE(PV0f.y,intBitsToFloat(uf_remappedPS[3].z)) + 0.5);
R125f.x = clamp(R125f.x, 0.0, 1.0);
PV1f.x = R125f.x;
R127f.y = (mul_nonIEEE(-(R127f.x),intBitsToFloat(uf_remappedPS[1].z)) + 1.0);
R127f.y = clamp(R127f.y, 0.0, 1.0);
PV1f.z = 0.5 + -(PV0f.w);
PV1f.w = 0.5 + -(PV0f.z);
R125f.y = (mul_nonIEEE(-(R126f.y),intBitsToFloat(uf_remappedPS[1].z)) + 1.0);
R125f.y = clamp(R125f.y, 0.0, 1.0);
PS1f = R125f.y;
// 4
R127f.x = (mul_nonIEEE(PV1f.z,R126f.z) + 0.5);
PV0f.x = R127f.x;
R126f.y = (mul_nonIEEE(PV1f.w,R125f.w) + 0.5);
PV0f.y = R126f.y;
PV0f.z = 0.5 + -(PV1f.x);
PV0f.w = 0.5 + -(R126f.x);
R125f.z = mul_nonIEEE(R4f.x, R3f.x);
PS0f = R125f.z;
// 5
R124f.x = (mul_nonIEEE(PV0f.z,R125f.y) + 0.5);
PV1f.x = R124f.x;
R124f.y = (mul_nonIEEE(PV0f.w,R127f.y) + 0.5);
PV1f.y = R124f.y;
PV1f.z = R127f.z + -(PV0f.x);
PV1f.w = R127f.w + -(PV0f.y);
R127f.w = (mul_nonIEEE(R5f.x,R3f.z) + R126f.w);
PS1f = R127f.w;
// 6
backupReg0f = R127f.x;
backupReg1f = R126f.y;
R127f.x = (mul_nonIEEE(PV1f.z,R125f.w) + backupReg0f);
R126f.y = (mul_nonIEEE(PV1f.w,R126f.z) + backupReg1f);
PV0f.z = R126f.x + -(PV1f.x);
PV0f.w = R125f.x + -(PV1f.y);
// 7
R1f.x = R0f.x + R127f.w;
R123f.y = (mul_nonIEEE(PV0f.w,R125f.y) + R124f.y);
PV1f.y = R123f.y;
R123f.z = (mul_nonIEEE(R5f.z,R3f.z) + R125f.z);
PV1f.z = R123f.z;
R123f.w = (mul_nonIEEE(PV0f.z,R127f.y) + R124f.x);
PV1f.w = R123f.w;
R3f.x = R0f.x + -(R127f.w);
PS1f = R3f.x;
// 8
PV0f.x = mul_nonIEEE(PV1f.w, intBitsToFloat(uf_remappedPS[3].w));
R1f.y = R0f.y + PV1f.z;
PV0f.z = mul_nonIEEE(PV1f.y, intBitsToFloat(uf_remappedPS[3].w));
R3f.w = R0f.y + -(PV1f.z);
PS0f = mul_nonIEEE(R4f.z, intBitsToFloat(uf_remappedPS[7].x));
// 9
PV1f.x = mul_nonIEEE(R3f.y, PS0f);
R3f.y = (mul_nonIEEE(R127f.x,intBitsToFloat(uf_remappedPS[4].w)) + PV0f.z);
PV1f.z = mul_nonIEEE(R4f.z, intBitsToFloat(uf_remappedPS[7].y));
R2f.w = (mul_nonIEEE(R126f.y,intBitsToFloat(uf_remappedPS[4].w)) + PV0f.x);
PS1f = mul_nonIEEE(R4f.x, PS0f);
// 10
R5f.y = 0.0;
R123f.z = (mul_nonIEEE(R5f.x,PV1f.z) + PV1f.x);
PV0f.z = R123f.z;
R123f.w = (mul_nonIEEE(R5f.z,PV1f.z) + PS1f);
PV0f.w = R123f.w;
R5f.w = 1.0;
PS0f = R5f.w;
// 11
backupReg0f = R0f.x;
backupReg1f = R0f.y;
backupReg0f = R0f.x;
backupReg1f = R0f.y;
R0f.xyz = vec3(backupReg0f,backupReg1f,backupReg0f) + vec3(PV0f.z,PV0f.w,-(PV0f.z));
R0f.w = backupReg1f + -(PV0f.w);
R1f.x = (texture(textureUnitPS1, R1f.xy).x);
R1f.y = (texture(textureUnitPS1, R3f.xw).x);
R0f.x = (texture(textureUnitPS1, R0f.xy).x);
R0f.y = (texture(textureUnitPS1, R0f.zw).x);
// 0
backupReg0f = R0f.x;
backupReg1f = R0f.y;
PV0f.x = R4f.y + -(R1f.y);
PV0f.y = R4f.y + -(R1f.x);
R125f.z = R4f.y + -(backupReg0f);
PV0f.z = R125f.z;
R127f.w = R4f.y + -(backupReg1f);
// 1
R124f.x = (mul_nonIEEE(-(PV0f.y),intBitsToFloat(uf_remappedPS[1].z)) + 1.0);
R124f.x = clamp(R124f.x, 0.0, 1.0);
R127f.y = (mul_nonIEEE(-(PV0f.x),intBitsToFloat(uf_remappedPS[1].z)) + 1.0);
R127f.y = clamp(R127f.y, 0.0, 1.0);
PV1f.z = mul_nonIEEE(PV0f.x, R4f.w);
PV1f.z /= 2.0;
PV1f.w = mul_nonIEEE(PV0f.y, R6f.x);
PV1f.w /= 2.0;
PS1f = mul_nonIEEE(PV0f.z, R6f.x);
PS1f /= 2.0;
// 2
R127f.x = (mul_nonIEEE(PV1f.z,intBitsToFloat(uf_remappedPS[6].z)) + 0.5);
R127f.x = clamp(R127f.x, 0.0, 1.0);
PV0f.x = R127f.x;
R126f.y = (mul_nonIEEE(PV1f.w,intBitsToFloat(uf_remappedPS[6].z)) + 0.5);
R126f.y = clamp(R126f.y, 0.0, 1.0);
PV0f.y = R126f.y;
PV0f.z = mul_nonIEEE(R127f.w, R4f.w);
PV0f.z /= 2.0;
R125f.w = (mul_nonIEEE(PS1f,intBitsToFloat(uf_remappedPS[7].z)) + 0.5);
R125f.w = clamp(R125f.w, 0.0, 1.0);
// 3
PV1f.x = 0.5 + -(PV0f.y);
PV1f.y = 0.5 + -(PV0f.x);
R126f.z = (mul_nonIEEE(PV0f.z,intBitsToFloat(uf_remappedPS[7].z)) + 0.5);
R126f.z = clamp(R126f.z, 0.0, 1.0);
PV1f.z = R126f.z;
R126f.w = (mul_nonIEEE(-(R125f.z),intBitsToFloat(uf_remappedPS[1].z)) + 1.0);
R126f.w = clamp(R126f.w, 0.0, 1.0);
R125f.y = (mul_nonIEEE(-(R127f.w),intBitsToFloat(uf_remappedPS[1].z)) + 1.0);
R125f.y = clamp(R125f.y, 0.0, 1.0);
PS1f = R125f.y;
// 4
PV0f.x = 0.5 + -(PV1f.z);
PV0f.y = 0.5 + -(R125f.w);
R125f.z = (mul_nonIEEE(PV1f.x,R124f.x) + 0.5);
PV0f.z = R125f.z;
R127f.w = (mul_nonIEEE(PV1f.y,R127f.y) + 0.5);
PV0f.w = R127f.w;
// 5
PV1f.x = R127f.x + -(PV0f.z);
PV1f.y = R126f.y + -(PV0f.w);
R127f.z = (mul_nonIEEE(PV0f.y,R126f.w) + 0.5);
PV1f.z = R127f.z;
R124f.w = (mul_nonIEEE(PV0f.x,R125f.y) + 0.5);
PV1f.w = R124f.w;
// 6
PV0f.x = R125f.w + -(PV1f.w);
PV0f.y = R126f.z + -(PV1f.z);
R123f.z = (mul_nonIEEE(PV1f.x,R127f.y) + R125f.z);
PV0f.z = R123f.z;
R123f.w = (mul_nonIEEE(PV1f.y,R124f.x) + R127f.w);
PV0f.w = R123f.w;
// 7
R123f.x = (mul_nonIEEE(PV0f.w,intBitsToFloat(uf_remappedPS[6].w)) + R2f.w);
PV1f.x = R123f.x;
R123f.y = (mul_nonIEEE(PV0f.y,R125f.y) + R127f.z);
PV1f.y = R123f.y;
R123f.z = (mul_nonIEEE(PV0f.z,intBitsToFloat(uf_remappedPS[6].w)) + R3f.y);
PV1f.z = R123f.z;
R123f.w = (mul_nonIEEE(PV0f.x,R126f.w) + R124f.w);
PV1f.w = R123f.w;
// 8
R123f.x = (mul_nonIEEE(PV1f.w,intBitsToFloat(uf_remappedPS[7].w)) + PV1f.x);
PV0f.x = R123f.x;
R123f.z = (mul_nonIEEE(PV1f.y,intBitsToFloat(uf_remappedPS[7].w)) + PV1f.z);
PV0f.z = R123f.z;
// 9
PV1f.w = PV0f.x + PV0f.z;
// 10
PV0f.y = PV1f.w + intBitsToFloat(uf_remappedPS[1].w);
// 11
PV1f.x = PV0f.y + -(0.5);
// 12
PV0f.z = mul_nonIEEE(PV1f.x, intBitsToFloat(uf_remappedPS[0].y));
PV0f.z = clamp(PV0f.z, 0.0, 1.0);
// 13
R5f.x = -(PV0f.z) + 1.0;
// export
passPixelColor0 = vec4(R5f.x, R5f.y, R5f.y, R5f.w);
}