Skip to content

Light the valley fog by the sky and the sun - #324

Merged
fredj merged 2 commits into
masterfrom
valley-fog-light
Nov 19, 2026
Merged

fredj merged 2 commits into
masterfrom
valley-fog-light

Conversation

@fredj

@fredj fredj commented Nov 19, 2026

Copy link
Copy Markdown
Member

ValleyFog mixed the scene toward one flat color whatever the sun's direction; fog looked at toward a low sun is much brighter than away from it. It is now lit by the light it scatters.

  • ValleyFog: the fog's color tinted by Cesium's clear sky toward the view, plus the sun's light (in its hue through the air) scattered forward in a Henyey-Greenstein lobe (g 0.8), cut by the clouds' shadow map a mean free path into the fog when Clouds is active. New option lighting, 0 to 1, 1 by default: this changes the look of existing fog; 0 keeps the flat color and draws no sky table. Pixels without fog skip the work.
  • Refactor (first commit): the sky table Precipitation drew moves to sky-table.js, the clouds' shadow uniforms to cloud-cover.js's cloudShadowUniforms; the haze and the fog share scatteredLight in RainHaze.glsl.
  • Post-process demo: a "Lit by the sky and the sun" slider.

Tested: npm test (new valley-fog and cloud-cover tests), typecheck, build, build-demos. Post-process demo, sun 7 degrees high, mean of the lower half of the frame: toward the sun 144/151/165 flat, 161/167/177 lit; away 129/136/147 flat, 123/137/154 lit (bluer). Frame time unchanged, 15.2 to 15.4 ms at 1201 x 647.

Not checked in a browser: the fog under Clouds (no demo has both). Known limits left: the fog's entry point treats the top as flat, so on grazing rays from high above the shadow may be read just above the fog; the sky table is drawn in preRender, a frame behind after a jump (as Precipitation's was); the table uses Cesium's Texture/Framebuffer, as Precipitation and Clouds already do.

…adow uniforms

Precipitation drew the clear sky its haze scatters into a small table at
each frame, and wired the clouds' shadow map into its shafts; sky-table.js
and cloud-cover.js's cloudShadowUniforms now do, for ValleyFog to light
its fog by the same sky and through the same clouds.
ValleyFog mixed the scene toward one flat color whatever the sun's
direction, where fog looked at toward a low sun is much brighter than
away from it. Its light is now the light it scatters: its color tinted
by Cesium's clear sky toward the view, from the sky table the rain's haze
reads, and the sun's light, in its hue through the air as it lights the
clouds, scattered forward in a Henyey-Greenstein lobe of asymmetry 0.8,
through the clouds' shadow map a mean free path into the fog when Clouds
is active. The `lighting` option, 1 by default, sets how much; 0 keeps
the flat color and draws no sky table. Pixels without fog skip it.

The haze and the fog share scatteredLight; the sky table takes its height
once. The density keeps its ramp under the top: a valley fog fills the
valley to its floor.

closes TASK-7
@fredj
fredj marked this pull request as ready for review November 19, 2026 20:25
@fredj
fredj merged commit c5f615b into master Nov 19, 2026
1 check passed
@fredj
fredj deleted the valley-fog-light branch November 19, 2026 20:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant