From 66959c35995ed4430796d3d777664e83fb41d62d Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Tue, 24 Jan 2023 08:39:13 +0100 Subject: [PATCH] Proper white color for clouds --- shader/cloudshader.cpp | 22 ++-------------------- shader/cloudshader.h | 4 +--- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/shader/cloudshader.cpp b/shader/cloudshader.cpp index 4fbb900..778eb91 100644 --- a/shader/cloudshader.cpp +++ b/shader/cloudshader.cpp @@ -44,27 +44,8 @@ Color CloudShader::shade(const Scene &scene, const Ray &ray) const } // Pre-processs accumulated getNoise -// accumulatedNoise /= (float) NOISE_SAMPLES; 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 // cloud += scene.ambientLight() * material.ambient(); // 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); // cloud += material.cloud() * illumination.cloud * diffuse; // } - return cloud; + + return background * cloudDensity + (1.0f - cloudDensity) * settings.cloudColor; } bool CloudShader::isTransparent() const diff --git a/shader/cloudshader.h b/shader/cloudshader.h index 69b9149..aee7ae8 100644 --- a/shader/cloudshader.h +++ b/shader/cloudshader.h @@ -15,9 +15,7 @@ struct CloudSettings float densityTreshold = 0.55f; float densityIntensity = 2.5f; float densityAbsorption = 1; - Color cloudColor = Color(0.7f, 0.7f, 0.7f); - Color wispyColor = Color(0.9f, 0.9f, 0.9f); - float wispyIntensity = 0.3f; + Color cloudColor = Color(1, 1, 1); }; class CloudShader : public Shader