From 81e9a162be9390ce00f54525fd3cb3be8e5f32cc Mon Sep 17 00:00:00 2001 From: Maximilian Giller Date: Fri, 27 Jan 2023 05:27:42 +0100 Subject: [PATCH] Reset some values and a somewhat decent result --- shader/cloudshader.cpp | 6 ++++-- shader/cloudshader.h | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/shader/cloudshader.cpp b/shader/cloudshader.cpp index 830fde3..5c4379c 100644 --- a/shader/cloudshader.cpp +++ b/shader/cloudshader.cpp @@ -55,6 +55,9 @@ Color CloudShader::shade(const Scene &scene, const Ray &ray) const accumulatedDensity += sampleDensity; } + if (accumulatedDensity > 1) + cloudColor /= accumulatedDensity; + float transmittance = exp(-accumulatedDensity * settings.lightAbsorptionThroughCloud); return background * transmittance + cloudColor; @@ -118,9 +121,8 @@ Color CloudShader::lightMarch(const Scene &scene, Vector3d currentInCloudPositio float transmittance = getDensityTransmittance(density); float scatter = scatterFactor(normalized(lengthDistance), illumination.direction); - // TODO: Back to default float factor = settings.darknessThreshold + - (1.0f - settings.darknessThreshold) * (1); // (transmittance * scatter) + (1.0f - settings.darknessThreshold) * (transmittance * scatter); // (transmittance * scatter) cloudColor += factor * illumination.color; } diff --git a/shader/cloudshader.h b/shader/cloudshader.h index cb4fc7a..d00f79c 100644 --- a/shader/cloudshader.h +++ b/shader/cloudshader.h @@ -17,7 +17,7 @@ struct CloudSettings float scale = 10; float densityOffset = -0.57f; float densityIntensity = 7.0f; // 7.0f - float darknessThreshold = 0.2f; // 0.07f + float darknessThreshold = 0.07f; // 0.07f float shadowIntensity = 0.6f; float shadowLightAbsorption = 1; float lightAbsorptionTowardsLight = 1.0f;