pub struct PhongMaterial {
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 PhongMaterial
impl PhongMaterial
Sourcepub fn from_uniforms(uniforms: PhongUniforms) -> PhongMaterial
pub fn from_uniforms(uniforms: PhongUniforms) -> PhongMaterial
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<'_, PhongUniforms>
pub fn uniforms_mut(&self) -> CheckedBufferGuard<'_, PhongUniforms>
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<'_, PhongUniforms>
pub fn uniforms(&self) -> BufferReadGuard<'_, PhongUniforms>
Returns a read guard for accessing uniform parameters.
Sourcepub fn set_specular(&self, value: Vec3)
pub fn set_specular(&self, value: Vec3)
Specular color.
Sourcepub fn set_opacity(&self, value: f32)
pub fn set_opacity(&self, value: f32)
Opacity value.
Sourcepub fn set_emissive(&self, value: Vec3)
pub fn set_emissive(&self, value: Vec3)
Emissive color.
Sourcepub fn set_emissive_intensity(&self, value: f32)
pub fn set_emissive_intensity(&self, value: f32)
Emissive intensity.
Sourcepub fn emissive_intensity(&self) -> f32
pub fn emissive_intensity(&self) -> f32
Emissive intensity.
Sourcepub fn set_normal_scale(&self, value: Vec2)
pub fn set_normal_scale(&self, value: Vec2)
Normal map scale.
Sourcepub fn normal_scale(&self) -> Vec2
pub fn normal_scale(&self) -> Vec2
Normal map scale.
Sourcepub fn set_shininess(&self, value: f32)
pub fn set_shininess(&self, value: f32)
Shininess factor.
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 set_normal_map(&self, value: Option<TextureHandle>)
pub fn set_normal_map(&self, value: Option<TextureHandle>)
The normal map.
Sourcepub fn normal_map(&self) -> Option<TextureHandle>
pub fn normal_map(&self) -> Option<TextureHandle>
The normal map.
Sourcepub fn set_normal_map_transform(&self, transform: TextureTransform)
pub fn set_normal_map_transform(&self, transform: TextureTransform)
Sets the UV transform for this texture slot.
Sourcepub fn configure_normal_map<F>(&self, f: F)where
F: FnOnce(&mut TextureSlot),
pub fn configure_normal_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 set_specular_map(&self, value: Option<TextureHandle>)
pub fn set_specular_map(&self, value: Option<TextureHandle>)
The specular map.
Sourcepub fn specular_map(&self) -> Option<TextureHandle>
pub fn specular_map(&self) -> Option<TextureHandle>
The specular map.
Sourcepub fn set_specular_map_transform(&self, transform: TextureTransform)
pub fn set_specular_map_transform(&self, transform: TextureTransform)
Sets the UV transform for this texture slot.
Sourcepub fn configure_specular_map<F>(&self, f: F)where
F: FnOnce(&mut TextureSlot),
pub fn configure_specular_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 set_emissive_map(&self, value: Option<TextureHandle>)
pub fn set_emissive_map(&self, value: Option<TextureHandle>)
The emissive map.
Sourcepub fn emissive_map(&self) -> Option<TextureHandle>
pub fn emissive_map(&self) -> Option<TextureHandle>
The emissive map.
Sourcepub fn set_emissive_map_transform(&self, transform: TextureTransform)
pub fn set_emissive_map_transform(&self, transform: TextureTransform)
Sets the UV transform for this texture slot.
Sourcepub fn configure_emissive_map<F>(&self, f: F)where
F: FnOnce(&mut TextureSlot),
pub fn configure_emissive_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(&PhongUniforms),
pub fn configure<F>(&self, f: F)where
F: FnOnce(&PhongUniforms),
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 PhongMaterial
impl PhongMaterial
Sourcepub fn new(color: Vec4) -> PhongMaterial
pub fn new(color: Vec4) -> PhongMaterial
Creates a new Phong material with the given diffuse color.
Sourcepub fn with_color(self, color: Vec4) -> PhongMaterial
pub fn with_color(self, color: Vec4) -> PhongMaterial
Sets the diffuse color (builder).
Sourcepub fn with_shininess(self, s: f32) -> PhongMaterial
pub fn with_shininess(self, s: f32) -> PhongMaterial
Sets the shininess factor (builder).
Sourcepub fn with_specular(self, specular: Vec3) -> PhongMaterial
pub fn with_specular(self, specular: Vec3) -> PhongMaterial
Sets the specular color (builder).
Sourcepub fn with_emissive(self, color: Vec3, intensity: f32) -> PhongMaterial
pub fn with_emissive(self, color: Vec3, intensity: f32) -> PhongMaterial
Sets the emissive color and intensity (builder).
Sourcepub fn with_normal_scale(self, scale: Vec2) -> PhongMaterial
pub fn with_normal_scale(self, scale: Vec2) -> PhongMaterial
Sets the normal map scale (builder).
Sourcepub fn with_opacity(self, opacity: f32) -> PhongMaterial
pub fn with_opacity(self, opacity: f32) -> PhongMaterial
Sets the opacity (builder).
Sourcepub fn with_map(self, handle: TextureHandle) -> PhongMaterial
pub fn with_map(self, handle: TextureHandle) -> PhongMaterial
Sets the color map texture (builder).
Sourcepub fn with_normal_map(self, handle: TextureHandle) -> PhongMaterial
pub fn with_normal_map(self, handle: TextureHandle) -> PhongMaterial
Sets the normal map texture (builder).
Sourcepub fn with_specular_map(self, handle: TextureHandle) -> PhongMaterial
pub fn with_specular_map(self, handle: TextureHandle) -> PhongMaterial
Sets the specular map texture (builder).
Sourcepub fn with_emissive_map(self, handle: TextureHandle) -> PhongMaterial
pub fn with_emissive_map(self, handle: TextureHandle) -> PhongMaterial
Sets the emissive map texture (builder).
Sourcepub fn with_side(self, side: Side) -> PhongMaterial
pub fn with_side(self, side: Side) -> PhongMaterial
Sets the face culling side (builder).
Sourcepub fn with_alpha_mode(self, mode: AlphaMode) -> PhongMaterial
pub fn with_alpha_mode(self, mode: AlphaMode) -> PhongMaterial
Sets the alpha mode (builder).
Sourcepub fn with_depth_write(self, enabled: bool) -> PhongMaterial
pub fn with_depth_write(self, enabled: bool) -> PhongMaterial
Sets depth write (builder).
Trait Implementations§
Source§impl Clone for PhongMaterial
impl Clone for PhongMaterial
Source§fn clone(&self) -> PhongMaterial
fn clone(&self) -> PhongMaterial
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for PhongMaterial
impl Debug for PhongMaterial
Source§impl Default for PhongMaterial
impl Default for PhongMaterial
Source§fn default() -> PhongMaterial
fn default() -> PhongMaterial
Source§impl From<PhongMaterial> for Material
impl From<PhongMaterial> for Material
Source§fn from(data: PhongMaterial) -> Material
fn from(data: PhongMaterial) -> Material
Source§impl MaterialTrait for PhongMaterial
impl MaterialTrait for PhongMaterial
Source§impl RenderableMaterialTrait for PhongMaterial
impl RenderableMaterialTrait for PhongMaterial
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 PhongMaterial
impl ResolveMaterial for PhongMaterial
fn resolve(self, assets: &AssetServer) -> MaterialHandle
Auto Trait Implementations§
impl !Freeze for PhongMaterial
impl !RefUnwindSafe for PhongMaterial
impl Send for PhongMaterial
impl Sync for PhongMaterial
impl Unpin for PhongMaterial
impl UnsafeUnpin for PhongMaterial
impl UnwindSafe for PhongMaterial
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().