pub enum Light {
Point(PointLight),
Spot(SpotLight),
Rect(RectLight),
}Expand description
A light that lives somewhere, as distinct from the sun, which does not.
Three variants and one row: the shader loop shades all four kinds with one BRDF, which is topic 44’s “one material table, one BRDF, one set of inputs” holding by construction rather than by four copies of it agreeing.
Variants§
Point(PointLight)
Radiates equally in every direction, out to its radius.
Spot(SpotLight)
A point light with a cone over it.
Rect(RectLight)
A rectangle that radiates from one of its faces.
Implementations§
Source§impl Light
impl Light
Sourcepub const fn is_fill(&self) -> bool
pub const fn is_fill(&self) -> bool
Whether this light is a fill light: one that lights, casts no shadow and adds no specular.
A method on the enum rather than a match at each caller, so
shadow::Selection asks one question of a
light rather than three. Every kind carries the field and
PointLight::fill is where it is described.
Sourcepub fn row(&self, base_tile: Option<usize>) -> GpuLight
pub fn row(&self, base_tile: Option<usize>) -> GpuLight
This light as the row the shaders read, occluding through the light tiles
starting at base_tile.
The first tile, not the only one: a spot occludes through that tile
alone and a point light through the
POINT_FACES tiles from there, one per cube
face, which the shader selects between. shadow::Selection is what hands
the run out.
None is a light with no map of its own, which is the ordinary case: the
atlas holds shadow::LIGHT_TILES light
tiles and a scene may want more than they hold. Such a light still lights
and simply does not occlude — topic 45’s honest
degradation, and the reason the budget is a quality knob rather than a
correctness cliff.