logo
pub struct StandardMaterial {
Show 16 fields pub base_color: Color, pub base_color_texture: Option<Handle<Image>>, pub emissive: Color, pub emissive_texture: Option<Handle<Image>>, pub perceptual_roughness: f32, pub metallic: f32, pub metallic_roughness_texture: Option<Handle<Image>>, pub reflectance: f32, pub normal_map_texture: Option<Handle<Image>>, pub flip_normal_map_y: bool, pub occlusion_texture: Option<Handle<Image>>, pub double_sided: bool, pub cull_mode: Option<Face>, pub unlit: bool, pub alpha_mode: AlphaMode, pub depth_bias: f32,
}
Expand description

A material with “standard” properties used in PBR lighting Standard property values with pictures here https://google.github.io/filament/Material%20Properties.pdf.

May be created directly from a Color or an Image.

Fields

base_color: Color

Doubles as diffuse albedo for non-metallic, specular for metallic and a mix for everything in between. If used together with a base_color_texture, this is factored into the final base color as base_color * base_color_texture_value

base_color_texture: Option<Handle<Image>>emissive: Color

Color the material “emits” to the camera.

This is typically used for monitor screens or LED lights. Anything that can be visible even in darkness.

The emissive color is added to what would otherwise be the material’s visible color. This means that for a light emissive value, in darkness, you will mostly see the emissive component.

The default emissive color is black, which doesn’t add anything to the material color.

Note that an emissive material won’t light up surrounding areas like a light source, it just adds a value to the color seen on screen.

emissive_texture: Option<Handle<Image>>perceptual_roughness: f32

Linear perceptual roughness, clamped to [0.089, 1.0] in the shader Defaults to minimum of 0.089 If used together with a roughness/metallic texture, this is factored into the final base color as roughness * roughness_texture_value

metallic: f32

From [0.0, 1.0], dielectric to pure metallic If used together with a roughness/metallic texture, this is factored into the final base color as metallic * metallic_texture_value

metallic_roughness_texture: Option<Handle<Image>>reflectance: f32

Specular intensity for non-metals on a linear scale of [0.0, 1.0] defaults to 0.5 which is mapped to 4% reflectance in the shader

normal_map_texture: Option<Handle<Image>>

Used to fake the lighting of bumps and dents on a material.

A typical usage would be faking cobblestones on a flat plane mesh in 3D.

Notes

Normal mapping with StandardMaterial and the core bevy PBR shaders requires:

  • A normal map texture
  • Vertex UVs
  • Vertex tangents
  • Vertex normals

Tangents do not have to be stored in your model, they can be generated using the Mesh::generate_tangents method. If your material has a normal map, but still renders as a flat surface, make sure your meshes have their tangents set.

flip_normal_map_y: bool

Normal map textures authored for DirectX have their y-component flipped. Set this to flip it to right-handed conventions.

occlusion_texture: Option<Handle<Image>>

Specifies the level of exposure to ambient light.

This is usually generated and stored automatically (“baked”) by 3D-modelling software.

Typically, steep concave parts of a model (such as the armpit of a shirt) are darker, because they have little exposed to light. An occlusion map specifies those parts of the model that light doesn’t reach well.

The material will be less lit in places where this texture is dark. This is similar to ambient occlusion, but built into the model.

double_sided: bool

Support two-sided lighting by automatically flipping the normals for “back” faces within the PBR lighting shader. Defaults to false. This does not automatically configure backface culling, which can be done via cull_mode.

cull_mode: Option<Face>

Whether to cull the “front”, “back” or neither side of a mesh defaults to Face::Back

unlit: boolalpha_mode: AlphaModedepth_bias: f32

Trait Implementations

Data that will be stored alongside the “prepared” bind group.

Creates a bind group for self matching the layout defined in AsBindGroup::bind_group_layout.

Creates the bind group layout matching all bind groups returned by AsBindGroup::as_bind_group

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

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

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

Customizes the default RenderPipelineDescriptor for a specific entity using the entity’s MaterialPipelineKey and MeshVertexBufferLayout as input. Read more

Returns this material’s fragment shader. If ShaderRef::Default is returned, the default mesh fragment shader will be used. Read more

Returns this material’s AlphaMode. Defaults to AlphaMode::Opaque.

Add a bias to the view depth of the mesh which can be used to force a specific render order for meshes with equal depth, to avoid z-fighting. Read more

Returns this material’s vertex shader. If ShaderRef::Default is returned, the default mesh vertex shader will be used. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Return the T ShaderType for self. When used in AsBindGroup derives, it is safe to assume that all images in self exist. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Returns the argument unchanged.

Creates Self using data from the given World

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

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Returns the UUID associated with this value’s type.

Returns the type name of this value’s type.

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

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