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§
Sourcefn base_color(&self) -> LinearRgba
fn base_color(&self) -> LinearRgba
Returns the base color (albedo or diffuse) of the material. Default implementation is White.
Sourcefn emissive_color(&self) -> LinearRgba
fn emissive_color(&self) -> LinearRgba
Returns the emissive color of the material. Default implementation is Black.
Sourcefn specular_power(&self) -> f32
fn specular_power(&self) -> f32
Returns the specular power or roughness conversion for the material. Default implementation is 32.0.
Sourcefn ambient_color(&self) -> LinearRgba
fn ambient_color(&self) -> LinearRgba
Returns the ambient color modifier for the material. Default implementation is (0.1, 0.1, 0.1, 0.0).
Sourcefn metallic(&self) -> f32
fn metallic(&self) -> f32
Returns the metallic factor (0.0 = dielectric, 1.0 = metal). Default implementation is 0.0.
Sourcefn roughness(&self) -> f32
fn roughness(&self) -> f32
Returns the roughness factor (0.0 = smooth, 1.0 = rough). Default implementation is 1.0.
Sourcefn base_color_texture(&self) -> Option<AssetUUID>
fn base_color_texture(&self) -> Option<AssetUUID>
Returns the UUID of the base-color (albedo) texture, if any.
Default implementation is None (untextured).
Sourcefn metallic_roughness_texture(&self) -> Option<AssetUUID>
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.
Sourcefn normal_map(&self) -> Option<AssetUUID>
fn normal_map(&self) -> Option<AssetUUID>
Returns the UUID of the tangent-space normal map, if any.
Default implementation is None.
Sourcefn emissive_texture(&self) -> Option<AssetUUID>
fn emissive_texture(&self) -> Option<AssetUUID>
Returns the UUID of the emissive texture, if any.
Default implementation is None.
Sourcefn occlusion_map(&self) -> Option<AssetUUID>
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.
Sourcefn alpha_mode(&self) -> AlphaMode
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.
Sourcefn double_sided(&self) -> bool
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§
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.