Great work!
I was just about to do the same thing but while struggling with the math
to express the pigment functions I luckily found your implementation ;)
But I'm wondering: while you cite the Preetham paper you do use
different values for the A to C parameters and also for the Perez
formulation.
Actually I do like the resulting renders better with the original values
from the Preetham paper (might very well just be a matter of individual
taste) but I'm curious where the other values did come from.
Also I'm wondering about the multiplication factor of 1000 for the
zenith luminance. As far as I understand it this formula return the
luminance in cd/m2 therefore this additional multiplication just makes
the exposure factor unnecessary small.
Here is what I do use (with the originalPreetham/Perez values):
// constant factors
#local AY = 0.1787*Turbidity- 1.4630;
#local BY =-0.3554*Turbidity+ 0.4275;
#local CY =-0.0227*Turbidity+ 5.3251;
#local DY = 0.1206*Turbidity- 2.5771;
#local EY =-0.0670*Turbidity+ 0.3703;
#local Ax =-0.0193*Turbidity- 0.2592;
#local Bx =-0.0665*Turbidity+ 0.0008;
#local Cx =-0.0004*Turbidity+ 0.2125;
#local Dx =-0.0641*Turbidity- 0.8989;
#local Ex =-0.0033*Turbidity+ 0.0452;
#local Ay =-0.0167*Turbidity- 0.2608;
#local By =-0.0950*Turbidity+ 0.0092;
#local Cy =-0.0079*Turbidity+ 0.2102;
#local Dy =-0.0441*Turbidity- 1.6537;
#local Ey =-0.0109*Turbidity+ 0.0529;
#macro computeZenithColor(T,thetas)
// Calculate luminance
#local zenithLuminance = ((4.0453*T - 4.9710) * tan( (4.0/9.0 - T/120)
* (pi-2*thetas) ) - 0.2155*T + 2.4192);
#if(zenithLuminance<=0)
#local zenithLuminance=1e-11;
#end
// Calculate colour
#local thetas2 = thetas*thetas;
#local thetas3 = thetas*thetas2;
#local T2 = T*T;
#local zx= ( 0.00166*thetas3 - 0.00375*thetas2 + 0.00209*thetas) * T2 +
(-0.02903*thetas3 + 0.06377*thetas2 - 0.03202*thetas +
0.00394) * T +
( 0.11693*thetas3 - 0.21196*thetas2 + 0.06052*thetas +
0.25886);
#local zy= ( 0.00275*thetas3 - 0.00610*thetas2 + 0.00317*thetas) * T2 +
(-0.04214*thetas3 + 0.08970*thetas2 - 0.04153*thetas +
0.00516) * T +
( 0.15346*thetas3 - 0.26756*thetas2 + 0.06670*thetas +
0.26688);
<zx,zy,zenithLuminance>
#end
-Ive
Post a reply to this message
|