[BotW] make contrasty happen before tone mapping

*for experimental purpose, haven't tested.
yea bd8bba is tone mapping
This commit is contained in:
NAVras-Z 2017-10-19 00:36:43 +08:00
parent 8768e66b31
commit 01f2f10337

View File

@ -57,12 +57,33 @@ R1f *= bloomFactor;
R0f.xyz = (texture(textureUnitPS1, R0f.xy).xyz);
// 0
R126f.x = R1f.x + R0f.x;
PV0f.x = R126f.x;
R127f.y = R1f.y + R0f.y;
PV0f.y = R127f.y;
R126f.z = R1f.z + R0f.z;
PV0f.z = R126f.z;
R125f.w = 1.0;
//Color Tweak
vec3 fColour = vec3(R126f.x, R127f.y, R126f.z);
fColour = max(vec3(0.0), fColour - vec3(crushContrast));
fColour = clamp(exposure * fColour, 0.0, 1.0);
fColour = pow(fColour, vec3(1.0 / gamma));
float luminance = fColour.r*0.299 + fColour.g*0.587 + fColour.b*0.114;
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;
vec3 lightness = vec3((mn + mx)/2.0);
// vibrance
fColour = mix(fColour, mix(fColour, lightness, -vibrance), sat);
//vec3 fColour = (fColour.xyz - floor) * scale; // Not recommended 0-255->16-235..
R126f.x = fColour.x;
R127f.y = fColour.y;
R126f.z = fColour.z;
PV0f.xyz = fColour;
// 1
tempf.x = dot(vec4(PV0f.x,PV0f.y,PV0f.z,-0.0),vec4(intBitsToFloat(0x3e99096c),intBitsToFloat(0x3f162b6b),intBitsToFloat(0x3dea4a8c),0.0));
PV1f.x = tempf.x;
@ -147,20 +168,6 @@ R0f.x = (mul_nonIEEE(R126f.x,R125f.w) + PV1f.w);
R0f.y = (mul_nonIEEE(R126f.x,R127f.z) + PV1f.w);
R0f.z = (mul_nonIEEE(R126f.x,R126f.y) + PV1f.w);
//Color Tweak
vec3 fColour = R0f.xyz;
fColour = max(vec3(0.0), fColour - vec3(crushContrast));
fColour = clamp(exposure * fColour, 0.0, 1.0);
fColour = pow(fColour, vec3(1.0 / gamma));
float luminance = fColour.r*0.299 + fColour.g*0.587 + fColour.b*0.114;
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;
vec3 lightness = vec3((mn + mx)/2.0);
// vibrance
fColour = mix(fColour, mix(fColour, lightness, -vibrance), sat);
//vec3 fColour = (fColour.xyz - floor) * scale; // Not recommended 0-255->16-235..
// export
passPixelColor0 = vec4(fColour.x, fColour.y, fColour.z, R0f.w);
passPixelColor0 = vec4(R0f.x, R0f.y, R0f.z, R0f.w);
}