Skip to main content

MaterialUniforms

Struct MaterialUniforms 

Source
#[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: f32

Perceptual roughness [0, 1]: 0 = mirror, 1 = fully diffuse.

§metallic: f32

Metallic factor [0, 1]: 0 = dielectric, 1 = metal.

§macro_variation: f32

Macro-variation strength [0, 1]; 0 disables the tiling-break noise.

§terrain_blend: f32

Terrain-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: f32

Padding so the field layout matches the shader-side struct.

§emissive: [f32; 3]

Additive emission colour in linear space.

§secondary_blend_sharpness: f32

Sharpness 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: u32

Index 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: u32

Companion to albedo_secondary_index for the slope-shaded secondary normal map.

§emissive_map_index: u32

Bindless-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: u32

Bindless-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: f32

Alpha-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: f32

Base 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: u32

1 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: u32

1 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

Source

pub const DEFAULT: MaterialUniforms

Neutral material: matte, non-metallic, white tint, no emission.

Trait Implementations§

Source§

impl Clone for MaterialUniforms

Source§

fn clone(&self) -> MaterialUniforms

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 MaterialUniforms

Source§

impl NoUninit for MaterialUniforms

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, <T as TryFrom<U>>::Error>

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.