Skip to main content

ViewLighting

Enum ViewLighting 

Source
pub enum ViewLighting {
    Scene,
    Fixed {
        key: DirectionalLight,
        environment: Vec3,
    },
}
Expand description

What lights a view’s surfaces — see ViewDesc::lighting.

Variants§

§

Scene

The frame’s own light: the sun and every light row ForwardRenderer::set_lights handed over, the sky’s irradiance, the irradiance probes, the reflections and the fog. What the primary camera is lit by, and what every view was lit by before this choice existed.

§

Fixed

One constant light, whatever the frame is lit by: the key’s direction and colour as the only direct light, its ambient as the only diffuse indirect one, and environment as the only thing a reflection sees.

For a picture that must not change with the world around it, such as a model rendered into an inventory icon: the same model under the same fixed light draws the same pixels in a sunlit level and a dark one.

§What it ignores

  • The frame’s sun and every light row — a point, spot or rectangle light near the view’s camera included. The key light is the view’s one row, which is a choice rather than a limit: an icon’s model is placed away from the world, so a local light that did reach it would be lighting it by accident.
  • Every shadow. The key light is not occluded — not by the frame’s cascades, which were fitted to the primary camera and cover whatever happens to be there, and not by contact shadows. The view’s frame block names no shadow map: every atlas rectangle in it is empty, which the shaders read as a map never rendered and answer lit. The frame’s atlas is still drawn and the view’s instances may still cast into it; see ForwardRenderer::set_instance_casts_shadow.
  • The sky and the irradiance probes: the view’s frame block carries no sky rows and an empty probe header, and the view binds a probe table of one zeroed row in place of the scene’s — to the forward pass, the reflection march and the water surface alike — so the diffuse ambient is the fill alone and a reflection that finds no geometry sees environment alone.
  • The air: Self::SCENE_EFFECTS are dropped from the view’s effects whatever ViewDesc::effects asked for, and the height fog is Fog::NONE.

What it keeps is everything the view’s own geometry decides: its materials and emission, its ambient occlusion, its reflections of itself, and every effect after the forward pass. The background is ViewDesc::background’s, so a view asking for ViewBackground::Scene still draws the frame’s sky behind a model it does not light.

Fields

§key: DirectionalLight

The one direct light, and in its ambient the diffuse fill.

§environment: Vec3

The radiance a reflection sees in every direction — a uniform environment, in linear RGB, that may exceed 1.0 like the key’s colour. It is what gives a dark glossy surface its sheen: a near-black dielectric scatters almost none of the key and the fill, and still reflects this at its F0, rising towards grazing angles by the split-sum Fresnel term — so what the camera sees edge-on reads brighter than what faces it. A metal reflects it tinted by its base colour.

Specular only. A uniform environment of radiance L would also reach a diffuse surface, as π·L — what Self::Scene adds for a uniform crate::Sky of that radiance — but here that half is the key’s ambient and nothing else, so the two are never summed and the fill means what it meant before this field existed. A caller who wants the pair to describe one physical environment sets ambient to π times this.

It reaches a surface through the reflection pass, so it needs RenderEffects::REFLECTIONS in both the frame’s effects and ViewDesc::effects; a view drawn without it reflects nothing. Zero is a view whose reflections find nothing but its own geometry.

Implementations§

Source§

impl ViewLighting

Source

pub const SCENE_EFFECTS: RenderEffects

The effects a ViewLighting::Fixed view never draws, because each brings the frame’s light into it: the froxel volume is lit by the sun and the scene’s lights, and the contact march shadows along the frame’s sun.

Reflections are not among them. The march’s fallback is the probe table and the sky rows, and a fixed view hands it its own — the zeroed row and a sky of environment in every direction — so what it reflects is the view’s own geometry and the fixed environment.

Trait Implementations§

Source§

impl Clone for ViewLighting

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 ViewLighting

Source§

impl Debug for ViewLighting

Source§

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

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

impl Default for ViewLighting

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl PartialEq for ViewLighting

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 ViewLighting

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.