diff options
Diffstat (limited to 'intern/cycles/kernel/osl/nodes/node_sky_texture.osl')
-rw-r--r-- | intern/cycles/kernel/osl/nodes/node_sky_texture.osl | 70 |
1 files changed, 35 insertions, 35 deletions
diff --git a/intern/cycles/kernel/osl/nodes/node_sky_texture.osl b/intern/cycles/kernel/osl/nodes/node_sky_texture.osl index fdb9b1d9708..932fb1e2f17 100644 --- a/intern/cycles/kernel/osl/nodes/node_sky_texture.osl +++ b/intern/cycles/kernel/osl/nodes/node_sky_texture.osl @@ -32,10 +32,10 @@ color xyY_to_xyz(float x, float y, float Y) { float X, Z; - if(y != 0.0) X = (x / y) * Y; + if (y != 0.0) X = (x / y) * Y; else X = 0.0; - if(y != 0.0 && Y != 0.0) Z = ((1.0 - x - y) / y) * Y; + if (y != 0.0 && Y != 0.0) Z = ((1.0 - x - y) / y) * Y; else Z = 0.0; return color(X, Y, Z); @@ -50,11 +50,11 @@ color xyz_to_rgb(float x, float y, float z) float sky_angle_between(float thetav, float phiv, float theta, float phi) { - float cospsi = sin(thetav)*sin(theta)*cos(phi - phiv) + cos(thetav)*cos(theta); + float cospsi = sin(thetav) * sin(theta) * cos(phi - phiv) + cos(thetav) * cos(theta); - if(cospsi > 1.0) + if (cospsi > 1.0) return 0.0; - if(cospsi < -1.0) + if (cospsi < -1.0) return M_PI; return acos(cospsi); @@ -70,7 +70,7 @@ float sky_perez_function(float lam[5], float theta, float gamma) float ctheta = cos(theta); float cgamma = cos(gamma); - return (1.0 + lam[0]*exp(lam[1] / ctheta)) * (1.0 + lam[2]*exp(lam[3]*gamma) + lam[4]*cgamma*cgamma); + return (1.0 + lam[0] * exp(lam[1] / ctheta)) * (1.0 + lam[2] * exp(lam[3] * gamma) + lam[4] * cgamma * cgamma); } color sky_xyz_radiance(KernelSunSky sunsky, vector dir) @@ -106,42 +106,42 @@ void precompute_sunsky(vector dir, float turbidity, output KernelSunSky sunsky) sunsky.phi = phi; sunsky.dir = dir; - float theta2 = theta*theta; - float theta3 = theta*theta*theta; + float theta2 = theta * theta; + float theta3 = theta * theta * theta; float T = turbidity; - float T2 = T*T; + float T2 = T * T; - float chi = (4.0/ 9.0- T / 120.0) * (M_PI - 2.0* theta); - sunsky.zenith_Y = (4.0453*T - 4.9710) * tan(chi) - 0.2155*T + 2.4192; + float chi = (4.0 / 9.0 - T / 120.0) * (M_PI - 2.0 * theta); + sunsky.zenith_Y = (4.0453 * T - 4.9710) * tan(chi) - 0.2155 * T + 2.4192; sunsky.zenith_Y *= 0.06; sunsky.zenith_x = - (0.00166* theta3 - 0.00375* theta2 + 0.00209* theta)*T2 + - (-0.02903* theta3 + 0.06377* theta2 - 0.03202* theta + 0.00394)*T + - (0.11693* theta3 - 0.21196* theta2 + 0.06052* theta + 0.25886); + ( 0.00166 * theta3 - 0.00375 * theta2 + 0.00209 * theta) * T2 + + (-0.02903 * theta3 + 0.06377 * theta2 - 0.03202 * theta + 0.00394) * T + + ( 0.11693 * theta3 - 0.21196 * theta2 + 0.06052 * theta + 0.25886); sunsky.zenith_y = - (0.00275* theta3 - 0.00610* theta2 + 0.00317* theta)*T2 + - (-0.04214* theta3 + 0.08970* theta2 - 0.04153* theta + 0.00516)*T + - (0.15346* theta3 - 0.26756* theta2 + 0.06670* theta + 0.26688); - - sunsky.perez_Y[0] = (0.1787*T - 1.4630); - sunsky.perez_Y[1] = (-0.3554*T + 0.4275); - sunsky.perez_Y[2] = (-0.0227*T + 5.3251); - sunsky.perez_Y[3] = (0.1206*T - 2.5771); - sunsky.perez_Y[4] = (-0.0670*T + 0.3703); - - sunsky.perez_x[0] = (-0.0193*T - 0.2592); - sunsky.perez_x[1] = (-0.0665*T + 0.0008); - sunsky.perez_x[2] = (-0.0004*T + 0.2125); - sunsky.perez_x[3] = (-0.0641*T - 0.8989); - sunsky.perez_x[4] = (-0.0033*T + 0.0452); - - sunsky.perez_y[0] = (-0.0167*T - 0.2608); - sunsky.perez_y[1] = (-0.0950*T + 0.0092); - sunsky.perez_y[2] = (-0.0079*T + 0.2102); - sunsky.perez_y[3] = (-0.0441*T - 1.6537); - sunsky.perez_y[4] = (-0.0109*T + 0.0529); + ( 0.00275 * theta3 - 0.00610 * theta2 + 0.00317 * theta) * T2 + + (-0.04214 * theta3 + 0.08970 * theta2 - 0.04153 * theta + 0.00516) * T + + ( 0.15346 * theta3 - 0.26756 * theta2 + 0.06670 * theta + 0.26688); + + sunsky.perez_Y[0] = ( 0.1787 * T - 1.4630); + sunsky.perez_Y[1] = (-0.3554 * T + 0.4275); + sunsky.perez_Y[2] = (-0.0227 * T + 5.3251); + sunsky.perez_Y[3] = ( 0.1206 * T - 2.5771); + sunsky.perez_Y[4] = (-0.0670 * T + 0.3703); + + sunsky.perez_x[0] = (-0.0193 * T - 0.2592); + sunsky.perez_x[1] = (-0.0665 * T + 0.0008); + sunsky.perez_x[2] = (-0.0004 * T + 0.2125); + sunsky.perez_x[3] = (-0.0641 * T - 0.8989); + sunsky.perez_x[4] = (-0.0033 * T + 0.0452); + + sunsky.perez_y[0] = (-0.0167 * T - 0.2608); + sunsky.perez_y[1] = (-0.0950 * T + 0.0092); + sunsky.perez_y[2] = (-0.0079 * T + 0.2102); + sunsky.perez_y[3] = (-0.0441 * T - 1.6537); + sunsky.perez_y[4] = (-0.0109 * T + 0.0529); sunsky.zenith_Y /= sky_perez_function(sunsky.perez_Y, 0, theta); sunsky.zenith_x /= sky_perez_function(sunsky.perez_x, 0, theta); |