mirror of
https://github.com/cemu-project/cemu_graphic_packs.git
synced 2024-11-26 19:44:14 +01:00
306da0b802
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
293 lines
9.9 KiB
Plaintext
293 lines
9.9 KiB
Plaintext
#version 420
|
|
#extension GL_ARB_texture_gather : enable
|
|
#extension GL_ARB_separate_shader_objects : enable
|
|
#extension GL_ARB_shading_language_packing : 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 5ce4bcf08c2aa688
|
|
// Used for: Bloom
|
|
const float resXScale = ($width/$gameWidth);
|
|
const float resYScale = ($height/$gameHeight);
|
|
|
|
|
|
#ifdef VULKAN
|
|
layout(set = 0, binding = 0) uniform ufBlock
|
|
{
|
|
uniform ivec4 uf_remappedVS[6];
|
|
uniform vec2 uf_windowSpaceToClipSpaceTransform;
|
|
};
|
|
#else
|
|
uniform ivec4 uf_remappedVS[6];
|
|
uniform vec2 uf_windowSpaceToClipSpaceTransform;
|
|
#endif
|
|
ATTR_LAYOUT(0, 0) in uvec4 attrDataSem0;
|
|
ATTR_LAYOUT(0, 1) in uvec4 attrDataSem1;
|
|
out gl_PerVertex
|
|
{
|
|
vec4 gl_Position;
|
|
float gl_PointSize;
|
|
};
|
|
layout(location = 0) noperspective out vec4 passParameterSem1;
|
|
layout(location = 1) noperspective out vec4 passParameterSem2;
|
|
layout(location = 2) noperspective out vec4 passParameterSem3;
|
|
layout(location = 3) noperspective out vec4 passParameterSem4;
|
|
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 mix(0.0, a*b, (a != 0.0) && (b != 0.0));}
|
|
void main()
|
|
{
|
|
ivec4 R0i = ivec4(0);
|
|
ivec4 R1i = ivec4(0);
|
|
ivec4 R2i = ivec4(0);
|
|
ivec4 R3i = ivec4(0);
|
|
ivec4 R4i = ivec4(0);
|
|
ivec4 R5i = ivec4(0);
|
|
ivec4 R6i = ivec4(0);
|
|
ivec4 R7i = ivec4(0);
|
|
ivec4 R8i = ivec4(0);
|
|
ivec4 R9i = ivec4(0);
|
|
ivec4 R10i = ivec4(0);
|
|
ivec4 R11i = ivec4(0);
|
|
ivec4 R12i = ivec4(0);
|
|
ivec4 R13i = ivec4(0);
|
|
ivec4 R14i = ivec4(0);
|
|
ivec4 R15i = ivec4(0);
|
|
ivec4 R16i = ivec4(0);
|
|
ivec4 R17i = ivec4(0);
|
|
ivec4 R18i = ivec4(0);
|
|
ivec4 R19i = ivec4(0);
|
|
ivec4 R20i = ivec4(0);
|
|
ivec4 R21i = ivec4(0);
|
|
ivec4 R22i = ivec4(0);
|
|
ivec4 R23i = ivec4(0);
|
|
ivec4 R24i = ivec4(0);
|
|
ivec4 R25i = ivec4(0);
|
|
ivec4 R26i = ivec4(0);
|
|
ivec4 R27i = ivec4(0);
|
|
ivec4 R28i = ivec4(0);
|
|
ivec4 R29i = ivec4(0);
|
|
ivec4 R30i = ivec4(0);
|
|
ivec4 R31i = ivec4(0);
|
|
ivec4 R32i = ivec4(0);
|
|
ivec4 R33i = ivec4(0);
|
|
ivec4 R34i = ivec4(0);
|
|
ivec4 R35i = ivec4(0);
|
|
ivec4 R36i = ivec4(0);
|
|
ivec4 R37i = ivec4(0);
|
|
ivec4 R38i = ivec4(0);
|
|
ivec4 R39i = ivec4(0);
|
|
ivec4 R40i = ivec4(0);
|
|
ivec4 R41i = ivec4(0);
|
|
ivec4 R42i = ivec4(0);
|
|
ivec4 R43i = ivec4(0);
|
|
ivec4 R44i = ivec4(0);
|
|
ivec4 R45i = ivec4(0);
|
|
ivec4 R46i = ivec4(0);
|
|
ivec4 R47i = ivec4(0);
|
|
ivec4 R48i = ivec4(0);
|
|
ivec4 R49i = ivec4(0);
|
|
ivec4 R50i = ivec4(0);
|
|
ivec4 R51i = ivec4(0);
|
|
ivec4 R52i = ivec4(0);
|
|
ivec4 R53i = ivec4(0);
|
|
ivec4 R54i = ivec4(0);
|
|
ivec4 R55i = ivec4(0);
|
|
ivec4 R56i = ivec4(0);
|
|
ivec4 R57i = ivec4(0);
|
|
ivec4 R58i = ivec4(0);
|
|
ivec4 R59i = ivec4(0);
|
|
ivec4 R60i = ivec4(0);
|
|
ivec4 R61i = ivec4(0);
|
|
ivec4 R62i = ivec4(0);
|
|
ivec4 R63i = ivec4(0);
|
|
ivec4 R64i = ivec4(0);
|
|
ivec4 R65i = ivec4(0);
|
|
ivec4 R66i = ivec4(0);
|
|
ivec4 R67i = ivec4(0);
|
|
ivec4 R68i = ivec4(0);
|
|
ivec4 R69i = ivec4(0);
|
|
ivec4 R70i = ivec4(0);
|
|
ivec4 R71i = ivec4(0);
|
|
ivec4 R72i = ivec4(0);
|
|
ivec4 R73i = ivec4(0);
|
|
ivec4 R74i = ivec4(0);
|
|
ivec4 R75i = ivec4(0);
|
|
ivec4 R76i = ivec4(0);
|
|
ivec4 R77i = ivec4(0);
|
|
ivec4 R78i = ivec4(0);
|
|
ivec4 R79i = ivec4(0);
|
|
ivec4 R80i = ivec4(0);
|
|
ivec4 R81i = ivec4(0);
|
|
ivec4 R82i = ivec4(0);
|
|
ivec4 R83i = ivec4(0);
|
|
ivec4 R84i = ivec4(0);
|
|
ivec4 R85i = ivec4(0);
|
|
ivec4 R86i = ivec4(0);
|
|
ivec4 R87i = ivec4(0);
|
|
ivec4 R88i = ivec4(0);
|
|
ivec4 R89i = ivec4(0);
|
|
ivec4 R90i = ivec4(0);
|
|
ivec4 R91i = ivec4(0);
|
|
ivec4 R92i = ivec4(0);
|
|
ivec4 R93i = ivec4(0);
|
|
ivec4 R94i = ivec4(0);
|
|
ivec4 R95i = ivec4(0);
|
|
ivec4 R96i = ivec4(0);
|
|
ivec4 R97i = ivec4(0);
|
|
ivec4 R98i = ivec4(0);
|
|
ivec4 R99i = ivec4(0);
|
|
ivec4 R100i = ivec4(0);
|
|
ivec4 R101i = ivec4(0);
|
|
ivec4 R102i = ivec4(0);
|
|
ivec4 R103i = ivec4(0);
|
|
ivec4 R104i = ivec4(0);
|
|
ivec4 R105i = ivec4(0);
|
|
ivec4 R106i = ivec4(0);
|
|
ivec4 R107i = ivec4(0);
|
|
ivec4 R108i = ivec4(0);
|
|
ivec4 R109i = ivec4(0);
|
|
ivec4 R110i = ivec4(0);
|
|
ivec4 R111i = ivec4(0);
|
|
ivec4 R112i = ivec4(0);
|
|
ivec4 R113i = ivec4(0);
|
|
ivec4 R114i = ivec4(0);
|
|
ivec4 R115i = ivec4(0);
|
|
ivec4 R116i = ivec4(0);
|
|
ivec4 R117i = ivec4(0);
|
|
ivec4 R118i = ivec4(0);
|
|
ivec4 R119i = ivec4(0);
|
|
ivec4 R120i = ivec4(0);
|
|
ivec4 R121i = ivec4(0);
|
|
ivec4 R122i = ivec4(0);
|
|
ivec4 R123i = ivec4(0);
|
|
ivec4 R124i = ivec4(0);
|
|
ivec4 R125i = ivec4(0);
|
|
ivec4 R126i = ivec4(0);
|
|
ivec4 R127i = ivec4(0);
|
|
uvec4 attrDecoder;
|
|
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;
|
|
vec3 cubeMapSTM;
|
|
int cubeMapFaceId;
|
|
R0i = ivec4(gl_VertexID, 0, 0, gl_InstanceID);
|
|
attrDecoder.xyz = attrDataSem0.xyz;
|
|
attrDecoder.xyz = (attrDecoder.xyz>>24)|((attrDecoder.xyz>>8)&0xFF00)|((attrDecoder.xyz<<8)&0xFF0000)|((attrDecoder.xyz<<24));
|
|
attrDecoder.w = 0;
|
|
R1i = ivec4(int(attrDecoder.x), int(attrDecoder.y), int(attrDecoder.z), floatBitsToInt(1.0));
|
|
attrDecoder = attrDataSem1;
|
|
attrDecoder = (attrDecoder>>24)|((attrDecoder>>8)&0xFF00)|((attrDecoder<<8)&0xFF0000)|((attrDecoder<<24));
|
|
R2i = ivec4(int(attrDecoder.x), int(attrDecoder.y), int(attrDecoder.z), int(attrDecoder.w));
|
|
// 0
|
|
PV0i.y = floatBitsToInt(mul_nonIEEE(intBitsToFloat(R1i.y), intBitsToFloat(uf_remappedVS[0].y)));
|
|
PV0i.z = floatBitsToInt(mul_nonIEEE(intBitsToFloat(R1i.x), intBitsToFloat(uf_remappedVS[0].x)));
|
|
R5i.w = 0x3f800000;
|
|
R127i.x = floatBitsToInt(1.0 / intBitsToFloat(uf_remappedVS[1].y));
|
|
PS0i = R127i.x;
|
|
// 1
|
|
PV1i.x = floatBitsToInt(intBitsToFloat(PV0i.z) + intBitsToFloat(uf_remappedVS[2].x));
|
|
PV1i.w = floatBitsToInt(intBitsToFloat(PV0i.y) + intBitsToFloat(uf_remappedVS[2].y));
|
|
PS1i = floatBitsToInt(1.0 / intBitsToFloat(uf_remappedVS[1].x));
|
|
// 2
|
|
R1i.x = uf_remappedVS[3].x;
|
|
PV0i.y = floatBitsToInt(intBitsToFloat(PV1i.x) * intBitsToFloat(PS1i));
|
|
PV0i.y = floatBitsToInt(intBitsToFloat(PV0i.y) * 2.0);
|
|
R5i.z = uf_remappedVS[2].z;
|
|
PV0i.w = floatBitsToInt(intBitsToFloat(PV1i.w) * intBitsToFloat(R127i.x));
|
|
PV0i.w = floatBitsToInt(intBitsToFloat(PV0i.w) * 2.0);
|
|
R1i.y = uf_remappedVS[3].y;
|
|
PS0i = R1i.y;
|
|
// 3
|
|
R5i.x = floatBitsToInt(intBitsToFloat(PV0i.y) + -(1.0));
|
|
R0i.y = uf_remappedVS[3].w;
|
|
PV1i.z = floatBitsToInt(intBitsToFloat(PV0i.w) + -(1.0));
|
|
R0i.w = floatBitsToInt(intBitsToFloat(uf_remappedVS[4].w) * 1.0);
|
|
R0i.x = uf_remappedVS[3].z;
|
|
PS1i = R0i.x;
|
|
// 4
|
|
R2i.x = uf_remappedVS[5].x;
|
|
R5i.y = floatBitsToInt(-(intBitsToFloat(PV1i.z)));
|
|
R1i.z = floatBitsToInt(intBitsToFloat(uf_remappedVS[4].z) * 1.0);
|
|
R1i.w = floatBitsToInt(intBitsToFloat(uf_remappedVS[4].w) * -(1.0));
|
|
R2i.y = uf_remappedVS[5].y;
|
|
PS0i = R2i.y;
|
|
// 5
|
|
R3i.x = uf_remappedVS[5].z;
|
|
R3i.y = uf_remappedVS[5].w;
|
|
R0i.z = floatBitsToInt(intBitsToFloat(uf_remappedVS[4].z) * 1.0);
|
|
R3i.w = floatBitsToInt(intBitsToFloat(uf_remappedVS[4].z) * -(1.0));
|
|
PS1i = int(intBitsToFloat(R2i.w));
|
|
// 6
|
|
R4i.x = PS1i + 0x00000018;
|
|
R2i.z = R0i.w;
|
|
R2i.w = R1i.w;
|
|
// 7
|
|
R33i.x = R1i.x;
|
|
R33i.y = R1i.y;
|
|
// 8
|
|
R34i.x = R0i.x;
|
|
R34i.y = R0i.y;
|
|
// 9
|
|
R35i.x = R2i.x;
|
|
R35i.y = R2i.y;
|
|
// 10
|
|
R36i.x = R3i.x;
|
|
R36i.y = R3i.y;
|
|
// 11
|
|
tempResulti = R4i.x;
|
|
tempResulti = clamp(tempResulti, -256, 255);
|
|
ARi.x = tempResulti;
|
|
PV1i.x = tempResulti;
|
|
// 12
|
|
R4i.x = ((ARi.x==0)?R9i.x:(ARi.x==24)?R33i.x:(ARi.x==25)?R34i.x:(ARi.x==26)?R35i.x:(ARi.x==27)?R36i.x:(ARi.x==118)?R127i.x:0);
|
|
R4i.y = ((ARi.x==0)?R9i.y:(ARi.x==24)?R33i.y:(ARi.x==25)?R34i.y:(ARi.x==26)?R35i.y:(ARi.x==27)?R36i.y:(ARi.x==118)?R127i.y:0);
|
|
// export
|
|
SET_POSITION(vec4(intBitsToFloat(R5i.x), intBitsToFloat(R5i.y), intBitsToFloat(R5i.z), intBitsToFloat(R5i.w)));
|
|
// 0
|
|
R5i.x = floatBitsToInt((mul_nonIEEE(intBitsToFloat(R0i.z)/resXScale,intBitsToFloat(uf_remappedVS[4].x)) + intBitsToFloat(R4i.x)));
|
|
R5i.y = floatBitsToInt((mul_nonIEEE(intBitsToFloat(R0i.w)/resYScale,intBitsToFloat(uf_remappedVS[4].y)) + intBitsToFloat(R4i.y)));
|
|
R0i.z = floatBitsToInt((mul_nonIEEE(intBitsToFloat(R1i.z)/resXScale,intBitsToFloat(uf_remappedVS[4].x)) + intBitsToFloat(R4i.x)));
|
|
R0i.w = floatBitsToInt((mul_nonIEEE(intBitsToFloat(R1i.w)/resYScale,intBitsToFloat(uf_remappedVS[4].y)) + intBitsToFloat(R4i.y)));
|
|
R3i.x = floatBitsToInt((mul_nonIEEE(intBitsToFloat(R3i.w)/resYScale,intBitsToFloat(uf_remappedVS[4].x)) + intBitsToFloat(R4i.x)));
|
|
PS0i = R3i.x;
|
|
// 1
|
|
backupReg0i = R2i.z;
|
|
R2i.x = floatBitsToInt((mul_nonIEEE(intBitsToFloat(R3i.w)/resYScale,intBitsToFloat(uf_remappedVS[4].x)) + intBitsToFloat(R4i.x)));
|
|
R3i.y = floatBitsToInt((mul_nonIEEE(intBitsToFloat(R2i.w)/resYScale,intBitsToFloat(uf_remappedVS[4].y)) + intBitsToFloat(R4i.y)));
|
|
R2i.z = floatBitsToInt((mul_nonIEEE(intBitsToFloat(backupReg0i)/resYScale,intBitsToFloat(uf_remappedVS[4].y)) + intBitsToFloat(R4i.y)));
|
|
// export
|
|
passParameterSem1 = vec4(intBitsToFloat(R5i.x), intBitsToFloat(R5i.y), intBitsToFloat(R5i.z), intBitsToFloat(R5i.z));
|
|
// export
|
|
passParameterSem2 = vec4(intBitsToFloat(R0i.z), intBitsToFloat(R0i.w), intBitsToFloat(R0i.z), intBitsToFloat(R0i.z));
|
|
// export
|
|
passParameterSem3 = vec4(intBitsToFloat(R3i.x), intBitsToFloat(R3i.y), intBitsToFloat(R3i.z), intBitsToFloat(R3i.z));
|
|
// export
|
|
passParameterSem4 = vec4(intBitsToFloat(R2i.x), intBitsToFloat(R2i.z), intBitsToFloat(R2i.z), intBitsToFloat(R2i.z));
|
|
}
|