logo

Trait bevy::sprite::SpecializedMaterial2d[]

pub trait SpecializedMaterial2d: Asset + RenderAsset {
    type Key: PartialEq<Self::Key> + Eq + Hash + Clone + Send + Sync;
    fn key(material: &Self::PreparedAsset) -> Self::Key;
fn specialize(key: Self::Key, descriptor: &mut RenderPipelineDescriptor);
fn bind_group(material: &Self::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 dynamic_uniform_indices(material: &Self::PreparedAsset) -> &[u32] { ... } }
Expand description

Materials are used alongside Material2dPlugin and MaterialMesh2dBundle to spawn entities that are rendered with a specific SpecializedMaterial2d type. They serve as an easy to use high level way to render Mesh2dHandle entities with custom shader logic. SpecializedMaterial2ds use their SpecializedMaterial2d::Key to customize their RenderPipelineDescriptor based on specific material values. The slightly simpler Material2d trait should be used for materials that do not need specialization. Material2d types automatically implement SpecializedMaterial2d.

Associated Types

The key used to specialize this material’s RenderPipelineDescriptor.

Required methods

Extract the SpecializedMaterial2d::Key for the “prepared” version of this material. This key will be passed in to the SpecializedMaterial2d::specialize function when compiling the RenderPipeline for a given entity’s material.

Specializes the given descriptor according to the given key.

Returns this material’s BindGroup. This should match the layout returned by SpecializedMaterial2d::bind_group_layout.

Returns this material’s BindGroupLayout. This should match the BindGroup returned by SpecializedMaterial2d::bind_group.

Provided methods

Returns this material’s vertex shader. If None is returned, the default mesh vertex shader will be used. Defaults to None.

Returns this material’s fragment shader. If None is returned, the default mesh fragment shader will be used. Defaults to None.

The dynamic uniform indices to set for the given material’s BindGroup. Defaults to an empty array / no dynamic uniform indices.

Implementors