ClarityGfx

Fixed Gamma, Brightness and Contrast to work as intended.  Exposure should only affect tone map now nothing else.
This commit is contained in:
Jamie 2017-10-24 17:01:33 -07:00
parent 0eb4cbda21
commit 07d27d0167

View File

@ -1,5 +1,6 @@
#version 420 #version 420
#extension GL_ARB_texture_gather : enable #extension GL_ARB_texture_gather : enable
// shader bd8bba59e2149449 // shader bd8bba59e2149449
// Possible problems // Possible problems
@ -22,25 +23,35 @@
//########################################################## //##########################################################
//----------------------------------------------------------- //Don't touch.
const float floor = 0.0 / 255;
const float scale = 255.0/(255.0-0.0);
//Don't touch.
// Adjustable values: //##########################################################
precision lowp float;
const float fogfactor = 0.4; // [1.0 Default] Changes amount of fog // Contrast, saturation, brightness
const float brightness = 1.2; // [1.0 Default] Lighten or Darken Shadows // For all settings: 1.0 = 100% 0.5=50% 1.5 = 150%
const float Gamma = 1.5; // [1.0 Default] [2.0 Clarity]
const float contrast = 1.5; //Adjustable Values:
const float Saturation = 0.10; // [-1.0, 1.0] Saturates Colors
const float Exposure = 0.00; // [-1.0, 1.0] Exposure Adjustment const float brt = .80; // [0.1 ~ 2.0] [1.0 Default] Brightness Adjustment
const float Defog = 0.12; // [0.0, 1.0] How much of the far distance fog to "remove." const float con = 0.0; // [0.1 ~ 2.0] [0.5 Default] Contrast Adjustment
const float sat = 0.0; // [0.1 ~ 1.0] Color Saturation Adjustment.
const float gamma = 1.50; // [1.0 ~ 2.0] [1.0 Default] [1.43 Serfrost] [1.50 Jamie]
const float vibrance = 0.008; // 0.0 is neutral
const float defog = 0.12; // [0.0 ~ 1.0] How much of the far distance fog to "remove."
//-----------------------------------------------------------
//End of adjustable values //End of adjustable values
//###########################################################
const float floor = 0.0 / 255; //Do not edit under this line.
const float scale = 255.0/(255.0-0.0); const float exposure = 0.00;
const float Bleach = 0.0; const float Bleach = 0.0;
const vec3 FogColor = vec3(0.0, 0.0, 0.0); //Defog Color"; const vec3 FogColor = vec3(0.0, 0.0, 0.0); //defog Color";
uniform ivec4 uf_remappedPS[1]; uniform ivec4 uf_remappedPS[1];
layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf46ac800 res 320x180x1 dim 1 tm: 4 format 0816 compSel: 0 1 2 5 mipView: 0x0 (num 0x5) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 1 layout(binding = 0) uniform sampler2D textureUnitPS0;// Tex0 addr 0xf46ac800 res 320x180x1 dim 1 tm: 4 format 0816 compSel: 0 1 2 5 mipView: 0x0 (num 0x5) sliceView: 0x0 (num 0x1) Sampler0 ClampX/Y/Z: 2 2 2 border: 1
@ -58,15 +69,15 @@ 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; } float mul_nonIEEE(float a, float b){ if( a == 0.0 || b == 0.0 ) return 0.0; return a*b; }
/* //-----------------------------------------------------------
* Tonemap version 1.1 // Based on CeeJay.dk's original GLSL/HLSL.
* //-----------------------------------------------------------
*/
vec3 TonemapPass(vec3 inputColor) { vec3 TonemapPass(vec3 inputColor) {
vec3 color = inputColor; vec3 color = inputColor;
color = clamp(color - Defog * FogColor * 2.55, 0.0, 1.0); // Defog color = clamp(color - defog * FogColor * 2.55, 0.0, 1.0); // defog
color *= pow(2.0f, Exposure); // Exposure color *= pow(2.0f, exposure); // exposure
color = pow(color, vec3(Gamma)); // Gamma color = pow(color, vec3(gamma)); // Gamma
const vec3 coefLuma = vec3(0.2126, 0.7152, 0.0722); const vec3 coefLuma = vec3(0.2126, 0.7152, 0.0722);
float lum = dot(coefLuma, color); float lum = dot(coefLuma, color);
@ -83,7 +94,7 @@ vec3 TonemapPass(vec3 inputColor) {
vec3 middlegray = vec3(dot(color, vec3(1.0 / 3.0))); vec3 middlegray = vec3(dot(color, vec3(1.0 / 3.0)));
vec3 diffcolor = color - middlegray; vec3 diffcolor = color - middlegray;
color = (color + diffcolor * Saturation) / (1 + (diffcolor * Saturation)); // Saturation color = (color + diffcolor * sat) / (1 + (diffcolor * sat)); // saturation
return color; return color;
} }
@ -108,7 +119,6 @@ vec3 cubeMapSTM;
int cubeMapFaceId; int cubeMapFaceId;
R0f = passParameterSem0; R0f = passParameterSem0;
R1f.xyz = (texture(textureUnitPS0, R0f.xy).xyz); R1f.xyz = (texture(textureUnitPS0, R0f.xy).xyz);
R1f *= fogfactor;
R0f.xyz = (texture(textureUnitPS1, R0f.xy).xyz); R0f.xyz = (texture(textureUnitPS1, R0f.xy).xyz);
// 0 // 0
R126f.x = R1f.x + R0f.x; R126f.x = R1f.x + R0f.x;
@ -201,24 +211,20 @@ PV1f.w = R123f.w;
R0f.x = (mul_nonIEEE(R126f.x,R125f.w) + PV1f.w); R0f.x = (mul_nonIEEE(R126f.x,R125f.w) + PV1f.w);
R0f.y = (mul_nonIEEE(R126f.x,R127f.z) + PV1f.w); R0f.y = (mul_nonIEEE(R126f.x,R127f.z) + PV1f.w);
R0f.z = (mul_nonIEEE(R126f.x,R126f.y) + PV1f.w); R0f.z = (mul_nonIEEE(R126f.x,R126f.y) + PV1f.w);
// export
passPixelColor0 = vec4(R0f.x, R0f.y, R0f.z, R0f.w); passPixelColor0 = vec4(R0f.x, R0f.y, R0f.z, R0f.w);
//Color vec3 color = (passPixelColor0.xyz);
vec3 fColour = (passPixelColor0.xyz); const vec3 diffcolor = vec3(1.0, 1.0, 1.0);
fColour = TonemapPass(fColour); color = TonemapPass(color);
vec3 gamma = vec3(1.0/2.2f, 1.0/2.2f, 1.0/2.2f); vec3 contrasted = (color - 0.5) * con + 0.5 + brt;
gamma = pow(fColour, gamma); vec3(pow(abs(color.r), gamma),pow(abs(color.g), gamma),pow(abs(color.b), gamma));
float luminance = fColour.r*0.299 + fColour.g*0.587 + fColour.b*0.114; float luminance = color.r*0.2125 + color.g*0.7154 + color.b*0.0721;
vec3 bright = fColour + vec3(brightness,brightness,brightness); float mn = min(min(color.r, color.g), color.b);
vec3 contrasted = (fColour - 0.5) * contrast + 0.5; float mx = max(max(color.r, color.g), color.b);
float mn = min(min(fColour.r, fColour.g), fColour.b);
float mx = max(max(fColour.r, fColour.g), fColour.b);
float sat = (1.0-(mx - mn)) * (1.0-mx) * luminance * 5.0; float sat = (1.0-(mx - mn)) * (1.0-mx) * luminance * 5.0;
vec3 lightness = vec3((mn + mx)/2.0); vec3 lightness = vec3((mn + mx)/2.0);
const vec3 lightPos = vec3(0.5, 0.5, 5.0); color = mix(color, mix(color, lightness, -vibrance), sat);
const vec3 diffColour = vec3(1.0, 1.0, 1.0); color = (color.xyz - floor) * scale;
const vec3 ambColour = vec3(0.2, 0.2, 0.2); passPixelColor0 = vec4(color.x, color.y, color.z, R0f.w);
fColour = (fColour.xyz - floor) * scale;
passPixelColor0 = vec4(fColour.x, fColour.y, fColour.z, R0f.w);
} }