cemu_graphic_packs/Workarounds/XenobladeX_Brightness/3cc7e98f78c258b4_00000000000003ca_ps.txt

112 lines
4.0 KiB
Plaintext
Raw Normal View History

#version 430
2017-05-28 08:24:01 +02:00
#extension GL_ARB_texture_gather : enable
#extension GL_ARB_separate_shader_objects : enable
// shader 3cc7e98f78c258b4 //Brightness fix
// start of shader inputs/outputs, predetermined by Cemu. Do not touch
#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 GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale.xy,gl_FragCoord.zw)
#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 GET_FRAGCOORD() vec4(gl_FragCoord.xy*uf_fragCoordScale,gl_FragCoord.zw)
#endif
#ifdef VULKAN
layout(set = 1, binding = 2) uniform ufBlock
{
uniform ivec4 uf_remappedPS[1];
uniform vec4 uf_fragCoordScale;
};
#else
2017-05-28 08:24:01 +02:00
uniform ivec4 uf_remappedPS[1];
uniform vec2 uf_fragCoordScale;
#endif
TEXTURE_LAYOUT(0, 1, 0) uniform sampler2D textureUnitPS0;
TEXTURE_LAYOUT(1, 1, 1) uniform sampler3D textureUnitPS1;
2017-05-28 08:24:01 +02:00
layout(location = 0) in vec4 passParameterSem0;
layout(location = 0) out vec4 passPixelColor0;
// end of shader inputs/outputs
const float exposure = $exposure;
const float vibrance = $vibrance;
const float postExposure = $postExposure;
const float contrastCurve = $contrastCurve;
2017-05-28 08:24:01 +02:00
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()
{
vec4 R0f = vec4(0.0);
vec4 R1f = vec4(0.0);
vec4 R5f = vec4(0.0);
2017-05-28 08:24:01 +02:00
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;
float tempResultf2;
2017-05-28 08:24:01 +02:00
int tempResulti;
ivec4 ARi = ivec4(0);
bool predResult = true;
vec3 cubeMapSTM;
int cubeMapFaceId;
R0f = passParameterSem0;
R0f.xyz = (texture(textureUnitPS0, R0f.xy).xyz);
R5f.xyzw = texture(textureUnitPS0, passParameterSem0.xy);
2017-05-28 08:24:01 +02:00
// 0
tempResultf = clamp(intBitsToFloat(uf_remappedPS[0].x), 0.0, exposure);
tempResultf2 = clamp(intBitsToFloat(uf_remappedPS[0].z), 0.0, 1.0);
R127f.x = R0f.z * tempResultf;//intBitsToFloat(uf_remappedPS[0].x);
R127f.x = clamp(R127f.x, 0.0, 1.0);
R127f.y = R0f.y * tempResultf;
R127f.y = clamp(R127f.y, 0.0, 1.0);
PV0f.z = R0f.x * tempResultf;
PV0f.z = clamp(PV0f.z, 0.0, 1.0);
2017-05-28 08:24:01 +02:00
R1f.w = 1.0;
// 1
tempResultf = max(0.0, PV0f.z);
tempResultf = log2(tempResultf);
if( isinf(tempResultf) == true ) tempResultf = -3.40282347E+38F;
2017-05-28 08:24:01 +02:00
PS1f = tempResultf;
// 2
R127f.z = PS1f * intBitsToFloat(0x3ee8ba2e);
tempResultf = max(0.0, R127f.y);
tempResultf = log2(tempResultf);
2017-05-28 08:24:01 +02:00
if( isinf(tempResultf) == true ) tempResultf = -3.40282347E+38F;
PS0f = tempResultf;
// 3
R127f.w = PS0f * intBitsToFloat(0x3ee8ba2e);
tempResultf = max(0.0, R127f.x);
tempResultf = log2(tempResultf);
2017-05-28 08:24:01 +02:00
if( isinf(tempResultf) == true ) tempResultf = -3.40282347E+38F;
PS1f = tempResultf;
// 4
R127f.x = PS1f * intBitsToFloat(0x3ee8ba2e);
2017-05-28 08:24:01 +02:00
PS0f = exp2(R127f.z);
// 5
R0f.x = (PS0f * tempResultf2 + intBitsToFloat(uf_remappedPS[0].w));
2017-05-28 08:24:01 +02:00
PS1f = exp2(R127f.w);
// 6
R0f.y = (PS1f * intBitsToFloat(uf_remappedPS[0].z) + intBitsToFloat(uf_remappedPS[0].w));
PS0f = exp2(R127f.x);
// 7
R0f.z = (PS0f * intBitsToFloat(uf_remappedPS[0].z) + intBitsToFloat(uf_remappedPS[0].w));
R0f.xyz = clamp(R0f.xyz, 0.0, 1.0);
2017-05-28 08:24:01 +02:00
R1f.xyz = (texture(textureUnitPS1, vec3(R0f.x,R0f.y,R0f.z)).xyz);
// export
R5f = mix (R1f,R5f,vibrance)*postExposure;
R5f.xyz = mix(R5f.xyz, smoothstep(0.0, 1.0, R5f.xyz), contrastCurve);
passPixelColor0 = vec4(R5f.x, R5f.y, R5f.z, R5f.w);
2017-05-28 08:24:01 +02:00
}