Skip to main content

Material

Struct Material 

Source
pub struct Material {
Show 19 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 macro_variation: f32, pub terrain_blend: f32, pub albedo_secondary: Option<TextureHandle>, pub normal_secondary: Option<TextureHandle>, pub secondary_blend_sharpness: f32, 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.

§macro_variation: f32

Macro-variation strength in [0, 1]. When non-zero, a large-scale, world-space noise modulates the albedo so a tiled texture on a big surface (terrain, floors) stops reading as an obvious repeating grid. 0 disables it.

§terrain_blend: f32

Terrain-shading blend in [0, 1]. When non-zero, the albedo and normal are sampled by a world-space projection blended from the three world axes (instead of a single UV lookup), and the surface shifts toward a darker rocky tint on steep slopes. This removes the obvious UV-stretch banding that heightfield ground shows when stretched across a big mesh, and gives “grass on top, rock on the cliffs” variation for free. 0 disables it.

§albedo_secondary: Option<TextureHandle>

Optional second albedo Texture for the slope-based terrain blend. When present, the steep / cliff regions sample this texture and blend with the primary albedo over the flat regions, using the surface’s up-facing component (softened by a per-pixel noise so the transition doesn’t read as a clean line). Without it, a rocky-tint multiplier is applied to the primary texture instead. Only used when terrain_blend > 0.

§normal_secondary: Option<TextureHandle>

Tangent-space normal map paired with albedo_secondary. Only used when both that field and terrain_blend are set.

§secondary_blend_sharpness: f32

Sharpness of the slope-based blend in [0, 1]. 0 = wide soft gradient between the two layers; 1 = nearly hard cliff edge. Default 0.5 matches the “smooth but visible” transition AAA terrain materials typically tune to.

§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<(), Error>

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

impl Default for Material

Source§

fn default() -> Material

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

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

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Material, <__D as Deserializer<'de>>::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 as Serializer>::Ok, <__S as Serializer>::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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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<S, T> Duplex<S> for T
where T: FromSample<S> + ToSample<S>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

fn from_sample_(s: S) -> S

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<R, P> ReadPrimitive<R> for P
where R: Read + ReadEndian<P>, P: Default,

Source§

fn read_from_little_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_little_endian().
Source§

fn read_from_big_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_big_endian().
Source§

fn read_from_native_endian(read: &mut R) -> Result<Self, Error>

Read this value from the supplied reader. Same as ReadEndian::read_from_native_endian().
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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> ToSample<U> for T
where U: FromSample<T>,

Source§

fn to_sample_(self) -> U

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more