Proper white color for clouds

This commit is contained in:
Maximilian Giller 2023-01-24 08:39:13 +01:00
parent 0eef1f8e6e
commit 66959c3599
2 changed files with 3 additions and 23 deletions

View file

@ -44,27 +44,8 @@ Color CloudShader::shade(const Scene &scene, const Ray &ray) const
} }
// Pre-processs accumulated getNoise // Pre-processs accumulated getNoise
// accumulatedNoise /= (float) NOISE_SAMPLES;
float cloudDensity = exp(-accumulatedNoise * settings.densityAbsorption); float cloudDensity = exp(-accumulatedNoise * settings.densityAbsorption);
return background * cloudDensity;
if (accumulatedNoise < 1 - settings.densityTreshold)
{
accumulatedNoise = 0;
} else
{
// Fade out the getNoise
accumulatedNoise = (accumulatedNoise - (1 - settings.densityTreshold)) / settings.densityTreshold;
}
// return accumulatedNoise * Color(1, 1, 1);
// Use the getNoise to control the densityTreshold of the clouds
Color cloud = background * (1.0f - accumulatedNoise) + settings.cloudColor * accumulatedNoise;
// Use the getNoise to add some wispy details to the clouds
cloud += settings.wispyColor * (accumulatedNoise * settings.wispyIntensity);
// Add some ambient and diffuse lighting // Add some ambient and diffuse lighting
// cloud += scene.ambientLight() * material.ambient(); // cloud += scene.ambientLight() * material.ambient();
// for (const auto &light: scene.lights()) // for (const auto &light: scene.lights())
@ -74,7 +55,8 @@ Color CloudShader::shade(const Scene &scene, const Ray &ray) const
// float diffuse = dotProduct(normal, illumination.direction); // float diffuse = dotProduct(normal, illumination.direction);
// cloud += material.cloud() * illumination.cloud * diffuse; // cloud += material.cloud() * illumination.cloud * diffuse;
// } // }
return cloud;
return background * cloudDensity + (1.0f - cloudDensity) * settings.cloudColor;
} }
bool CloudShader::isTransparent() const bool CloudShader::isTransparent() const

View file

@ -15,9 +15,7 @@ struct CloudSettings
float densityTreshold = 0.55f; float densityTreshold = 0.55f;
float densityIntensity = 2.5f; float densityIntensity = 2.5f;
float densityAbsorption = 1; float densityAbsorption = 1;
Color cloudColor = Color(0.7f, 0.7f, 0.7f); Color cloudColor = Color(1, 1, 1);
Color wispyColor = Color(0.9f, 0.9f, 0.9f);
float wispyIntensity = 0.3f;
}; };
class CloudShader : public Shader class CloudShader : public Shader