Skip to main content

Light

Enum Light 

Source
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

Source

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.

Source

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.

Source

pub const fn sphere(&self) -> (Vec3, f32)

Where this light is and how far it reaches, for a caller that has to bound it — the clustering pass’s test, on the host.

Trait Implementations§

Source§

impl Clone for Light

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Light

Source§

impl Debug for Light

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for Light

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Light

Auto Trait Implementations§

§

impl Forget for Light

§

impl Freeze for Light

§

impl Move for Light

§

impl RefUnwindSafe for Light

§

impl Send for Light

§

impl Sync for Light

§

impl Unpin for Light

§

impl UnsafeUnpin for Light

§

impl UnwindSafe for Light

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> HalThreadSafe for T
where T: Send + Sync,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.