Trait bevy_pbr::Material [−][src]
pub trait Material: Asset + RenderAsset {
fn bind_group(material: &<Self as RenderAsset>::PreparedAsset) -> &BindGroup;
fn bind_group_layout(render_device: &RenderDevice) -> BindGroupLayout;
fn vertex_shader(asset_server: &AssetServer) -> Option<Handle<Shader>> { ... }
fn fragment_shader(asset_server: &AssetServer) -> Option<Handle<Shader>> { ... }
fn alpha_mode(material: &<Self as RenderAsset>::PreparedAsset) -> AlphaMode { ... }
fn dynamic_uniform_indices(
material: &<Self as RenderAsset>::PreparedAsset
) -> &[u32] { ... }
}
Expand description
Materials are used alongside MaterialPlugin
and MaterialMeshBundle
to spawn entities that are rendered with a specific Material
type. They serve as an easy to use high level
way to render Mesh
entities with custom shader logic. For materials that can specialize their RenderPipelineDescriptor
based on specific material values, see SpecializedMaterial
. Material
automatically implements SpecializedMaterial
and can be used anywhere that type is used (such as MaterialPlugin
).
Required methods
fn bind_group(material: &<Self as RenderAsset>::PreparedAsset) -> &BindGroup
fn bind_group(material: &<Self as RenderAsset>::PreparedAsset) -> &BindGroup
Returns this material’s BindGroup
. This should match the layout returned by Material::bind_group_layout
.
fn bind_group_layout(render_device: &RenderDevice) -> BindGroupLayout
fn bind_group_layout(render_device: &RenderDevice) -> BindGroupLayout
Returns this material’s BindGroupLayout
. This should match the BindGroup
returned by Material::bind_group
.
Provided methods
fn vertex_shader(asset_server: &AssetServer) -> Option<Handle<Shader>>
fn vertex_shader(asset_server: &AssetServer) -> Option<Handle<Shader>>
fn fragment_shader(asset_server: &AssetServer) -> Option<Handle<Shader>>
fn fragment_shader(asset_server: &AssetServer) -> Option<Handle<Shader>>
fn alpha_mode(material: &<Self as RenderAsset>::PreparedAsset) -> AlphaMode
fn alpha_mode(material: &<Self as RenderAsset>::PreparedAsset) -> AlphaMode
Returns this material’s AlphaMode
. Defaults to AlphaMode::Opaque
.
fn dynamic_uniform_indices(
material: &<Self as RenderAsset>::PreparedAsset
) -> &[u32]
fn dynamic_uniform_indices(
material: &<Self as RenderAsset>::PreparedAsset
) -> &[u32]
The dynamic uniform indices to set for the given material
’s BindGroup
.
Defaults to an empty array / no dynamic uniform indices.