pub struct Material { /* private fields */ }Expand description
Control how disks are rendered.
Disks are always opaque and alpha in any texture or background color is ignored.
By default Material is initialized with only one background
color. Color the instances differently by setting more than one color
with set_background_colors. The color of each disk is given by
background_colors[tag % len(background_colors)] so you may set fewer colors
than there are disks. sync assigns tag values in increasing order to each
primitive.
The background_color tints the texture by multiplication. With a None
texture (the default), background_color sets the exact color of the disk.
Set the initial material by piping MaterialParameters into Disk::setup.
After it is initialized, change the material during execution via the material
field inResMut<disk::Representation<A>>.
Implementations§
Source§impl Material
impl Material
Sourcepub fn set_background_colors(
&mut self,
buffers: ResMut<'_, Assets<ShaderStorageBuffer>>,
colors: &[LinearRgba],
)
pub fn set_background_colors( &mut self, buffers: ResMut<'_, Assets<ShaderStorageBuffer>>, colors: &[LinearRgba], )
Set new background colors.
§Panics
WebGL2 builds (identified by the wasm32 target without the webgpu
feature) support only 1024 background colors.
Desktop target builds or wasm32 target builds with webgpu support
a much larger number of colors and will not panic.
Trait Implementations§
Source§impl AsBindGroup for Material
impl AsBindGroup for Material
type Param = (Res<'static, RenderAssets<GpuImage>>, Res<'static, FallbackImage>, Res<'static, RenderAssets<GpuShaderStorageBuffer>>)
Source§fn unprepared_bind_group(
&self,
layout: &BindGroupLayout,
render_device: &RenderDevice,
(images, fallback_image, storage_buffers): &mut SystemParamItem<'_, '_, Self::Param>,
force_no_bindless: bool,
) -> Result<UnpreparedBindGroup, AsBindGroupError>
fn unprepared_bind_group( &self, layout: &BindGroupLayout, render_device: &RenderDevice, (images, fallback_image, storage_buffers): &mut SystemParamItem<'_, '_, Self::Param>, force_no_bindless: bool, ) -> Result<UnpreparedBindGroup, AsBindGroupError>
OwnedBindingResource). Read morefn bind_group_data(&self) -> Self::Data
Source§fn bind_group_layout_entries(
render_device: &RenderDevice,
force_no_bindless: bool,
) -> Vec<BindGroupLayoutEntry>
fn bind_group_layout_entries( render_device: &RenderDevice, force_no_bindless: bool, ) -> Vec<BindGroupLayoutEntry>
fn bindless_descriptor() -> Option<BindlessDescriptor>
§fn bindless_slot_count() -> Option<BindlessSlabResourceLimit>
fn bindless_slot_count() -> Option<BindlessSlabResourceLimit>
§fn bindless_supported(_: &RenderDevice) -> bool
fn bindless_supported(_: &RenderDevice) -> bool
§fn as_bind_group(
&self,
layout_descriptor: &BindGroupLayoutDescriptor,
render_device: &RenderDevice,
pipeline_cache: &PipelineCache,
param: &mut <Self::Param as SystemParam>::Item<'_, '_>,
) -> Result<PreparedBindGroup, AsBindGroupError>
fn as_bind_group( &self, layout_descriptor: &BindGroupLayoutDescriptor, render_device: &RenderDevice, pipeline_cache: &PipelineCache, param: &mut <Self::Param as SystemParam>::Item<'_, '_>, ) -> Result<PreparedBindGroup, AsBindGroupError>
self matching the layout defined in [AsBindGroup::bind_group_layout].§fn bind_group_layout(render_device: &RenderDevice) -> BindGroupLayoutwhere
Self: Sized,
fn bind_group_layout(render_device: &RenderDevice) -> BindGroupLayoutwhere
Self: Sized,
AsBindGroup::as_bind_group]§fn bind_group_layout_descriptor(
render_device: &RenderDevice,
) -> BindGroupLayoutDescriptorwhere
Self: Sized,
fn bind_group_layout_descriptor(
render_device: &RenderDevice,
) -> BindGroupLayoutDescriptorwhere
Self: Sized,
AsBindGroup::as_bind_group]
TODO: we only need RenderDevice to determine if bindless is supportedSource§impl Material2d for Material
impl Material2d for Material
Source§fn fragment_shader() -> ShaderRef
fn fragment_shader() -> ShaderRef
ShaderRef::Default] is returned, the default mesh fragment shader
will be used.Source§fn vertex_shader() -> ShaderRef
fn vertex_shader() -> ShaderRef
ShaderRef::Default] is returned, the default mesh vertex shader
will be used.fn alpha_mode(&self) -> AlphaMode2d
§fn depth_bias(&self) -> f32
fn depth_bias(&self) -> f32
§fn specialize(
descriptor: &mut RenderPipelineDescriptor,
layout: &MeshVertexBufferLayoutRef,
key: Material2dKey<Self>,
) -> Result<(), SpecializedMeshPipelineError>
fn specialize( descriptor: &mut RenderPipelineDescriptor, layout: &MeshVertexBufferLayoutRef, key: Material2dKey<Self>, ) -> Result<(), SpecializedMeshPipelineError>
RenderPipelineDescriptor].Source§impl TypePath for Material
impl TypePath for Material
Source§fn type_path() -> &'static str
fn type_path() -> &'static str
Source§fn short_type_path() -> &'static str
fn short_type_path() -> &'static str
Source§fn type_ident() -> Option<&'static str>
fn type_ident() -> Option<&'static str>
Source§fn crate_name() -> Option<&'static str>
fn crate_name() -> Option<&'static str>
Source§impl VisitAssetDependencies for Material
impl VisitAssetDependencies for Material
fn visit_dependencies(&self, visit: &mut impl FnMut(UntypedAssetId))
impl Asset for Material
Auto Trait Implementations§
impl Freeze for Material
impl !RefUnwindSafe for Material
impl Send for Material
impl Sync for Material
impl Unpin for Material
impl !UnwindSafe for Material
Blanket Implementations§
§impl<T, U> AsBindGroupShaderType<U> for T
impl<T, U> AsBindGroupShaderType<U> for T
§fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
fn as_bind_group_shader_type(&self, _images: &RenderAssets<GpuImage>) -> U
T [ShaderType] for self. When used in [AsBindGroup]
derives, it is safe to assume that all images in self exist.Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> DynamicTypePath for Twhere
T: TypePath,
impl<T> DynamicTypePath for Twhere
T: TypePath,
§fn reflect_type_path(&self) -> &str
fn reflect_type_path(&self) -> &str
TypePath::type_path].§fn reflect_short_type_path(&self) -> &str
fn reflect_short_type_path(&self) -> &str
TypePath::short_type_path].§fn reflect_type_ident(&self) -> Option<&str>
fn reflect_type_ident(&self) -> Option<&str>
TypePath::type_ident].§fn reflect_crate_name(&self) -> Option<&str>
fn reflect_crate_name(&self) -> Option<&str>
TypePath::crate_name].§fn reflect_module_path(&self) -> Option<&str>
fn reflect_module_path(&self) -> Option<&str>
TypePath::module_path].§impl<T> Identity for Twhere
T: ?Sized,
impl<T> Identity for Twhere
T: ?Sized,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more