Skip to main content

Material

Trait Material 

Source
pub trait Material:
    Asset
    + AsAny
    + MaterialClone {
Show 13 methods // Provided methods fn base_color(&self) -> LinearRgba { ... } fn emissive_color(&self) -> LinearRgba { ... } fn specular_power(&self) -> f32 { ... } fn ambient_color(&self) -> LinearRgba { ... } fn metallic(&self) -> f32 { ... } fn roughness(&self) -> f32 { ... } fn base_color_texture(&self) -> Option<AssetUUID> { ... } fn metallic_roughness_texture(&self) -> Option<AssetUUID> { ... } fn normal_map(&self) -> Option<AssetUUID> { ... } fn emissive_texture(&self) -> Option<AssetUUID> { ... } fn occlusion_map(&self) -> Option<AssetUUID> { ... } fn alpha_mode(&self) -> AlphaMode { ... } fn double_sided(&self) -> bool { ... }
}
Expand description

A trait for types that can be used as a material.

A material defines the surface properties of an object being rendered, influencing how it interacts with light and determining which shader (RenderPipeline) is used to draw it.

Provided Methods§

Source

fn base_color(&self) -> LinearRgba

Returns the base color (albedo or diffuse) of the material. Default implementation is White.

Source

fn emissive_color(&self) -> LinearRgba

Returns the emissive color of the material. Default implementation is Black.

Source

fn specular_power(&self) -> f32

Returns the specular power or roughness conversion for the material. Default implementation is 32.0.

Source

fn ambient_color(&self) -> LinearRgba

Returns the ambient color modifier for the material. Default implementation is (0.1, 0.1, 0.1, 0.0).

Source

fn metallic(&self) -> f32

Returns the metallic factor (0.0 = dielectric, 1.0 = metal). Default implementation is 0.0.

Source

fn roughness(&self) -> f32

Returns the roughness factor (0.0 = smooth, 1.0 = rough). Default implementation is 1.0.

Source

fn base_color_texture(&self) -> Option<AssetUUID>

Returns the UUID of the base-color (albedo) texture, if any. Default implementation is None (untextured).

Source

fn metallic_roughness_texture(&self) -> Option<AssetUUID>

Returns the UUID of the metallic-roughness texture, if any (glTF convention: B=metallic, G=roughness). Default implementation is None.

Source

fn normal_map(&self) -> Option<AssetUUID>

Returns the UUID of the tangent-space normal map, if any. Default implementation is None.

Source

fn emissive_texture(&self) -> Option<AssetUUID>

Returns the UUID of the emissive texture, if any. Default implementation is None.

Source

fn occlusion_map(&self) -> Option<AssetUUID>

Returns the UUID of the ambient-occlusion map, if any (red channel). Attenuates the indirect (ambient/IBL) term only, never direct light. Default implementation is None.

Source

fn alpha_mode(&self) -> AlphaMode

Returns the material’s alpha (transparency) mode. For AlphaMode::Mask the contained value is the alpha-cutoff threshold: fragments below it are discarded. Default implementation is AlphaMode::Opaque.

Source

fn double_sided(&self) -> bool

Whether the material is rendered double-sided (back faces not culled). false (the default) culls back faces for correctly-wound meshes.

Trait Implementations§

Source§

impl Clone for Box<dyn Material>

Source§

fn clone(&self) -> Self

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 Asset for Box<dyn Material>

This is the key to our type-erased material handle system. We explicitly tell the compiler that a boxed, dynamic Material trait object can itself be treated as a valid Asset. This allows it to be stored inside an AssetHandle.

Implementors§