pub struct UnlitMaterial {
pub auto_sync_texture_to_uniforms: bool,
/* private fields */
}Fields§
§auto_sync_texture_to_uniforms: boolWhen true, texture transforms are automatically flushed to uniforms.
Implementations§
Source§impl UnlitMaterial
impl UnlitMaterial
Sourcepub fn from_uniforms(uniforms: UnlitUniforms) -> UnlitMaterial
pub fn from_uniforms(uniforms: UnlitUniforms) -> UnlitMaterial
Creates a new material instance from uniform data with default settings.
Sourcepub fn settings_mut(&self) -> SettingsGuard<'_>
pub fn settings_mut(&self) -> SettingsGuard<'_>
Returns a RAII guard for batch-modifying material settings.
The guard automatically increments the material version on drop if any settings changed, triggering pipeline cache invalidation.
Sourcepub fn settings(&self) -> MaterialSettings
pub fn settings(&self) -> MaterialSettings
Returns a snapshot of the current material settings.
Sourcepub fn set_alpha_mode(&self, mode: AlphaMode)
pub fn set_alpha_mode(&self, mode: AlphaMode)
Sets the alpha blending mode.
Sourcepub fn alpha_mode(&self) -> AlphaMode
pub fn alpha_mode(&self) -> AlphaMode
Returns the current alpha blending mode.
Sourcepub fn set_depth_test(&self, depth_test: bool)
pub fn set_depth_test(&self, depth_test: bool)
Enables or disables depth testing.
Sourcepub fn depth_test(&self) -> bool
pub fn depth_test(&self) -> bool
Returns whether depth testing is enabled.
Sourcepub fn set_depth_write(&self, depth_write: bool)
pub fn set_depth_write(&self, depth_write: bool)
Enables or disables depth buffer writing.
For transparent objects, it is usually recommended to disable this.
Sourcepub fn depth_write(&self) -> bool
pub fn depth_write(&self) -> bool
Returns whether depth buffer writing is enabled.
Sourcepub fn uniforms_mut(&self) -> CheckedBufferGuard<'_, UnlitUniforms>
pub fn uniforms_mut(&self) -> CheckedBufferGuard<'_, UnlitUniforms>
Returns a write guard for batch-modifying uniform parameters.
The guard automatically marks data as dirty on drop, triggering GPU buffer synchronization.
Sourcepub fn uniforms(&self) -> BufferReadGuard<'_, UnlitUniforms>
pub fn uniforms(&self) -> BufferReadGuard<'_, UnlitUniforms>
Returns a read guard for accessing uniform parameters.
Sourcepub fn set_opacity(&self, value: f32)
pub fn set_opacity(&self, value: f32)
Opacity value.
Sourcepub fn set_alpha_test(&self, value: f32)
pub fn set_alpha_test(&self, value: f32)
Alpha test threshold.
Sourcepub fn alpha_test(&self) -> f32
pub fn alpha_test(&self) -> f32
Alpha test threshold.
Sourcepub fn set_map(&self, value: Option<TextureHandle>)
pub fn set_map(&self, value: Option<TextureHandle>)
The color map.
Sourcepub fn map(&self) -> Option<TextureHandle>
pub fn map(&self) -> Option<TextureHandle>
The color map.
Sourcepub fn set_map_transform(&self, transform: TextureTransform)
pub fn set_map_transform(&self, transform: TextureTransform)
Sets the UV transform for this texture slot.
Sourcepub fn configure_map<F>(&self, f: F)where
F: FnOnce(&mut TextureSlot),
pub fn configure_map<F>(&self, f: F)where
F: FnOnce(&mut TextureSlot),
Configures this texture slot via a closure for batch modifications.
The closure receives a mutable reference to the [TextureSlot].
Version is automatically bumped if the texture or UV channel changes.
Sourcepub fn flush_texture_transforms(&self) -> bool
pub fn flush_texture_transforms(&self) -> bool
Flushes texture transform matrices to the uniform buffer.
Only writes when values actually change, avoiding unnecessary version bumps. Returns whether any data was updated.
Sourcepub fn configure<F>(&self, f: F)where
F: FnOnce(&UnlitUniforms),
pub fn configure<F>(&self, f: F)where
F: FnOnce(&UnlitUniforms),
Provides access to uniform data through a closure (under write lock).
Sourcepub fn notify_pipeline_dirty(&self)
pub fn notify_pipeline_dirty(&self)
Manually marks the material pipeline as dirty, forcing a rebuild.
In most cases this is not needed, as the standard API automatically tracks version changes. Use this only when:
- After directly modifying internal fields (e.g., in loader code)
- When material configuration has changed but version wasn’t updated
Source§impl UnlitMaterial
impl UnlitMaterial
Sourcepub fn new(color: Vec4) -> UnlitMaterial
pub fn new(color: Vec4) -> UnlitMaterial
Creates a new unlit material with the given base color.
Sourcepub fn with_color(self, color: Vec4) -> UnlitMaterial
pub fn with_color(self, color: Vec4) -> UnlitMaterial
Sets the base color (builder).
Sourcepub fn with_opacity(self, opacity: f32) -> UnlitMaterial
pub fn with_opacity(self, opacity: f32) -> UnlitMaterial
Sets the opacity (builder).
Sourcepub fn with_map(self, handle: TextureHandle) -> UnlitMaterial
pub fn with_map(self, handle: TextureHandle) -> UnlitMaterial
Sets the color map texture (builder).
Sourcepub fn with_side(self, side: Side) -> UnlitMaterial
pub fn with_side(self, side: Side) -> UnlitMaterial
Sets the face culling side (builder).
Sourcepub fn with_alpha_mode(self, mode: AlphaMode) -> UnlitMaterial
pub fn with_alpha_mode(self, mode: AlphaMode) -> UnlitMaterial
Sets the alpha mode (builder).
Sourcepub fn with_depth_write(self, enabled: bool) -> UnlitMaterial
pub fn with_depth_write(self, enabled: bool) -> UnlitMaterial
Sets depth write (builder).
Trait Implementations§
Source§impl Clone for UnlitMaterial
impl Clone for UnlitMaterial
Source§fn clone(&self) -> UnlitMaterial
fn clone(&self) -> UnlitMaterial
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UnlitMaterial
impl Debug for UnlitMaterial
Source§impl Default for UnlitMaterial
impl Default for UnlitMaterial
Source§fn default() -> UnlitMaterial
fn default() -> UnlitMaterial
Source§impl From<UnlitMaterial> for Material
impl From<UnlitMaterial> for Material
Source§fn from(data: UnlitMaterial) -> Material
fn from(data: UnlitMaterial) -> Material
Source§impl MaterialTrait for UnlitMaterial
impl MaterialTrait for UnlitMaterial
Source§impl RenderableMaterialTrait for UnlitMaterial
impl RenderableMaterialTrait for UnlitMaterial
Source§fn shader_name(&self) -> &'static str
fn shader_name(&self) -> &'static str
Source§fn settings(&self) -> MaterialSettings
fn settings(&self) -> MaterialSettings
Source§fn uniform_buffer(&self) -> BufferRef
fn uniform_buffer(&self) -> BufferRef
Source§fn with_uniform_bytes(&self, visitor: &mut dyn FnMut(&[u8]))
fn with_uniform_bytes(&self, visitor: &mut dyn FnMut(&[u8]))
Source§fn shader_defines(&self) -> ShaderDefines
fn shader_defines(&self) -> ShaderDefines
Source§fn visit_textures(&self, visitor: &mut dyn FnMut(&TextureSource))
fn visit_textures(&self, visitor: &mut dyn FnMut(&TextureSource))
Source§fn define_bindings<'a>(&'a self, builder: &mut ResourceBuilder<'a>)
fn define_bindings<'a>(&'a self, builder: &mut ResourceBuilder<'a>)
fn extra_defines(&self, _defines: &mut ShaderDefines)
Source§impl ResolveMaterial for UnlitMaterial
impl ResolveMaterial for UnlitMaterial
fn resolve(self, assets: &AssetServer) -> MaterialHandle
Auto Trait Implementations§
impl !Freeze for UnlitMaterial
impl !RefUnwindSafe for UnlitMaterial
impl Send for UnlitMaterial
impl Sync for UnlitMaterial
impl Unpin for UnlitMaterial
impl UnsafeUnpin for UnlitMaterial
impl UnwindSafe for UnlitMaterial
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
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>
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)
&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)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().