From 7ced041f650574ca209ba0b25e6d3f904264f97b Mon Sep 17 00:00:00 2001 From: Alex <42661490+ThatRedox@users.noreply.github.com> Date: Sat, 14 Jan 2023 01:22:48 -0800 Subject: [PATCH] Don't apply sky fog if fog mode is uniform and density is 0. (#1538) --- .../se/llbit/chunky/renderer/scene/Fog.java | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java b/chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java index 16d413fbb3..3e9adc09e1 100644 --- a/chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java +++ b/chunky/src/java/se/llbit/chunky/renderer/scene/Fog.java @@ -59,17 +59,19 @@ private static double clampDy(double dy) { public void addSkyFog(Ray ray, Vector4 scatterLight) { if (mode == FogMode.UNIFORM) { - double fog; - if (ray.d.y > 0) { - fog = 1 - ray.d.y; - fog *= fog; - } else { - fog = 1; + if (uniformDensity > 0.0) { + double fog; + if (ray.d.y > 0) { + fog = 1 - ray.d.y; + fog *= fog; + } else { + fog = 1; + } + fog *= skyFogDensity; + ray.color.x = (1 - fog) * ray.color.x + fog * fogColor.x; + ray.color.y = (1 - fog) * ray.color.y + fog * fogColor.y; + ray.color.z = (1 - fog) * ray.color.z + fog * fogColor.z; } - fog *= skyFogDensity; - ray.color.x = (1 - fog) * ray.color.x + fog * fogColor.x; - ray.color.y = (1 - fog) * ray.color.y + fog * fogColor.y; - ray.color.z = (1 - fog) * ray.color.z + fog * fogColor.z; } else if (mode == FogMode.LAYERED) { double dy = ray.d.y; double y1 = ray.o.y;