Skylight.hpp   Skylight.hpp 
skipping to change at line 56 skipping to change at line 56
// This funtion has to be called once before any call to get_*_value () // This funtion has to be called once before any call to get_*_value ()
void setParams(float sunZenithAngle, float turbidity); void setParams(float sunZenithAngle, float turbidity);
// Compute the sky color at the given position in the xyY color syst em and store it in position.color // Compute the sky color at the given position in the xyY color syst em and store it in position.color
// void getxyYValue(skylightStruct * position); // void getxyYValue(skylightStruct * position);
// Return the current zenith color // Return the current zenith color
inline void getZenithColor(float * v) const; inline void getZenithColor(float * v) const;
// Same functions but in vector mode : faster because prevents extra cosine calculations // Same functions but in vector mode : faster because prevents extra cosine calculations
// The position vectors MUST be normalized, and the vertical z compo nent is the third one // The position vectors MUST be normalized, and the vertical z compo nent is the third one
void setParamsv(const float * sunPos, float turbidity); void setParamsv(const float * sunPos, float turbidity);
void getxyYValuev(skylightStruct2& position) const;
// Compute the sky color at the given position in the CIE color syst
em and store it in p.color
// p.color[0] is CIE x color component
// p.color[1] is CIE y color component
// p.color[2] is CIE Y color component (luminance)
void getxyYValuev(skylightStruct2& p) const
{
const float cosDistSun = sunPos[0]*p.pos[0] + sunPos[1]*p.po
s[1] + sunPos[2]*p.pos[2];
const float distSun = fastAcos(cosDistSun);
const float cosDistSun_q = cosDistSun*cosDistSun;
Q_ASSERT(p.pos[2] >= 0.f);
const float oneOverCosZenithAngle = (p.pos[2]==0.) ? 1e99 :
1.f / p.pos[2];
p.color[0] = term_x * (1.f + Ax * std::exp(Bx*oneOverCosZeni
thAngle))
* (1.f + Cx * std::exp(Dx*distSun) + Ex * co
sDistSun_q);
p.color[1] = term_y * (1.f + Ay * std::exp(By*oneOverCosZeni
thAngle))
* (1.f + Cy * std::exp(Dy*distSun) + Ey * co
sDistSun_q);
p.color[2] = term_Y * (1.f + AY * std::exp(BY*oneOverCosZeni
thAngle))
* (1.f + CY * std::exp(DY*distSun) + EY * co
sDistSun_q);
if (p.color[2] < 0. || p.color[0] < 0. || p.color[1] < 0.)
{
p.color[0] = 0.25;
p.color[1] = 0.25;
p.color[2] = 0.;
}
}
private: private:
float thetas; // angular distance between the zenith and the sun in radian float thetas; // angular distance between the zenith and the sun in radian
float T; // Turbidity : i.e. sky "clarity" float T; // Turbidity : i.e. sky "clarity"
// 1 : pure air // 1 : pure air
// 2 : exceptionnally clear // 2 : exceptionnally clear
// 4 : clear // 4 : clear
// 8 : light haze // 8 : light haze
// 25 : haze // 25 : haze
// 64 : thin fog // 64 : thin fog
skipping to change at line 95 skipping to change at line 123
// Compute CIE Y (luminance) for zenith in cd/m^2 // Compute CIE Y (luminance) for zenith in cd/m^2
inline void computeZenithLuminance(void); inline void computeZenithLuminance(void);
// Compute CIE x and y color components // Compute CIE x and y color components
inline void computeZenithColor(void); inline void computeZenithColor(void);
// Compute the luminance distribution coefficients // Compute the luminance distribution coefficients
inline void computeLuminanceDistributionCoefs(void); inline void computeLuminanceDistributionCoefs(void);
// Compute the color distribution coefficients // Compute the color distribution coefficients
inline void computeColorDistributionCoefs(void); inline void computeColorDistributionCoefs(void);
/// Compute acos(x)
//! The taylor serie is not accurate around x=1 and x=-1
static inline float fastAcos(float x)
{
return M_PI_2 - (x + x*x*x * (1.f/6.f + x*x * (3.f/40.f + 5.
f/112.f * x*x)) );
}
}; };
// Return the current zenith color in xyY color system // Return the current zenith color in xyY color system
inline void Skylight::getZenithColor(float * v) const inline void Skylight::getZenithColor(float * v) const
{ {
v[0] = zenithColorX; v[0] = zenithColorX;
v[1] = zenithColorY; v[1] = zenithColorY;
v[2] = zenithLuminance; v[2] = zenithLuminance;
} }
 End of changes. 2 change blocks. 
1 lines changed or deleted 45 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/