Skip to main content

Material

Struct Material 

Source
pub struct Material {
Show 73 fields pub base_color: [f32; 4], pub emissive_factor: [f32; 3], pub alpha_mode: AlphaMode, pub alpha_cutoff: f32, pub blend_opaque_alpha_threshold: f32, pub base_texture: Option<String>, pub base_texture_transform: TextureTransform, pub emissive_texture: Option<String>, pub emissive_texture_transform: TextureTransform, pub normal_texture: Option<String>, pub normal_texture_transform: TextureTransform, pub normal_scale: f32, pub normal_map_flip_y: bool, pub normal_map_two_component: bool, pub metallic_roughness_texture: Option<String>, pub metallic_roughness_texture_transform: TextureTransform, pub occlusion_texture: Option<String>, pub occlusion_texture_transform: TextureTransform, pub occlusion_strength: f32, pub roughness: f32, pub metallic: f32, pub unlit: bool, pub double_sided: bool, pub transmission_factor: f32, pub transmission_texture: Option<String>, pub transmission_texture_transform: TextureTransform, pub thickness: f32, pub thickness_texture: Option<String>, pub thickness_texture_transform: TextureTransform, pub attenuation_color: [f32; 3], pub attenuation_distance: f32, pub ior: f32, pub specular_factor: f32, pub specular_color_factor: [f32; 3], pub specular_texture: Option<String>, pub specular_texture_transform: TextureTransform, pub specular_color_texture: Option<String>, pub specular_color_texture_transform: TextureTransform, pub emissive_strength: f32, pub diffuse_transmission_factor: f32, pub diffuse_transmission_texture: Option<String>, pub diffuse_transmission_texture_transform: TextureTransform, pub diffuse_transmission_color_factor: [f32; 3], pub diffuse_transmission_color_texture: Option<String>, pub diffuse_transmission_color_texture_transform: TextureTransform, pub dispersion: f32, pub anisotropy_strength: f32, pub anisotropy_rotation: f32, pub anisotropy_texture: Option<String>, pub anisotropy_texture_transform: TextureTransform, pub iridescence_factor: f32, pub iridescence_texture: Option<String>, pub iridescence_texture_transform: TextureTransform, pub iridescence_ior: f32, pub iridescence_thickness_minimum: f32, pub iridescence_thickness_maximum: f32, pub iridescence_thickness_texture: Option<String>, pub iridescence_thickness_texture_transform: TextureTransform, pub sheen_color_factor: [f32; 3], pub sheen_color_texture: Option<String>, pub sheen_color_texture_transform: TextureTransform, pub sheen_roughness_factor: f32, pub sheen_roughness_texture: Option<String>, pub sheen_roughness_texture_transform: TextureTransform, pub clearcoat_factor: f32, pub clearcoat_texture: Option<String>, pub clearcoat_texture_transform: TextureTransform, pub clearcoat_roughness_factor: f32, pub clearcoat_roughness_texture: Option<String>, pub clearcoat_roughness_texture_transform: TextureTransform, pub clearcoat_normal_texture: Option<String>, pub clearcoat_normal_texture_transform: TextureTransform, pub clearcoat_normal_scale: f32,
}
Expand description

PBR material definition following glTF 2.0 conventions.

Supports the metallic-roughness workflow with optional textures for each parameter. Includes glTF extensions: KHR_materials_transmission, KHR_materials_volume, KHR_materials_specular, and KHR_materials_emissive_strength.

Fields§

§base_color: [f32; 4]

Base color (albedo) as RGBA. Multiplied with base_texture if present.

§emissive_factor: [f32; 3]

Emissive color multiplier as RGB.

§alpha_mode: AlphaMode

Transparency handling mode.

§alpha_cutoff: f32

Alpha threshold for AlphaMode::Mask.

§blend_opaque_alpha_threshold: f32

Alpha threshold above which a fragment of an AlphaMode::Blend material is treated as effectively opaque by the depth prepass: fragments at or above this value write depth so transparent fragments behind them are correctly occluded; fragments below the threshold skip the prepass and accumulate through OIT. Defaults to 0.99; lower it for materials with soft alpha edges like anti-aliased text or decals where a tighter threshold produces visible halos in OIT.

§base_texture: Option<String>

Path to base color texture.

§base_texture_transform: TextureTransform§emissive_texture: Option<String>

Path to emissive texture.

§emissive_texture_transform: TextureTransform§normal_texture: Option<String>

Path to normal map texture.

§normal_texture_transform: TextureTransform§normal_scale: f32

Normal map intensity multiplier.

§normal_map_flip_y: bool

Flip normal map Y (green) channel for DirectX-style maps.

§normal_map_two_component: bool

Two-component normal map (RG only, B reconstructed).

§metallic_roughness_texture: Option<String>

Path to metallic (B) / roughness (G) texture.

§metallic_roughness_texture_transform: TextureTransform§occlusion_texture: Option<String>

Path to ambient occlusion texture (R channel).

§occlusion_texture_transform: TextureTransform§occlusion_strength: f32

Occlusion effect strength (0 = none, 1 = full).

§roughness: f32

Surface roughness (0 = smooth/mirror, 1 = rough/diffuse).

§metallic: f32

Metallic factor (0 = dielectric, 1 = metal).

§unlit: bool

Skip lighting calculations (flat shaded).

§double_sided: bool

Render both sides of faces.

§transmission_factor: f32

Transmission factor for refractive materials (KHR_materials_transmission).

§transmission_texture: Option<String>§transmission_texture_transform: TextureTransform§thickness: f32

Volume thickness for transmission (KHR_materials_volume).

§thickness_texture: Option<String>§thickness_texture_transform: TextureTransform§attenuation_color: [f32; 3]

Light absorption color inside the volume.

§attenuation_distance: f32

Distance at which light is attenuated to attenuation_color.

§ior: f32

Index of refraction (default 1.5 for glass).

§specular_factor: f32

Specular intensity override (KHR_materials_specular).

§specular_color_factor: [f32; 3]

Specular color tint.

§specular_texture: Option<String>§specular_texture_transform: TextureTransform§specular_color_texture: Option<String>§specular_color_texture_transform: TextureTransform§emissive_strength: f32

Emissive intensity multiplier (KHR_materials_emissive_strength).

§diffuse_transmission_factor: f32

Diffuse transmission factor (KHR_materials_diffuse_transmission). Fraction of base color light transmitted as Lambertian through the surface.

§diffuse_transmission_texture: Option<String>§diffuse_transmission_texture_transform: TextureTransform§diffuse_transmission_color_factor: [f32; 3]

Color tint applied to the diffuse-transmitted light.

§diffuse_transmission_color_texture: Option<String>§diffuse_transmission_color_texture_transform: TextureTransform§dispersion: f32

Chromatic dispersion strength (KHR_materials_dispersion). Splits the refraction angle per wavelength using Cauchy’s approximation.

§anisotropy_strength: f32

Anisotropy strength (KHR_materials_anisotropy). 0 = isotropic, 1 = maximum.

§anisotropy_rotation: f32

Rotation of anisotropic direction in radians around the surface normal.

§anisotropy_texture: Option<String>§anisotropy_texture_transform: TextureTransform§iridescence_factor: f32

Iridescence strength (KHR_materials_iridescence). 0 = none, 1 = full thin-film effect.

§iridescence_texture: Option<String>§iridescence_texture_transform: TextureTransform§iridescence_ior: f32

Index of refraction for the iridescent thin-film layer.

§iridescence_thickness_minimum: f32

Minimum film thickness in nanometers.

§iridescence_thickness_maximum: f32

Maximum film thickness in nanometers (modulated by iridescence_thickness_texture.g).

§iridescence_thickness_texture: Option<String>§iridescence_thickness_texture_transform: TextureTransform§sheen_color_factor: [f32; 3]

Sheen color (KHR_materials_sheen). Multiplied with sheen_color_texture if present.

§sheen_color_texture: Option<String>§sheen_color_texture_transform: TextureTransform§sheen_roughness_factor: f32

Sheen roughness (0 = sharp, 1 = smooth velvet).

§sheen_roughness_texture: Option<String>§sheen_roughness_texture_transform: TextureTransform§clearcoat_factor: f32

Clearcoat layer strength (KHR_materials_clearcoat). 0 = none, 1 = full coat.

§clearcoat_texture: Option<String>§clearcoat_texture_transform: TextureTransform§clearcoat_roughness_factor: f32

Clearcoat layer roughness.

§clearcoat_roughness_texture: Option<String>§clearcoat_roughness_texture_transform: TextureTransform§clearcoat_normal_texture: Option<String>

Optional separate normal map for the clearcoat layer.

§clearcoat_normal_texture_transform: TextureTransform§clearcoat_normal_scale: f32

Implementations§

Source§

impl Material

Source

pub fn is_transparent(&self) -> bool

Returns true if this material requires transparency handling.

Source

pub fn texture_names(&self) -> impl Iterator<Item = &str>

Yields every texture name referenced by this material across every PBR slot (base color, normal map, metallic-roughness, all glTF extension textures). Used by the texture cache to bump and drop reference counts without missing any slots.

Trait Implementations§

Source§

impl Clone for Material

Source§

fn clone(&self) -> Material

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Material

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for Material

Source§

fn default() -> Material

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Material

Source§

fn deserialize<__D>( __deserializer: __D, ) -> Result<Material, <__D as Deserializer<'de>>::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for Material

Source§

fn eq(&self, other: &Material) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for Material

Source§

fn serialize<__S>( &self, __serializer: __S, ) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for Material

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> Downcast for T
where T: Any,

Source§

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>

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)

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)

Convert &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> Downcast for T
where T: Any,

Source§

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

Converts Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
Source§

fn as_any(&self) -> &(dyn Any + 'static)

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

Converts &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> DowncastSend for T
where T: Any + Send,

Source§

fn into_any_send(self: Box<T>) -> Box<dyn Any + Send>

Converts Box<Trait> (where Trait: DowncastSend) to Box<dyn Any + Send>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

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

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

Source§

fn into_any_sync(self: Box<T>) -> Box<dyn Any + Send + Sync>

Converts Box<Trait> (where Trait: DowncastSync) to Box<dyn Any + Send + Sync>, which can then be downcast into Box<ConcreteType> where ConcreteType implements Trait.
Source§

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

Converts Arc<Trait> (where Trait: DowncastSync) to Arc<Any>, which can then be downcast into Arc<ConcreteType> where ConcreteType implements Trait.
Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<S> FromSample<S> for S

Source§

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 T
where 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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<F, T> IntoSample<T> for F
where T: FromSample<F>,

Source§

fn into_sample(self) -> T

Source§

impl<T> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> Scalar for T
where T: 'static + Clone + PartialEq + Debug,

Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

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

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

Source§

fn to_sample_(self) -> U

Source§

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

Source§

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 T
where U: TryFrom<T>,

Source§

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WasmNotSend for T
where T: Send,

Source§

impl<T> WasmNotSendSync for T

Source§

impl<T> WasmNotSync for T
where T: Sync,

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