Struct bevy::pbr::ExtendedMaterial

pub struct ExtendedMaterial<B, E>where
    B: Material,
    E: MaterialExtension,{
    pub base: B,
    pub extension: E,
}
Expand description

A material that extends a base Material with additional shaders and data.

The data from both materials will be combined and made available to the shader so that shader functions built for the base material (and referencing the base material bindings) will work as expected, and custom alterations based on custom data can also be used.

If the extension E returns a non-default result from vertex_shader() it will be used in place of the base material’s vertex shader.

If the extension E returns a non-default result from fragment_shader() it will be used in place of the base fragment shader.

When used with StandardMaterial as the base, all the standard material fields are present, so the pbr_fragment shader functions can be called from the extension shader (see the extended_material example).

Fields§

§base: B§extension: E

Trait Implementations§

§

impl<B, E> AsBindGroup for ExtendedMaterial<B, E>where B: Material, E: MaterialExtension,

§

type Data = (<B as AsBindGroup>::Data, <E as AsBindGroup>::Data)

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

fn unprepared_bind_group( &self, layout: &BindGroupLayout, render_device: &RenderDevice, images: &RenderAssets<Image>, fallback_image: &FallbackImage ) -> Result<UnpreparedBindGroup<<ExtendedMaterial<B, E> as AsBindGroup>::Data>, AsBindGroupError>

Returns a vec of (binding index, OwnedBindingResource). In cases where OwnedBindingResource is not available (as for bindless texture arrays currently), an implementor may define as_bind_group directly. This may prevent certain features from working correctly.
§

fn bind_group_layout_entries( render_device: &RenderDevice ) -> Vec<BindGroupLayoutEntry>where ExtendedMaterial<B, E>: Sized,

Returns a vec of bind group layout entries
§

fn label() -> Option<&'static str>

label
§

fn as_bind_group( &self, layout: &BindGroupLayout, render_device: &RenderDevice, images: &RenderAssets<Image>, fallback_image: &FallbackImage ) -> Result<PreparedBindGroup<Self::Data>, AsBindGroupError>

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

fn bind_group_layout(render_device: &RenderDevice) -> BindGroupLayoutwhere Self: Sized,

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

impl<B, E> Clone for ExtendedMaterial<B, E>where B: Clone + Material, E: Clone + MaterialExtension,

§

fn clone(&self) -> ExtendedMaterial<B, E>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<B, E> Material for ExtendedMaterial<B, E>where B: Material, E: MaterialExtension,

§

fn vertex_shader() -> ShaderRef

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

fn fragment_shader() -> ShaderRef

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

fn prepass_vertex_shader() -> ShaderRef

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

fn prepass_fragment_shader() -> ShaderRef

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

fn deferred_vertex_shader() -> ShaderRef

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

fn deferred_fragment_shader() -> ShaderRef

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

fn alpha_mode(&self) -> AlphaMode

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

fn depth_bias(&self) -> f32

Add a bias to the view depth of the mesh which can be used to force a specific render order. for meshes with similar depth, to avoid z-fighting. The bias is in depth-texture units so large values may be needed to overcome small depth differences.
§

fn reads_view_transmission_texture(&self) -> bool

Returns whether the material would like to read from ViewTransmissionTexture. Read more
§

fn opaque_render_method(&self) -> OpaqueRendererMethod

Returns if this material should be rendered by the deferred or forward renderer. for AlphaMode::Opaque or AlphaMode::Mask materials. If OpaqueRendererMethod::Auto, it will default to what is selected in the DefaultOpaqueRendererMethod resource.
§

fn specialize( pipeline: &MaterialPipeline<ExtendedMaterial<B, E>>, descriptor: &mut RenderPipelineDescriptor, layout: &Hashed<InnerMeshVertexBufferLayout>, key: MaterialPipelineKey<ExtendedMaterial<B, E>> ) -> Result<(), SpecializedMeshPipelineError>

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

impl<B, E> TypePath for ExtendedMaterial<B, E>where B: Material + TypePath, E: MaterialExtension + TypePath,

§

fn type_path() -> &'static str

Returns the fully qualified path of the underlying type. Read more
§

fn short_type_path() -> &'static str

Returns a short, pretty-print enabled path to the type. Read more
§

fn type_ident() -> Option<&'static str>

Returns the name of the type, or None if it is anonymous. Read more
§

fn crate_name() -> Option<&'static str>

Returns the name of the crate the type is in, or None if it is anonymous. Read more
§

fn module_path() -> Option<&'static str>

Returns the path to the module the type is in, or None if it is anonymous. Read more
§

impl<B, E> VisitAssetDependencies for ExtendedMaterial<B, E>where B: Material, E: MaterialExtension,

§

fn visit_dependencies(&self, _visit: &mut impl FnMut(UntypedAssetId))

§

impl<B, E> Asset for ExtendedMaterial<B, E>where B: Material, E: MaterialExtension,

Auto Trait Implementations§

§

impl<B, E> RefUnwindSafe for ExtendedMaterial<B, E>where B: RefUnwindSafe, E: RefUnwindSafe,

§

impl<B, E> Send for ExtendedMaterial<B, E>

§

impl<B, E> Sync for ExtendedMaterial<B, E>

§

impl<B, E> Unpin for ExtendedMaterial<B, E>where B: Unpin, E: Unpin,

§

impl<B, E> UnwindSafe for ExtendedMaterial<B, E>where B: UnwindSafe, E: UnwindSafe,

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T, U> AsBindGroupShaderType<U> for Twhere U: ShaderType, &'a T: for<'a> Into<U>,

§

fn as_bind_group_shader_type(&self, _images: &RenderAssets<Image>) -> U

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

impl<A> AssetContainer for Awhere A: Asset,

§

fn insert(self: Box<A>, id: UntypedAssetId, world: &mut World)

§

fn asset_type_name(&self) -> &'static str

source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
§

impl<T> Downcast<T> for T

§

fn downcast(&self) -> &T

§

impl<T> Downcast for Twhere T: Any,

§

fn into_any(self: Box<T>) -> Box<dyn Any>

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.
§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert 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)

Convert &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)

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

impl<T> DowncastSync for Twhere T: Any + Send + Sync,

§

fn into_any_arc(self: Arc<T>) -> Arc<dyn Any + Send + Sync>

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

impl<T> DynamicTypePath for Twhere T: TypePath,

source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<S> FromSample<S> for S

§

fn from_sample_(s: S) -> S

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for Twhere U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

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

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

impl<T, U> ToSample<U> for Twhere U: FromSample<T>,

§

fn to_sample_(self) -> U

source§

impl<T, U> TryFrom<U> for Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for Twhere U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> TypeData for Twhere T: 'static + Send + Sync + Clone,

§

fn clone_type_data(&self) -> Box<dyn TypeData>

§

impl<T> Upcast<T> for T

§

fn upcast(&self) -> Option<&T>

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where S: Into<Dispatch>,

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

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<S, T> Duplex<S> for Twhere T: FromSample<S> + ToSample<S>,

§

impl<T> Settings for Twhere T: 'static + Send + Sync,

§

impl<T> WasmNotSend for Twhere T: Send,

§

impl<T> WasmNotSync for Twhere T: Sync,