Skip to main content

ViewUniforms

Struct ViewUniforms 

Source
#[repr(C)]
pub struct ViewUniforms { pub vp: [[f32; 4]; 4], pub view: [[f32; 4]; 4], pub elapsed: f32, pub reflections_enabled: f32, pub cam_pos: [f32; 3], pub prefilter_mip_count: f32, pub shade_mode: f32, pub _end_pad: f32, pub sky_rot: [[f32; 4]; 3], }
Expand description

Per-frame view-projection uniforms, uploaded once per frame and shared across every draw in it. view is the standalone view matrix the vertex shader uses to compute view-space depth for cascade selection in the fragment shader.

The .slang source declares the same bytes with its own spelling (view_mat, and cam_x/cam_y/cam_z in place of cam_pos), which is why the two are checked as byte ranges rather than by name.

Fields§

§vp: [[f32; 4]; 4]

Combined view-projection matrix (column-major).

§view: [[f32; 4]; 4]

Camera view matrix (column-major). Used to compute view-space depth in the vertex shader for shadow cascade selection.

§elapsed: f32

Elapsed seconds, available to shaders for animation.

§reflections_enabled: f32

1.0 when a screen-space / ray-traced reflection resolve composites this frame, else 0.0. The forward fragment shader uses it to yield the sharp specular for glossy surfaces to that resolve (whose miss-fallback samples the same probe set), so a glossy surface does not show both the parallax-approximate forward probe reflection and the exact resolved one.

§cam_pos: [f32; 3]

World-space camera position (packed_float3 in the MSL contract, alignment 4).

§prefilter_mip_count: f32

Number of mip levels in the bound IBL prefilter cubemap. 0 means “no EnvironmentMap bound”: the fragment shader uses this as the IBL enable flag and falls back to a flat ambient placeholder.

§shade_mode: f32

1.0 while the unlit view mode is active: shade_surface returns the base color before lighting. Occupies what was pad space, so the offsets in the user-shader binding contract are unchanged.

§_end_pad: f32

End-padding: the shader rounds the block up to a multiple of float4x4’s 16-byte alignment, so the upload rounds explicitly to match.

§sky_rot: [[f32; 4]; 3]

Rows of the rotation that takes a world-space direction into the environment cubemaps’ baked frame: the inverse of the sky’s current rotation (SkyOrientation::sample_rows), identity when the world declares no SkyRotation. Every cubemap sample helper applies it, so the sky, the ambient fill and the glossy reflections turn together. One float4 per row; w is unused.

Trait Implementations§

Source§

impl Clone for ViewUniforms

Source§

fn clone(&self) -> ViewUniforms

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 ViewUniforms

Source§

impl NoUninit for ViewUniforms

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, 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.