pub struct DirectionalLight {
pub direction: Vec3,
pub color: Vec3,
pub ambient: Vec3,
}Expand description
A directional light: the whole of milestone 4’s lighting model.
One light, no shadows, no attenuation. Stage 2’s rung
4 is “single directional light, Lambert+Blinn — enough to see geometry
properly; real material model comes with stage 3/5”, and cascaded shadow maps
are explicitly P7 (topic 18). The real material model arrived: mesh.slang
shades with a Cook-Torrance GGX lobe against a glTF metallic-roughness row,
and the rung’s Blinn wording is what it replaced.
Fields§
§direction: Vec3Direction towards the light, in render space. Normalised on the way into the uniform block.
Towards, not “the direction the light travels”: that is the vector both the Lambert term and the specular lobe’s half-vector want, and storing the other one means every consumer negates it and one of them eventually forgets.
color: Vec3Colour premultiplied by intensity. May exceed 1.0 — the scene target
is Rgba16Float precisely so that it can.
ambient: Vec3Flat ambient term. A real irradiance probe is P7’s.
Trait Implementations§
Source§impl Clone for DirectionalLight
impl Clone for DirectionalLight
impl Copy for DirectionalLight
Source§impl Debug for DirectionalLight
impl Debug for DirectionalLight
Source§impl Default for DirectionalLight
impl Default for DirectionalLight
Source§fn default() -> Self
fn default() -> Self
A warm key light over the viewer’s right shoulder, with headroom.
Two of the three numbers here are deliberate rather than aesthetic:
- The direction has a positive X, so it comes from the same side as the default camera rather than from behind the geometry that camera can see. A light pointing away from every visible face renders a technically correct picture of an unlit cube, which is a confusing first result and was in fact P1.3’s first result.
- The intensity is above 1.0, so the brightest lit surface exceeds
what the swapchain can hold. That is what makes the
Rgba16Floatscene target carry something anRgba8one could not, and it is whatcrcbl-vk’s e2e suite reads back to prove HDR-from-P1 is a pipeline rather than a format enum. A key light brighter than the display is also simply what daylight is.
The ambient is small but non-zero, so a face turned away from the light is dark rather than black.