J
Posted on Oct 30
Edited on Oct 30
It’s time to bring depth and atmosphere into our scene through Dynamic Lighting. In a typical rendering pipeline, lighting also works closely with shadows.
The light types I am aiming for are:
Point Light
Directional Light
Spot Light
HDRI Light Analytical lights (point, directional, and spot) use uniform buffer data. In contrast, HDRI lighting is image-based (IBL) and requires a cubemap texture ( texture_cube<f32> ) and sampler rather than a standard uniform buffer.
Rust Implementation: lighting.rs
In lighting.rs , we create a unified structure to upload the light parameters to the GPU:
light_type (identifying which mode to evaluate)
direction
inner_cone and outer_cone (for spot light boundaries)
color, rangle, intensity (basic things about light)
Just like we did for the depth buffer and post-processing passes, we create a GPU buffer to hold the light information, construct a bind group layout and bind group, and instantiate the light controller in the…