#[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: f32Elapsed seconds, available to shaders for animation.
reflections_enabled: f321.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: f32Number 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: f321.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: f32End-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
impl Clone for ViewUniforms
Source§fn clone(&self) -> ViewUniforms
fn clone(&self) -> ViewUniforms
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more