Unverified Commit 42ac8577 authored by Dogway's avatar Dogway Committed by GitHub
Browse files

adjust defaults and prefixes in white_point

parent c4b95335
// White Point Mapping
// ported by Dogway
//
// From the first comment post (sRGB and linear light compensated)
// From the first comment post (sRGB primaries and linear light compensated)
// http://www.zombieprototypes.com/?p=210#comment-4695029660
// Based on the Neil Bartlett's blog update
// http://www.zombieprototypes.com/?p=210
......@@ -9,11 +9,11 @@
// http://www.tannerhelland.com/4435/convert-temperature-rgb-algorithm-code/
#pragma parameter temperature "White Point" 6504.0 1000.0 12000.0 100.0
#pragma parameter temperature "White Point" 9311.0 1031.0 12047.0 72.0
#pragma parameter luma_preserve "Preserve Luminance" 1.0 0.0 1.0 1.0
#pragma parameter red "Red Shift" 0.0 -1.0 1.0 0.01
#pragma parameter green "Green Shift" 0.0 -1.0 1.0 0.01
#pragma parameter blue "Blue Shift" 0.0 -1.0 1.0 0.01
#pragma parameter wp_red "Red Shift" 0.0 -1.0 1.0 0.01
#pragma parameter wp_green "Green Shift" 0.0 -1.0 1.0 0.01
#pragma parameter wp_blue "Blue Shift" 0.0 -1.0 1.0 0.01
#if defined(VERTEX)
......@@ -99,18 +99,18 @@ COMPAT_VARYING vec4 TEX0;
#ifdef PARAMETER_UNIFORM
uniform COMPAT_PRECISION float temperature, luma_preserve, red, green, blue;
#else
#define temperature 6504.0
#define temperature 9311.0
#define luma_preserve 1.0
#define red 0.0
#define green 0.0
#define blue 0.0
#define wp_red 0.0
#define wp_green 0.0
#define wp_blue 0.0
#endif
vec3 wp_adjust(vec3 color){
float temp = temperature / 100.0;
float k = temperature / 10000.0;
float temp = temperature / 100.;
float k = temperature / 10000.;
float lk = log(k);
vec3 wp = vec3(1.);
......@@ -129,11 +129,11 @@ vec3 wp_adjust(vec3 color){
// clamp
wp.rgb = clamp(wp.rgb, vec3(0.), vec3(1.));
// this is dumb, but various cores don't always show white as white. Use this to make white white...
wp.rgb += vec3(red, green, blue);
// R/G/B independent manual White Point adjustment
wp.rgb += vec3(wp_red, wp_green, wp_blue);
// Linear color input
return (color * wp);
return color * wp;
}
vec3 sRGB_to_XYZ(vec3 RGB){
......@@ -184,7 +184,7 @@ vec3 linear_to_sRGB(vec3 color, float gamma){
color.b = (color.b <= 0.00313066844250063) ?
color.b * 12.92 : 1.055 * pow(color.b, 1.0 / gamma) - 0.055;
return color;
return color.rgb;
}
......@@ -198,17 +198,17 @@ vec3 sRGB_to_linear(vec3 color, float gamma){
color.b = (color.b <= 0.04045) ?
color.b / 12.92 : pow((color.b + 0.055) / (1.055), gamma);
return color;
return color.rgb;
}
void main()
{
vec3 original = sRGB_to_linear(COMPAT_TEXTURE(Source, vTexCoord).rgb, vec3(2.4));
vec3 original = sRGB_to_linear(COMPAT_TEXTURE(Source, vTexCoord).rgb, 2.40);
vec3 adjusted = wp_adjust(original);
vec3 base_luma = XYZtoYxy(sRGB_to_XYZ(original));
vec3 adjusted_luma = XYZtoYxy(sRGB_to_XYZ(adjusted));
adjusted = (luma_preserve > 0.5) ? adjusted_luma + (vec3(base_luma.r,0.,0.) - vec3(adjusted_luma.r,0.,0.)) : adjusted_luma;
FragColor = vec4(linear_to_sRGB(XYZ_to_sRGB(YxytoXYZ(adjusted)), vec3(2.4)), 1.0);
adjusted = (luma_preserve == 1.0) ? adjusted_luma + (vec3(base_luma.r,0.,0.) - vec3(adjusted_luma.r,0.,0.)) : adjusted_luma;
FragColor = vec4(linear_to_sRGB(XYZ_to_sRGB(YxytoXYZ(adjusted)), 2.40), 1.0);
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment