Builtin Library
- ..
- README.md2.5 KB
- module.wgsl8.3 KB
README.md
cloud_light
The light the cloud layer is lit by, and the air it is seen through, read by the cloud raymarcher.
With the scene's physical atmosphere (PhysicalAtmosphere; the raymarch's
U[28] is 1) the clouds stand in that air:
cloud_sun_dir(),cloud_sun_radiance()— the atmosphere's sun, its direction, colour and brightness, scaled by the preset's sun colour and brightness.cloud_sun_through_air(offset, alt0, radius, sun_dir, zenith_sun)— the share of that sun reaching a sample through the air, against what a sun overhead gives there (cloud_zenith_sun(altitude)): white at noon, gold and red as the sun sinks, fading out over the sun's width once the planet stands between the sample and the sun. A cloud high in the layer keeps the sun a little after the ground has lost it, lit from below.cloud_sky(cam_pos, sun_dir)— the sky around the clouds as the physical sky draws it: its zenith, its horizon away from the sun (the sky a cloud's shade faces), the sunlit ground under the air, and the light from every side (the mean of the zenith and the horizon, in the proportion the preset'sambientholds to the mean of the preset's own horizon and zenith).cloud_through_air(cam_pos, dir, distance, light, coverage)— a cloud's light as it reaches the camera through the air between them, the way the aerial perspective hazes a surface: the raymarch applies it at the cloud's mean depth on a ray over the sky, so distant clouds fade into the haze at the horizon.
Without one, the clouds take the scene's own sun (@frame.light, through
@builtin::shaderModules.frame_light) and the preset's sky colours, which are
the sky of a high sun: cloud_sky scales them by cloud_sky_share() (the
sun's share, times the daylight its height gives: all of it from about 20
degrees up, none once it is about 6 degrees under the horizon), and the air
terms pass the light through unchanged.
A sunset lights the clouds low and warm, a night leaves them dark, and with the sun at zero the layer is black.
The including shader binds scene_light (@frame.light), the uniform U
with its u_vec3 reader, and the atmosphere's atmo_params,
transmittance_lut, multiscatter_lut and skyview_lut, and includes
@builtin::shaderModules.frame_light and the atmosphere's atmo_common,
atmo_transmittance_lookup, atmo_multiscatter_lookup, atmo_integrator and
atmo_skyview_lookup ahead of this module.