#[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,
}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 field names are a published contract. A world-authored Metal shader
declares its own ViewUniforms and binds it at Metal buffer(0); the runtime
validator (metal::shader_layout) compares that declaration against this
struct field by field, by name. Renaming one here rejects every world shader
that spells it the old way. 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.
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