Fix night sky: visible clouds, real moon-driven darkening
Three coordinated changes: 1. nightPaletteNew.cloud: void -> raised (slightly lighter than sky) so clouds have contrast against the new-moon sky 2. nightPaletteFull.cloudShadow: panel -> void so cloud undersides fade into the night sky, while the lit topsides (border) stand out clearly 3. getNightColor() now keeps 'light' (moonlight) bright and only partially darkens sky/bg. The previous version squashed everything toward black, killing cloud structure. Shader side: - max(0.15, uDayProgress) keeps a baseline moonlight tint on the lit side of clouds even when uDayProgress happens to be 0 - The final darken pass is now driven by nightFactor (sunAlt-based) instead of the unreliable uDayProgress
This commit is contained in:
1 parent
58f1ecbc61
commit
673ed6cf0f
3 files changed
+48
-35
No files matched your search
Vendored
+9
-6
@@ -141,12 +141,13 @@ var FRAG_SRC = [
|
||||
'float skyT = clamp(rd.y * 0.7 + 0.5, 0.0, 1.0);',
|
||||
'vec3 col = mix(uBg, uSky, skyT);',
|
||||
// Stars: hash-grid sphere, above horizon, only at night.
|
||||
// Night = sun altitude below 0. Visibility extends well into the
|
||||
// lower half of the sky so the airplane-cockpit view shows stars
|
||||
// from the horizon up.
|
||||
// Night = sun altitude below 0. Visibility extends well into the
|
||||
// lower half of the sky so the airplane-cockpit view shows stars
|
||||
// from the horizon up.
|
||||
'float nightFactor = smoothstep(0.05, -0.15, uSunAlt);',
|
||||
'float skyMask = smoothstep(-0.10, 0.30, rd.y);',
|
||||
'float stars = starField(rd) * skyMask * nightFactor;',
|
||||
// (nightFactor is also used below for the final darken pass.)',
|
||||
'col = mix(col, uLight, clamp(stars, 0.0, 1.0) * 0.9);',
|
||||
// Density threshold: weather 'sunny' -> high (sparse clouds),
|
||||
// 'stormy' -> low (overcast deck).
|
||||
@@ -169,7 +170,7 @@ var FRAG_SRC = [
|
||||
'float lit = clamp((p.y + 0.3) / 2.1, 0.0, 1.0);',
|
||||
'vec3 cloudCol = mix(uCloudShadow, uCloud, lit);',
|
||||
// Sun tint on the lit side, fades at night
|
||||
'cloudCol = mix(cloudCol, uLight, uDayProgress * 0.35 * lit);',
|
||||
'cloudCol = mix(cloudCol, uLight, max(0.15, uDayProgress) * 0.35 * lit);',
|
||||
'float alpha = clamp(d * stepSize * 0.9, 0.0, 1.0);',
|
||||
'col = mix(col, cloudCol, alpha * trans);',
|
||||
'trans *= (1.0 - alpha);',
|
||||
@@ -177,8 +178,10 @@ var FRAG_SRC = [
|
||||
'}',
|
||||
't += stepSize;',
|
||||
'}',
|
||||
// Night darkening
|
||||
'col = mix(col, mix(uBg, col, 0.4), (1.0 - uDayProgress) * 0.55);',
|
||||
// Night darkening — driven by sun altitude, not uDayProgress
|
||||
// (uDayProgress is the 0..1 clock progress through 24h, which
|
||||
// is not the same as 'is it night').
|
||||
'col = mix(col, mix(uBg, col, 0.4), nightFactor * 0.45);',
|
||||
'gl_FragColor = vec4(col, 1.0);',
|
||||
'}'
|
||||
].join('\n');
|
||||
|
||||
Reference in new issue
Block a user