moon object, tweaks to the lighting model

This commit is contained in:
tmj-fstate
2017-03-28 13:09:01 +02:00
parent 2ec6cad7cb
commit 9dda5037d3
12 changed files with 220 additions and 128 deletions

View File

@@ -184,7 +184,7 @@ void CSkyDome::SetGammaCorrection( float const Gamma ) {
void CSkyDome::SetOvercastFactor( float const Overcast ) {
m_overcast = clamp( Overcast, 0.0f, 1.0f );
m_overcast = clamp( Overcast, 0.0f, 1.0f ) * 0.75f; // going above 0.65 makes the model go pretty bad, appearance-wise
}
void CSkyDome::GetPerez( float *Perez, float Distribution[ 5 ][ 2 ], const float Turbidity ) {
@@ -277,7 +277,7 @@ void CSkyDome::RebuildColors() {
// luminance(Y) for clear & overcast sky
float const yclear = PerezFunctionO2( perezluminance, icostheta, gamma, cosgamma2, zenithluminance );
float const yover = ( 1.0f + 2.0f * vertex.y ) / 3.0f;
float const yover = zenithluminance * ( 1.0f + 2.0f * vertex.y ) / 3.0f;
float const Y = interpolate( yclear, yover, m_overcast );
float const X = (x / y) * Y;
@@ -295,6 +295,11 @@ void CSkyDome::RebuildColors() {
colorconverter.z = 1.0f - exp( -m_expfactor * colorconverter.z );
}
// desaturate sky colour, based on overcast level
if( colorconverter.y > 0.0f ) {
colorconverter.y *= ( 1.0f - m_overcast );
}
// override the hue, based on sun height above the horizon. crude way to deal with model shortcomings
// correction begins when the sun is higher than 10 degrees above the horizon, and fully in effect at 10+15 degrees
float const degreesabovehorizon = 90.0f - m_thetasun * ( 180.0f / M_PI );
@@ -318,8 +323,8 @@ void CSkyDome::RebuildColors() {
*/
// crude correction for the times where the model breaks (late night)
// TODO: use proper night sky calculation for these times instead
if( ( color.x <= 0.0f )
&& ( color.y <= 0.0f ) ) {
if( ( color.x <= 0.05f )
&& ( color.y <= 0.05f ) ) {
// darken the sky as the sun goes deeper below the horizon
// 15:50:75 is picture-based night sky colour. it may not be accurate but looks 'right enough'
color.z = 0.75f * std::max( color.z + m_sundirection.y, 0.075f );