From 3685b735bcfb5f49b5460ed34515e35fe6c8f090 Mon Sep 17 00:00:00 2001 From: Steven M Date: Sun, 7 Jun 2026 18:12:34 +0100 Subject: [PATCH] Fix faint lightshafts when Voxy/DH is enabled When VOXY or DISTANT_HORIZONS is defined, maxDistance was set to renderDistance * 0.5 for all pixels. The weight accumulation normalizes against maxDistance, so with a large LOD render distance (e.g. 512 chunks) geometry at vanilla render distance only accumulated ~4% of the expected weight, making lightshafts appear very faint. Fix: keep maxDistance = far * 0.98 for non-sky pixels so weight normalization is identical to vanilla behaviour. Only sky pixels that need to trace into the LOD zone use loddedMaxDistance, where the extended distance is appropriate and weights still integrate correctly to 1.0. --- .../volumetricLight/volumetricLight.glsl | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/shaders/lib/atmospherics/volumetricLight/volumetricLight.glsl b/shaders/lib/atmospherics/volumetricLight/volumetricLight.glsl index 971782be..afe3f970 100644 --- a/shaders/lib/atmospherics/volumetricLight/volumetricLight.glsl +++ b/shaders/lib/atmospherics/volumetricLight/volumetricLight.glsl @@ -94,9 +94,11 @@ vec4 GetVolumetricLight(inout float vlFactor, vec3 translucentMult, float lViewP float maxDistance = far * 0.98; // The distance where the fog is 1.0 and we stop tracing float qualityThreshold = min(far, shadowDistance) * 0.98; // Only use farSamples from this point on to hit our maxDistance. Set higher than maxDistance to disable far samples - + #if defined VOXY || defined DISTANT_HORIZONS - maxDistance = renderDistance * 0.5; // Covers lod chunks + // loddedMaxDistance is only used for sky pixels — non-sky pixels keep maxDistance = far + // so weight normalization isn't diluted by a large LOD render distance + float loddedMaxDistance = max(renderDistance * 0.5, maxDistance); fogCurve = 0.7; fogCurveIntense *= 1.0 - 0.5 * rainFactor; @@ -142,7 +144,11 @@ vec4 GetVolumetricLight(inout float vlFactor, vec3 translucentMult, float lViewP vec3 nViewPosInSceneSpace = normalize(mat3(gbufferModelViewInverse) * nViewPos); vec3 rayDirection = nViewPosInSceneSpace; - float rayEnd = !sky ? min(lViewPos1, maxDistance) : maxDistance; + float rayEnd = !sky ? min(lViewPos1, maxDistance) : maxDistance; + #if defined VOXY || defined DISTANT_HORIZONS + // Sky pixels trace into LOD chunks; update maxDistance so weights normalize correctly + if (sky) { rayEnd = loddedMaxDistance; maxDistance = loddedMaxDistance; } + #endif float lastDistance = 0.0; #if defined END && !defined VOXY && !defined DISTANT_HORIZONS