Fix clouds3d: declare outer cloud variable

'cloud' was referenced outside the for-loop where it was
defined. Use 1.0 - trans (transmittance) as a cloud mask
instead — same information, properly scoped.
This commit is contained in:
Richard Zink committed 2026-10-07 20:09:56 +02:00
1 parent 48160b730f
commit 7cb04686c7
1 file changed
+3 -2
+3 -2
View File
@@ -188,8 +188,9 @@ var FRAG_SRC = [
// is not the same as 'is it night'). // is not the same as 'is it night').
// Only darkens the sky, NOT the clouds — we want them to stay // Only darkens the sky, NOT the clouds — we want them to stay
// moon-lit (their colour came from uLight) while the sky around // moon-lit (their colour came from uLight) while the sky around
// them goes dark. The cloud mask 'cloud' tells us how much of // them goes dark. transmittance tells us how much light made it
// this pixel is cloud, so fully cloudy pixels keep their colour. // through the cloud layer (1 = clear, 0 = fully cloudy).
'float cloud = 1.0 - trans;',
'float skyDarkness = nightFactor * 0.85;', 'float skyDarkness = nightFactor * 0.85;',
'col = mix(col, col * (1.0 - skyDarkness), 1.0 - cloud);', 'col = mix(col, col * (1.0 - skyDarkness), 1.0 - cloud);',
'gl_FragColor = vec4(col, 1.0);', 'gl_FragColor = vec4(col, 1.0);',