#[repr(C)]pub struct MaterialUniforms {Show 16 fields
pub roughness: f32,
pub metallic: f32,
pub macro_variation: f32,
pub terrain_blend: f32,
pub tint: [f32; 3],
pub _pad2: f32,
pub emissive: [f32; 3],
pub secondary_blend_sharpness: f32,
pub albedo_secondary_index: u32,
pub normal_secondary_index: u32,
pub emissive_map_index: u32,
pub orm_map_index: u32,
pub alpha_cutoff: f32,
pub opacity: f32,
pub transparent: u32,
pub see_through: u32,
}Expand description
Per-draw-call material parameters pushed to the fragment shader at buffer(3).
Must stay in sync with the MaterialUniforms struct in every .metal shader.
Fields§
§roughness: f32Perceptual roughness [0, 1]: 0 = mirror, 1 = fully diffuse.
metallic: f32Metallic factor [0, 1]: 0 = dielectric, 1 = metal.
macro_variation: f32Macro-variation strength [0, 1]; 0 disables the tiling-break noise.
terrain_blend: f32Terrain-shading blend [0, 1]; 0 disables (default PBR sampling),
non-zero switches the shader to a triplanar world-space projection
with slope-based rocky-tint blending. See Material::terrain_blend.
tint: [f32; 3]Linear-space RGB multiplier on the albedo sample.
_pad2: f32Padding so the field layout matches the shader-side struct.
emissive: [f32; 3]Additive emission colour in linear space.
secondary_blend_sharpness: f32Sharpness of the slope-based blend between the primary and the
albedo_secondary texture pair. 0 = wide soft gradient;
1 = nearly hard cliff edge. Ignored unless both terrain_blend > 0
and the secondary texture pair is bound.
albedo_secondary_index: u32Index into the per-draw albedo texture (legacy path) or the
bindless texture pool (bindless path) for the slope-shaded
secondary albedo. 0 is also the fallback when the material
doesn’t declare a secondary texture; the shader’s
terrain_blend > 0 && secondary_blend_sharpness > 0 gate keeps
it from being sampled in that case.
normal_secondary_index: u32Companion to albedo_secondary_index for the slope-shaded
secondary normal map.
emissive_map_index: u32Bindless-pool index for the emissive map. 0 means no map: the shader
gates on a non-zero index, falling back to the scalar emissive factor.
orm_map_index: u32Bindless-pool index for the packed occlusion/roughness/metalness map
(R = occlusion, G = roughness, B = metalness). 0 means no map: the
shader keeps the scalar roughness/metallic and full occlusion.
alpha_cutoff: f32Alpha-cutout threshold in [0, 1]; 0 disables the test. Non-zero makes the fragment shader discard any texel whose albedo alpha falls below it, which is how foliage and decal cards punch holes while staying in the opaque pass.
opacity: f32Base surface opacity in [0, 1]; 1 = fully opaque (the default). Only
meaningful with transparent: it drives the glass alpha in the
transparent pass. Carried on the material so it rides Material ->
DrawObject.material to the backend; the opaque main-pass shader ignores it.
transparent: u321 when this surface routes through the transparent pass instead of the opaque one (a glass MESH on an RT-capable device); 0 for opaque. A CPU routing flag: the backend reads it to skip the draw in the opaque pass + the RT BLAS and to feed the per-pixel-RT transparent producer. No GPU shader reads it (the opaque skip is decided CPU-side).
see_through: u321 when a transparent glass MESH renders as genuinely see-through (Layer
2: the scene behind shows through plus a sharp per-pixel reflection); 0
keeps it as opaque low-roughness reflective glass (Layer 1). Another CPU
routing flag (no GPU shader reads it): the see-through producer, the
opaque-pass skip, and the RT-BLAS exclude all key off it, so Layer 2 is
opt-in per material. Always 0 unless transparent is also 1.
Implementations§
Source§impl MaterialUniforms
impl MaterialUniforms
Sourcepub const DEFAULT: MaterialUniforms
pub const DEFAULT: MaterialUniforms
Neutral material: matte, non-metallic, white tint, no emission.
Trait Implementations§
Source§impl Clone for MaterialUniforms
impl Clone for MaterialUniforms
Source§fn clone(&self) -> MaterialUniforms
fn clone(&self) -> MaterialUniforms
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more