Builtin Library
- ..
- README.md1.7 KB
- module.wgsl2.8 KB
README.md
frame_light
The scene's sun and ambient term as a render-feature pass reads them from the
@frame.light input: the light the surfaces of the drawn view are shaded by,
in the same frame. A participating medium lit through this module follows a
day cycle, a scripted sun and a switched-off one in the frame the surfaces do,
and goes black with them.
@frame.light is three vec4s:
| Word | Content |
|---|---|
[0] | the direction the sun's light travels (unit, world space), intensity in w |
[1] | the sun's colour, w 1 while it casts shadows |
[2] | the ambient colour, intensity in w |
# bindings.yaml
- { name: scene_light, kind: buffer, access: read, element: vec4<f32> }
ctx.enqueue { kind = "compute", program = prog, inputs = { scene_light = "@frame.light" }, ... }
#include "@builtin::shaderModules.frame_light"
let light = zero_frame_light(scene_light[0], scene_light[1], scene_light[2]);
let sun = zero_frame_light_sun_tint(light) * authored_sun_brightness;
let toward_sun = zero_frame_light_toward_sun(light);
zero_frame_light_sun_share is the share of a medium's authored brightness the
scene's sun lights: its intensity up to a unit sun, and 1 from there up. A
weaker sun dims the medium in proportion and a sun at 0 lights none of it.
zero_frame_light_sun_irradiance is the sun's light as the surfaces take it
(colour times intensity), in the units the scene's other lights (@scene.lights)
are stated in: a medium that scatters those as well takes the sun this way, so
the sun and the lights keep the balance they have on the surfaces.
light.ambient is the flat ambient irradiance (colour times intensity).
Pure math, no bindings.