Expand description
Converts drained DirectionalLight, PointLight, SpotLight, and RectAreaLight asset components into the GPU data the renderer consumes: the fixed LightUniforms uniform (directional lights, ambient, and the legacy point array the raymarch / fog / probe paths read), the GpuLight storage buffer the clustered forward pass iterates, the per-slice spot shadow projections, and the rect area-light extents.
Structs§
- Directional
Light Set - A frame’s directional lights, held inline at the shader’s capacity so a
frame can carry them without allocating. Extras past
MAX_DIRECTIONAL_LIGHTSare dropped, exactly asdirectional_light_datadrops them. - Light
Data - The per-scene GPU light data: the storage buffer the clustered forward pass
iterates, plus the side tables it indexes into. Kept together because
GpuLight.shadow_indexindexesspot_shadowsandGpuLight.data_indexindexesarea_lights– invariants that would be easy to break if the three were built independently.
Functions§
- build_
light_ data - Packs point, spot, and rect area lights into the GpuLight storage buffer and assigns their side-table slots. All three share the MAX_LOCAL_LIGHTS budget (not the 8-entry LightUniforms array); extras past the cap are dropped with a warning. Unused fields stay at their neutral GpuLight::ZERO values, so a point light carries no cone, shadow, or area data.
- build_
light_ uniforms local_lightsis the bufferbuild_light_dataproduced; its length is the authoritativenum_local_lightsthe forward pass iterates.- directional_
light_ data - The
LightUniformsdirectional slots and their count forlights, padded with zeroed entries. Shared by the init-time build below and the livecrate::render::backend::RenderBackend::update_directional_lightsseam, so a sun edited at runtime packs exactly as a relaunch would pack it. - glint_
sun - The
sun_dir/sun_colorlanes the transparent pass carries for its specular glint: the unit direction toward the first directional light and that light’s intensity-weighted colour. Both lanes are zero when the world declares no directional light, or when the one it declares has no direction, so the glint disappears rather than falling back to the neutral sunsun_colorhands the fog. - sun_
color - The intensity-weighted colour of the sun
sun_directionnames, white when the world declares no directional light. - sun_
direction - The direction the cascade shadow projection and the fog ray-march follow: the first declared directional light, or the neutral sun a world with none falls back to. Backends cache this at init and re-derive it when the light set changes.