Skip to content

enum

Material

pub enum Material {
    Standard { color2: Option<Color>, shininess: f32, rim: f32, rim_color: Color, emissive: f32, wobble: f32, opacity: f32, map: Option<TextureRef> },
    Physical(PhysicalMaterial),
    Custom { vertex: Option<String>, fragment: String, uniforms: BTreeMap<String, Uniform>, attributes: BTreeMap<String, Attribute>, opacity: f32, transparent: bool, side: Side, depth_write: bool, blending: Blending },
}

What an object's surface looks like.

Variants

Standard

Standard { color2: Option<Color>, shininess: f32, rim: f32, rim_color: Color, emissive: f32, wobble: f32, opacity: f32, map: Option<TextureRef> }

The built-in lit material.

Physical

Physical(PhysicalMaterial)

Physically based shading (metallic-roughness, as glTF).

Custom

Custom { vertex: Option<String>, fragment: String, uniforms: BTreeMap<String, Uniform>, attributes: BTreeMap<String, Attribute>, opacity: f32, transparent: bool, side: Side, depth_write: bool, blending: Blending }

Your own GLSL. A source without #version gets Weft's prelude (the standard attributes, uniforms and helpers; see crate::shaders::custom_mesh_program).

Methods

opacity

pub fn opacity(&self) -> f32

How opaque it is, 0 to 1.

opacity_mut

pub fn opacity_mut(&mut self) -> &mut f32

Mutable access to its opacity.

custom

pub fn custom(fragment: &str) -> Material

A custom material with this fragment shader and the defaults.

textures

pub fn textures(&self) -> Vec<&TextureRef>

The textures it samples.

is_animated

pub fn is_animated(&self) -> bool

Whether it changes over time on its own.

Trait implementations