pub struct MaterialInstance {Show 13 fields
pub base_material_index: u32,
pub albedo_override: Option<[f32; 3]>,
pub alpha_override: Option<f32>,
pub metallic_override: Option<f32>,
pub roughness_override: Option<f32>,
pub emission_override: Option<[f32; 3]>,
pub emission_intensity_override: Option<f32>,
pub uv_scale_override: Option<[f32; 2]>,
pub uv_offset_override: Option<[f32; 2]>,
pub tint: Option<[f32; 4]>,
pub priority_override: Option<i32>,
pub custom_floats: HashMap<String, f32>,
pub custom_vec3s: HashMap<String, [f32; 3]>,
}Expand description
Per-object overrides layered on top of a base PbrMaterial. Only set fields are applied; None means use base material value.
Fields§
§base_material_index: u32Index of the base material in the library.
albedo_override: Option<[f32; 3]>Optional albedo override.
alpha_override: Option<f32>Optional alpha override.
metallic_override: Option<f32>Optional metallic override.
roughness_override: Option<f32>Optional roughness override.
emission_override: Option<[f32; 3]>Optional emission override.
emission_intensity_override: Option<f32>Optional emission intensity override.
uv_scale_override: Option<[f32; 2]>Optional UV scale override.
uv_offset_override: Option<[f32; 2]>Optional UV offset override.
tint: Option<[f32; 4]>Optional tint color (multiplied with albedo).
priority_override: Option<i32>Optional priority override.
custom_floats: HashMap<String, f32>Custom float parameters (shader-specific).
custom_vec3s: HashMap<String, [f32; 3]>Custom vec3 parameters.
Implementations§
Source§impl MaterialInstance
impl MaterialInstance
pub fn new(base_material_index: u32) -> Self
pub fn with_albedo(self, albedo: [f32; 3]) -> Self
pub fn with_alpha(self, alpha: f32) -> Self
pub fn with_metallic(self, m: f32) -> Self
pub fn with_roughness(self, r: f32) -> Self
pub fn with_emission(self, e: [f32; 3]) -> Self
pub fn with_tint(self, tint: [f32; 4]) -> Self
pub fn set_custom_float(&mut self, name: impl Into<String>, value: f32)
pub fn set_custom_vec3(&mut self, name: impl Into<String>, value: [f32; 3])
Sourcepub fn resolve(&self, base: &PbrMaterial) -> PbrMaterial
pub fn resolve(&self, base: &PbrMaterial) -> PbrMaterial
Resolve this instance against its base material, producing a final PbrMaterial.
Sourcepub fn override_count(&self) -> u32
pub fn override_count(&self) -> u32
Get the number of overrides set.
Trait Implementations§
Source§impl Clone for MaterialInstance
impl Clone for MaterialInstance
Source§fn clone(&self) -> MaterialInstance
fn clone(&self) -> MaterialInstance
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for MaterialInstance
impl Debug for MaterialInstance
Source§impl Default for MaterialInstance
impl Default for MaterialInstance
Source§fn default() -> MaterialInstance
fn default() -> MaterialInstance
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for MaterialInstance
impl RefUnwindSafe for MaterialInstance
impl Send for MaterialInstance
impl Sync for MaterialInstance
impl Unpin for MaterialInstance
impl UnsafeUnpin for MaterialInstance
impl UnwindSafe for MaterialInstance
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> 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>
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.