From f6e71f1e87590e089fe04ba88e78ab9812348f12 Mon Sep 17 00:00:00 2001 From: Joshua Barretto Date: Mon, 19 Apr 2021 22:02:47 +0100 Subject: [PATCH] Fixed negative cloud density bug --- assets/voxygen/shaders/include/cloud/regular.glsl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/assets/voxygen/shaders/include/cloud/regular.glsl b/assets/voxygen/shaders/include/cloud/regular.glsl index e6b5a11a09..682841780f 100644 --- a/assets/voxygen/shaders/include/cloud/regular.glsl +++ b/assets/voxygen/shaders/include/cloud/regular.glsl @@ -53,8 +53,13 @@ vec4 cloud_at(vec3 pos, float dist, out vec3 emission) { const float turb_speed = -1.0; // Turbulence goes the opposite way vec3 turb_offset = vec3(1, 1, 0) * time_of_day.x * turb_speed; mist *= 0.5 + #if (CLOUD_MODE >= CLOUD_MODE_LOW) + 4 * (noise_2d(wind_pos.xy / 20000) - 0.5) - + 1 * (noise_3d(wind_pos / 1000) - 0.5); + #endif + #if (CLOUD_MODE >= CLOUD_MODE_MEDIUM) + + 1 * (noise_3d(wind_pos / 1000) - 0.5) + #endif + ; float CLOUD_DEPTH = (view_distance.w - view_distance.z) * 0.8; const float CLOUD_DENSITY = 5.0; @@ -76,7 +81,7 @@ vec4 cloud_at(vec3 pos, float dist, out vec3 emission) { + 0.5 * (noise_3d(wind_pos / 150.0 / cloud_scale) - 0.5) #endif ) * 0.01; - cloud = pow(cloud, 3) * sign(cloud); + cloud = pow(max(cloud, 0), 3) * sign(cloud); cloud *= CLOUD_DENSITY * (cloud_tendency * 100) * falloff(abs(pos.z - cloud_alt) / CLOUD_DEPTH); // What proportion of sunlight is *not* being blocked by nearby cloud? (approximation)