Skip to content

struct

ModelMaterial

pub struct ModelMaterial {
    pub name: String,
    pub color: Color,
    pub map: Option<usize>,
    pub metallic: f32,
    pub roughness: f32,
    pub emissive: f32,
    pub opacity: f32,
    pub blend: bool,
    pub double_sided: bool,
    pub physical: bool,
    pub emissive_color: Color,
    pub metallic_roughness_map: Option<usize>,
    pub normal_map: Option<usize>,
    pub normal_scale: f32,
    pub occlusion_map: Option<usize>,
    pub occlusion_strength: f32,
    pub emissive_map: Option<usize>,
}

A model's material, mapped onto Weft's physical material (glTF's metallic-roughness PBR) or, for formats without PBR, the standard one.

Fields

name

pub name: String

Its name in the file.

color

pub color: Color

Base colour.

map

pub map: Option<usize>

Base-colour texture: an index into [Model::textures].

metallic

pub metallic: f32

0 (dielectric) to 1 (metal).

roughness

pub roughness: f32

0 (mirror) to 1 (fully rough).

emissive

pub emissive: f32

The emissive colour's strength (its brightest channel).

opacity

pub opacity: f32

0 (invisible) to 1 (opaque).

blend

pub blend: bool

Alpha-blended (glTF BLEND).

double_sided

pub double_sided: bool

Whether back faces draw too.

physical

pub physical: bool

Physically based (glTF): draws with [crate::scene::Material::Physical].

emissive_color

pub emissive_color: Color

The emitted colour.

metallic_roughness_map

pub metallic_roughness_map: Option<usize>

Roughness (green) and metalness (blue), as glTF packs them.

normal_map

pub normal_map: Option<usize>

Tangent-space normals: an index into [Model::textures].

normal_scale

pub normal_scale: f32

How strongly normal_map bends the normals.

occlusion_map

pub occlusion_map: Option<usize>

Ambient occlusion (red channel): an index into [Model::textures].

occlusion_strength

pub occlusion_strength: f32

How strongly occlusion_map darkens.

emissive_map

pub emissive_map: Option<usize>

Emitted colour texture: an index into [Model::textures].

Methods

to_material

pub fn to_material(&self, texture: impl Fn(usize) -> Option<TextureRef>) -> Material

As one of Weft's materials, with texture resolving texture indices to images.

Trait implementations