mirror of
https://github.com/cemu-project/cemu_graphic_packs.git
synced 2024-11-22 17:49:17 +01:00
a144f58ca4
Fixes issues with too dark nights and too bright days by clamping relative value instead of static approximation of exposure decrease.
112 lines
4.0 KiB
Plaintext
112 lines
4.0 KiB
Plaintext
#version 430
|
|
#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
|
|
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;
|
|
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;
|
|
|
|
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);
|
|
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;
|
|
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);
|
|
// 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);
|
|
R1f.w = 1.0;
|
|
// 1
|
|
tempResultf = max(0.0, PV0f.z);
|
|
tempResultf = log2(tempResultf);
|
|
if( isinf(tempResultf) == true ) tempResultf = -3.40282347E+38F;
|
|
PS1f = tempResultf;
|
|
// 2
|
|
R127f.z = PS1f * intBitsToFloat(0x3ee8ba2e);
|
|
tempResultf = max(0.0, R127f.y);
|
|
tempResultf = log2(tempResultf);
|
|
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);
|
|
if( isinf(tempResultf) == true ) tempResultf = -3.40282347E+38F;
|
|
PS1f = tempResultf;
|
|
// 4
|
|
R127f.x = PS1f * intBitsToFloat(0x3ee8ba2e);
|
|
PS0f = exp2(R127f.z);
|
|
// 5
|
|
R0f.x = (PS0f * tempResultf2 + intBitsToFloat(uf_remappedPS[0].w));
|
|
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);
|
|
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);
|
|
|
|
}
|