xyYToRGB.glsl   xyYToRGB.glsl 
skipping to change at line 19 skipping to change at line 19
// Variables for the color computation // Variables for the color computation
uniform highp vec3 sunPos; uniform highp vec3 sunPos;
uniform mediump float term_x, Ax, Bx, Cx, Dx, Ex; uniform mediump float term_x, Ax, Bx, Cx, Dx, Ex;
uniform mediump float term_y, Ay, By, Cy, Dy, Ey; uniform mediump float term_y, Ay, By, Cy, Dy, Ey;
// The current projection matrix // The current projection matrix
uniform mediump mat4 projectionMatrix; uniform mediump mat4 projectionMatrix;
// Contains the 2d position of the point on the screen (before multiplicati on by the projection matrix) // Contains the 2d position of the point on the screen (before multiplicati on by the projection matrix)
attribute mediump vec2 skyVertex; attribute mediump vec2 vertex;
// Contains the r,g,b,Y (luminosity) components. // Contains the r,g,b,Y (luminosity) components.
attribute highp vec4 skyColor; attribute highp vec4 color;
// The output variable passed to the fragment shader // The output variable passed to the fragment shader
varying mediump vec4 resultSkyColor; varying mediump vec4 resultSkyColor;
void main() void main()
{ {
gl_Position = projectionMatrix*vec4(skyVertex, 0., 1.); gl_Position = projectionMatrix*vec4(vertex, 0., 1.);
highp vec4 color = skyColor;
// Must be a separate variable due to Intel drivers
vec4 tempColor = color;
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// First compute the xy color component // First compute the xy color component
// color contains the unprojected vertex position in r,g,b // color contains the unprojected vertex position in r,g,b
// + the Y (luminance) component of the color in the alpha channel // + the Y (luminance) component of the color in the alpha channel
if (color[3]>0.01) if (tempColor[3]>0.01)
{ {
highp float cosDistSunq = sunPos[0]*color[0] + sunPos[1]*col or[1] + sunPos[2]*color[2]; highp float cosDistSunq = sunPos[0]*tempColor[0] + sunPos[1] *tempColor[1] + sunPos[2]*tempColor[2];
highp float distSun=acos(cosDistSunq); highp float distSun=acos(cosDistSunq);
highp float oneOverCosZenithAngle = (color[2]==0.) ? 9999999 999999. : 1. / color[2]; highp float oneOverCosZenithAngle = (tempColor[2]==0.) ? 999 9999999999. : 1. / tempColor[2];
cosDistSunq*=cosDistSunq; cosDistSunq*=cosDistSunq;
color[0] = term_x * (1. + Ax * exp(Bx*oneOverCosZenithAngle) tempColor[0] = term_x * (1. + Ax * exp(Bx*oneOverCosZenithAn
)* (1. + Cx * exp(Dx*distSun) + Ex * cosDistSunq); gle))* (1. + Cx * exp(Dx*distSun) + Ex * cosDistSunq);
color[1] = term_y * (1. + Ay * exp(By*oneOverCosZenithAngle) tempColor[1] = term_y * (1. + Ay * exp(By*oneOverCosZenithAn
)* (1. + Cy * exp(Dy*distSun) + Ey * cosDistSunq); gle))* (1. + Cy * exp(Dy*distSun) + Ey * cosDistSunq);
if (color[0] < 0. || color[1] < 0.) if (tempColor[0] < 0. || tempColor[1] < 0.)
{ {
color[0] = 0.25; tempColor[0] = 0.25;
color[1] = 0.25; tempColor[1] = 0.25;
} }
} }
else else
{ {
color[0] = 0.25; tempColor[0] = 0.25;
color[1] = 0.25; tempColor[1] = 0.25;
} }
color[2]=color[3]; tempColor[2]=tempColor[3];
color[3]=1.; tempColor[3]=1.;
//////////////////////////////////////////////////////////////////// /////// //////////////////////////////////////////////////////////////////// ///////
// Now we have the xyY components in color, need to convert to RGB // Now we have the xyY components in color, need to convert to RGB
// 1. Hue conversion // 1. Hue conversion
// if log10Y>0.6, photopic vision only (with the cones, colors are s een) // if log10Y>0.6, photopic vision only (with the cones, colors are s een)
// else scotopic vision if log10Y<-2 (with the rods, no colors, ever ything blue), // else scotopic vision if log10Y<-2 (with the rods, no colors, ever ything blue),
// else mesopic vision (with rods and cones, transition state) // else mesopic vision (with rods and cones, transition state)
if (color[2] <= 0.01) if (tempColor[2] <= 0.01)
{ {
// special case for s = 0 (x=0.25, y=0.25) // special case for s = 0 (x=0.25, y=0.25)
color[2] *= 0.5121445; tempColor[2] *= 0.5121445;
color[2] = pow(color[2]*pi*0.0001, alphaWaOverAlphaDa*oneOve tempColor[2] = pow(tempColor[2]*pi*0.0001, alphaWaOverAlphaD
rGamma)* term2TimesOneOverMaxdLpOneOverGamma; a*oneOverGamma)* term2TimesOneOverMaxdLpOneOverGamma;
color[0] = 0.787077*color[2]; tempColor[0] = 0.787077*tempColor[2];
color[1] = 0.9898434*color[2]; tempColor[1] = 0.9898434*tempColor[2];
color[2] *= 1.9256125; tempColor[2] *= 1.9256125;
resultSkyColor = color*brightnessScale; resultSkyColor = tempColor*brightnessScale;
} }
else else
{ {
if (color[2]<3.9810717055349722) if (tempColor[2]<3.9810717055349722)
{ {
// Compute s, ratio between scotopic and photopic vi sion // Compute s, ratio between scotopic and photopic vi sion
float op = (log(color[2])/ln10 + 2.)/2.6; float op = (log(tempColor[2])/ln10 + 2.)/2.6;
float s = op * op *(3. - 2. * op); float s = op * op *(3. - 2. * op);
// Do the blue shift for scotopic vision simulation (night vision) [3] // Do the blue shift for scotopic vision simulation (night vision) [3]
// The "night blue" is x,y(0.25, 0.25) // The "night blue" is x,y(0.25, 0.25)
color[0] = (1. - s) * 0.25 + s * color[0]; // A tempColor[0] = (1. - s) * 0.25 + s * tempColor[0];
dd scotopic + photopic components // Add scotopic + photopic components
color[1] = (1. - s) * 0.25 + s * color[1]; // A tempColor[1] = (1. - s) * 0.25 + s * tempColor[1];
dd scotopic + photopic components // Add scotopic + photopic components
// Take into account the scotopic luminance approxim ated by V [3] [4] // Take into account the scotopic luminance approxim ated by V [3] [4]
float V = color[2] * (1.33 * (1. + color[1] / color[ float V = tempColor[2] * (1.33 * (1. + tempColor[1]
0] + color[0] * (1. - color[0] - color[1])) - 1.68); / tempColor[0] + tempColor[0] * (1. - tempColor[0] - tempColor[1])) - 1.68)
color[2] = 0.4468 * (1. - s) * V + s * color[2]; ;
tempColor[2] = 0.4468 * (1. - s) * V + s * tempColor
[2];
} }
// 2. Adapt the luminance value and scale it to fit in the R GB range [2] // 2. Adapt the luminance value and scale it to fit in the R GB range [2]
// color[2] = std::pow(adaptLuminanceScaled(color[2]), oneOv // tempColor[2] = std::pow(adaptLuminanceScaled(tempColor[2]
erGamma); ), oneOverGamma);
color[2] = pow(color[2]*pi*0.0001, alphaWaOverAlphaDa*oneOve tempColor[2] = pow(tempColor[2]*pi*0.0001, alphaWaOverAlphaD
rGamma)* term2TimesOneOverMaxdLpOneOverGamma; a*oneOverGamma)* term2TimesOneOverMaxdLpOneOverGamma;
// Convert from xyY to XZY // Convert from xyY to XZY
// Use a XYZ to Adobe RGB (1998) matrix which uses a D65 ref erence white // Use a XYZ to Adobe RGB (1998) matrix which uses a D65 ref erence white
mediump vec3 tmp = vec3(color[0] * color[2] / color[1], colo r[2], (1. - color[0] - color[1]) * color[2] / color[1]); mediump vec3 tmp = vec3(tempColor[0] * tempColor[2] / tempCo lor[1], tempColor[2], (1. - tempColor[0] - tempColor[1]) * tempColor[2] / t empColor[1]);
resultSkyColor = vec4(2.04148*tmp.x-0.564977*tmp.y-0.344713* tmp.z, -0.969258*tmp.x+1.87599*tmp.y+0.0415557*tmp.z, 0.0134455*tmp.x-0.118 373*tmp.y+1.01527*tmp.z, 1.); resultSkyColor = vec4(2.04148*tmp.x-0.564977*tmp.y-0.344713* tmp.z, -0.969258*tmp.x+1.87599*tmp.y+0.0415557*tmp.z, 0.0134455*tmp.x-0.118 373*tmp.y+1.01527*tmp.z, 1.);
resultSkyColor*=brightnessScale; resultSkyColor*=brightnessScale;
} }
} }
 End of changes. 18 change blocks. 
40 lines changed or deleted 44 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/