pub enum MaterialType {
Unlit(UnlitMaterial),
Phong(PhongMaterial),
Physical(PhysicalMaterial),
Custom(Box<dyn RenderableMaterialTrait>),
}Expand description
Material data enum with hybrid dispatch strategy.
Uses “static dispatch + dynamic escape hatch” approach:
- Built-in materials (Unlit/Phong/Physical) use static dispatch for performance
- Custom variant allows user-defined materials via dynamic dispatch
§Built-in Materials
UnlitMaterial: Unlit, flat-shaded materialPhongMaterial: Classic Blinn-Phong shadingPhysicalMaterial: PBR material with metallic-roughness workflow, clearcoat, transmission, etc.
Variants§
Unlit(UnlitMaterial)
Unlit material (no lighting calculations)
Phong(PhongMaterial)
Classic Blinn-Phong shading model
Physical(PhysicalMaterial)
Advanced PBR material with additional features
Custom(Box<dyn RenderableMaterialTrait>)
User-defined custom material
Implementations§
Source§impl MaterialType
impl MaterialType
Sourcepub fn as_custom<T>(&self) -> Option<&T>where
T: MaterialTrait + 'static,
pub fn as_custom<T>(&self) -> Option<&T>where
T: MaterialTrait + 'static,
Tries to downcast to a concrete type (for Custom materials)
Sourcepub fn as_custom_mut<T>(&mut self) -> Option<&mut T>where
T: MaterialTrait + 'static,
pub fn as_custom_mut<T>(&mut self) -> Option<&mut T>where
T: MaterialTrait + 'static,
Tries to downcast to a mutable reference of concrete type (for Custom materials)
Trait Implementations§
Source§impl Debug for MaterialType
impl Debug for MaterialType
Source§impl MaterialTrait for MaterialType
impl MaterialTrait for MaterialType
Source§impl RenderableMaterialTrait for MaterialType
impl RenderableMaterialTrait for MaterialType
Source§fn shader_name(&self) -> &'static str
fn shader_name(&self) -> &'static str
Returns the shader template name.
Source§fn shader_defines(&self) -> ShaderDefines
fn shader_defines(&self) -> ShaderDefines
Returns shader macro definitions based on current material state.
Source§fn settings(&self) -> MaterialSettings
fn settings(&self) -> MaterialSettings
Returns material rendering settings.
Source§fn visit_textures(&self, visitor: &mut dyn FnMut(&TextureSource))
fn visit_textures(&self, visitor: &mut dyn FnMut(&TextureSource))
Visits all textures used by this material.
Source§fn define_bindings<'a>(&'a self, builder: &mut ResourceBuilder<'a>)
fn define_bindings<'a>(&'a self, builder: &mut ResourceBuilder<'a>)
Defines GPU resource bindings for this material.
Source§fn uniform_buffer(&self) -> BufferRef
fn uniform_buffer(&self) -> BufferRef
Returns a reference to the uniform buffer.
Source§fn with_uniform_bytes(&self, visitor: &mut dyn FnMut(&[u8]))
fn with_uniform_bytes(&self, visitor: &mut dyn FnMut(&[u8]))
Provides uniform data bytes to the callback.
fn extra_defines(&self, _defines: &mut ShaderDefines)
Auto Trait Implementations§
impl !Freeze for MaterialType
impl !RefUnwindSafe for MaterialType
impl Send for MaterialType
impl Sync for MaterialType
impl Unpin for MaterialType
impl UnsafeUnpin for MaterialType
impl !UnwindSafe for MaterialType
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn 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.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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.Source§fn as_any(&self) -> &(dyn Any + 'static)
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.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
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.