Skip to main content

DirectionalLight

Struct DirectionalLight 

Source
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: Vec3

Direction 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: Vec3

Colour premultiplied by intensity. May exceed 1.0 — the scene target is Rgba16Float precisely so that it can.

§ambient: Vec3

Flat ambient term. A real irradiance probe is P7’s.

Trait Implementations§

Source§

impl Clone for DirectionalLight

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 DirectionalLight

Source§

impl Debug for DirectionalLight

Source§

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

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

impl Default for DirectionalLight

Source§

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 Rgba16Float scene target carry something an Rgba8 one could not, and it is what crcbl-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.

Source§

impl PartialEq for DirectionalLight

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 DirectionalLight

Auto Trait Implementations§

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.