Skip to main content

Sky

Struct Sky 

Source
pub struct Sky {
    pub zenith: Vec3,
    pub horizon: Vec3,
    pub ground: Vec3,
}
Expand description

A gradient sky: three radiances, and the environment they light with.

Topic 43 §8. The sky is a smoothstep blend from ground through horizon to zenith in a direction’s y, and what reaches the scene is that field projected onto the L1 spherical-harmonic basis the irradiance grid already speaks — so a surface facing up is lit by the sky and one facing down by the ground, from three colours and no extra pass.

It is added to the flat ambient and to the probe grid, not chosen between them, because all three are the same term: what a diffuse surface receives from an environment it is not looking at directly. An author who wants the sky to be the whole of the environment sets DirectionalLight::ambient to zero.

Sky::NONE is the default and is exactly no sky. A black gradient projects to coefficients that are all zero, so the three dot products the fragment stage adds are zero, and every golden blessed before a sky existed still matches.

Nothing draws the sky yet — this lights with it, and the background is still the scene target’s clear colour. ForwardRenderer::set_sky is what a caller hands this to, and crcbl_shaders::sky is the projection.

Fields§

§zenith: Vec3

Radiance straight up.

May exceed 1.0, like DirectionalLight::color and Fog::color and for their reason: the scene target is Rgba16Float and this is a radiance rather than a display colour.

§horizon: Vec3

Radiance at the horizon, where a direction’s y is zero.

The band both hemispheres blend away from, so it carries more weight in the ambient than either pole does.

§ground: Vec3

Radiance straight down — the ground’s bounce, not the ground itself.

This engine traces nothing to find it, so it is an author’s estimate of what the surface below sends back up.

Implementations§

Source§

impl Sky

Source

pub const NONE: Self

No sky, which is what a renderer nobody has called ForwardRenderer::set_sky on carries.

Black in every direction, and its projection is every coefficient zero, so it adds nothing rather than nearly nothing.

Trait Implementations§

Source§

impl Clone for Sky

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 Sky

Source§

impl Debug for Sky

Source§

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

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

impl Default for Sky

Source§

impl PartialEq for Sky

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 Sky

Auto Trait Implementations§

§

impl Forget for Sky

§

impl Freeze for Sky

§

impl Move for Sky

§

impl RefUnwindSafe for Sky

§

impl Send for Sky

§

impl Sync for Sky

§

impl Unpin for Sky

§

impl UnsafeUnpin for Sky

§

impl UnwindSafe for Sky

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.