pub struct Material {
pub base_color_factor: [f32; 4],
pub metallic_factor: f32,
pub roughness_factor: f32,
pub emissive_factor: [f32; 3],
pub alpha_mode: AlphaMode,
pub alpha_cutoff: f32,
/* private fields */
}Expand description
Common glTF material data with an optional MToon extension.
Fields§
§base_color_factor: [f32; 4]Linear RGBA multiplier for the base color.
metallic_factor: f32Metallic multiplier used by the glTF PBR model.
roughness_factor: f32Roughness multiplier used by the glTF PBR model.
emissive_factor: [f32; 3]Linear RGB emissive color before the HDR strength multiplier.
alpha_mode: AlphaModeAlpha composition mode used by the material.
alpha_cutoff: f32Alpha-test threshold used when Self::alpha_mode is AlphaMode::Mask.
Implementations§
Source§impl Material
impl Material
Sourcepub const fn with_base_color_factor(self, factor: [f32; 4]) -> Self
pub const fn with_base_color_factor(self, factor: [f32; 4]) -> Self
Sets the base-color factor shared by the supported shading models.
Sourcepub const fn with_metallic_factor(self, factor: f32) -> Self
pub const fn with_metallic_factor(self, factor: f32) -> Self
Sets the metallic factor of the core glTF material model.
Sourcepub const fn with_roughness_factor(self, factor: f32) -> Self
pub const fn with_roughness_factor(self, factor: f32) -> Self
Sets the roughness factor of the core glTF material model.
Sourcepub const fn with_emissive_factor(self, factor: [f32; 3]) -> Self
pub const fn with_emissive_factor(self, factor: [f32; 3]) -> Self
Sets the emissive color before applying Self::emissive_strength.
Sourcepub const fn with_base_color_texture(self, texture: TextureInfo) -> Self
pub const fn with_base_color_texture(self, texture: TextureInfo) -> Self
Sets the base-color texture.
Sourcepub const fn with_metallic_roughness_texture(self, texture: TextureInfo) -> Self
pub const fn with_metallic_roughness_texture(self, texture: TextureInfo) -> Self
Sets the texture whose green and blue channels provide roughness and metalness.
Sourcepub const fn with_normal_texture(self, texture: NormalTextureInfo) -> Self
pub const fn with_normal_texture(self, texture: NormalTextureInfo) -> Self
Sets the tangent-space normal map.
Sourcepub const fn with_occlusion_texture(self, texture: OcclusionTextureInfo) -> Self
pub const fn with_occlusion_texture(self, texture: OcclusionTextureInfo) -> Self
Sets the red-channel occlusion map.
Sourcepub const fn with_emissive_texture(self, texture: TextureInfo) -> Self
pub const fn with_emissive_texture(self, texture: TextureInfo) -> Self
Sets the emissive texture.
Sourcepub const fn with_unlit(self, unlit: bool) -> Self
pub const fn with_unlit(self, unlit: bool) -> Self
Enables or disables the KHR_materials_unlit shading model.
Sourcepub const fn with_emissive_strength(self, strength: f32) -> Self
pub const fn with_emissive_strength(self, strength: f32) -> Self
Sets the KHR_materials_emissive_strength multiplier.
Sourcepub const fn with_alpha_mode(self, alpha_mode: AlphaMode) -> Self
pub const fn with_alpha_mode(self, alpha_mode: AlphaMode) -> Self
Sets the alpha composition mode.
Sourcepub const fn with_alpha_cutoff(self, alpha_cutoff: f32) -> Self
pub const fn with_alpha_cutoff(self, alpha_cutoff: f32) -> Self
Sets the cutoff used by AlphaMode::Mask.
Sourcepub const fn with_double_sided(self, double_sided: bool) -> Self
pub const fn with_double_sided(self, double_sided: bool) -> Self
Enables or disables rendering both sides of each triangle.
Sourcepub fn with_mtoon(self, mtoon: MToonMaterial) -> Self
pub fn with_mtoon(self, mtoon: MToonMaterial) -> Self
Adds an MToon model, which takes precedence over Unlit and PBR rendering.
Sourcepub fn base_color_texture(&self) -> Option<&TextureInfo>
pub fn base_color_texture(&self) -> Option<&TextureInfo>
Returns the base-color texture used by every supported material model.
Sourcepub fn metallic_roughness_texture(&self) -> Option<&TextureInfo>
pub fn metallic_roughness_texture(&self) -> Option<&TextureInfo>
Returns the texture whose green and blue channels contain roughness and metalness.
Sourcepub fn normal_texture(&self) -> Option<&NormalTextureInfo>
pub fn normal_texture(&self) -> Option<&NormalTextureInfo>
Returns the tangent-space normal map and its scale.
Sourcepub fn occlusion_texture(&self) -> Option<&OcclusionTextureInfo>
pub fn occlusion_texture(&self) -> Option<&OcclusionTextureInfo>
Returns the red-channel occlusion map and its strength.
Sourcepub fn emissive_texture(&self) -> Option<&TextureInfo>
pub fn emissive_texture(&self) -> Option<&TextureInfo>
Returns the emissive texture.
Sourcepub fn unlit(&self) -> bool
pub fn unlit(&self) -> bool
Returns whether KHR_materials_unlit was declared.
This remains true when MToon is also present. Use Self::shading_model
when selecting a renderer because MToon takes precedence over Unlit.
Sourcepub fn emissive_strength(&self) -> f32
pub fn emissive_strength(&self) -> f32
Returns the selected emissive multiplier, defaulting to one.
KHR_materials_emissive_strength takes precedence over the archived VRM
multiplier when both extensions are present.
Sourcepub fn emissive_strength_source(&self) -> EmissiveStrengthSource
pub fn emissive_strength_source(&self) -> EmissiveStrengthSource
Returns the extension that supplied Self::emissive_strength.
Sourcepub fn legacy_emissive_multiplier(&self) -> Option<f32>
pub fn legacy_emissive_multiplier(&self) -> Option<f32>
Returns the archived VRM emissive multiplier when it was declared.
The value is retained even when the modern KHR extension overrides it so callers can emit a deprecation or precedence diagnostic.
Sourcepub fn effective_emissive_factor(&self) -> [f32; 3]
pub fn effective_emissive_factor(&self) -> [f32; 3]
Returns emissive_factor after applying the selected HDR multiplier.
Sourcepub fn shading_model(&self) -> MaterialShadingModel
pub fn shading_model(&self) -> MaterialShadingModel
Returns the material model that takes precedence for rendering.
Sourcepub fn double_sided(&self) -> bool
pub fn double_sided(&self) -> bool
Reports whether back-face culling must be disabled.
Sourcepub fn mtoon(&self) -> Option<&MToonMaterial>
pub fn mtoon(&self) -> Option<&MToonMaterial>
Returns the MToon extension parameters, if present.