Skip to main content

Material

Struct Material 

Source
pub struct Material {
Show 14 fields pub asset_id: AssetId, pub albedo: Option<TextureHandle>, pub normal_map: Option<TextureHandle>, pub emissive_map: Option<TextureHandle>, pub orm_map: Option<TextureHandle>, pub roughness: f32, pub metallic: f32, pub tint: [f32; 3], pub emissive_factor: [f32; 3], pub alpha_cutoff: f32, pub opacity: f32, pub transparent: bool, pub see_through: bool, pub shader: Option<ShaderHandle>,
}
Expand description

A Material bundles the surface parameters that control how a Prop is lit and shaded.

Reference it from a Prop’s material field. The material field takes precedence over the older texture field.

Material {
    roughness: 0.85,
    metallic: 0.0,
    ..Default::default()
};

Fields§

§asset_id: AssetId

Asset identity; injected via inject_name. Not part of args.

§albedo: Option<TextureHandle>

The Texture asset used as the base colour (albedo) map.

§normal_map: Option<TextureHandle>

The Texture asset used as a tangent-space normal map.

§emissive_map: Option<TextureHandle>

The Texture asset used as an emissive map. Multiplied by emissive_factor to drive the glow; when omitted, only the scalar emissive_factor is used. Pair a textured emissive with an emissive_factor above 1 to make the bright parts bloom.

§orm_map: Option<TextureHandle>

The Texture asset used as a packed surface map: green = roughness, blue = metalness. When present it overrides the scalar roughness and metallic per-texel; when omitted those scalars are used. The red channel is reserved and not read as ambient occlusion: packed maps in the wild (glTF metallic-roughness, FBX specular maps) leave red empty, so treating it as occlusion would darken indirect light to black. Ambient occlusion comes from the screen-space pass.

§roughness: f32

Perceptual roughness in [0, 1]. 0 = mirror, 1 = fully diffuse. Controls the width of the specular highlight.

§metallic: f32

Metallic factor in [0, 1]. 0 = dielectric (plastic/stone), 1 = metal. Metallic surfaces tint their reflections with the albedo colour and show almost no diffuse; dielectrics keep a neutral, dim reflection.

§tint: [f32; 3]

Linear-space RGB multiplier applied to the albedo sample. Useful for tinting a shared texture without a separate asset (e.g. coloured brick).

§emissive_factor: [f32; 3]

Additive emission colour in linear space. Non-zero values make the surface appear to glow independently of the scene lighting.

§alpha_cutoff: f32

Alpha-cutout threshold in [0, 1]. When non-zero, a texel whose albedo alpha falls below it is discarded outright, punching a hole in the surface: this is how foliage, chain-link, and decal cards are drawn as one opaque quad. 0 (the default) disables the test and keeps every texel. Cutout is not glass: the surface still renders in the opaque pass, so leave transparent and see_through off.

§opacity: f32

Surface opacity in [0, 1]. 1 = fully opaque (the default). Only meaningful when transparent is set: it drives how much of the scene behind the surface shows through the glass.

§transparent: bool

When true, the surface is a translucent dielectric (glass): it renders in the engine’s transparent pass instead of the opaque pass, refracting and reflecting the scene rather than writing solid colour + depth. The importer sets this for materials it detects as glass; authored materials can opt in directly. Defaults to false (opaque).

§see_through: bool

When true, the glass is rendered as genuinely see-through: the scene behind it shows through with a sharp per-pixel reflection (requires a ray-tracing-capable GPU). When false (the default), a transparent surface still renders as low-roughness reflective glass that hides whatever is behind it. See-through only looks right when the space behind the glass is actually modelled, so it is opt-in per material. Setting it implies transparent.

§shader: Option<ShaderHandle>

The Shader asset that shades surfaces using this material. When omitted, the world’s default shader is used. Referencing a shader from a material ties that shader’s lifetime to the material’s: a shader referenced only by scene-exclusive materials loads and unloads with the scene.

Trait Implementations§

Source§

impl Clone for Material

Source§

fn clone(&self) -> Material

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 Debug for Material

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Material

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Material

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl ResourceAsset for Material

Source§

impl Serialize for Material

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

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.