pub struct DataDrivenMaterial { /* private fields */ }Expand description
MADD — Data-driven material (v0–v3, 140–160 bytes)
The engine’s own name for this chunk is SDataDrivenMaterialData. It is not “additional” data: at load the renderer converts every StandardMaterial (1), DisplacementMaterial (2) and ReflectionMaterial (10) in the model into one of these and rewrites the MaterialMap to MaterialType::DataDriven, so this is the only material representation the renderer actually consumes.
fragmentHashes names the shader fragments the material links, in order. Concatenating shaderType’s token with those names gives the shader permutation name, and its crc32 is the effect-cache lookup key.
propertyBlob is a self-describing two-level dictionary keyed by crc32 of unprefixed names — decode it with decodeProperties().
@see M3_FILE_FORMAT_SPECIFICATION.md §11 Materials
Implementations§
Source§impl DataDrivenMaterial
impl DataDrivenMaterial
Sourcepub fn material_name(&self) -> String
pub fn material_name(&self) -> String
Material name (Ref<CHAR>)
pub fn set_material_name(&mut self, value: &str)
Sourcepub fn fragment_hashes(&self) -> &[u32]
pub fn fragment_hashes(&self) -> &[u32]
crc32 of each shader fragment name, in link order (U32_)
Zero-copy view of the underlying std::vector.
Sourcepub fn fragment_hashes_mut(&mut self) -> &mut [u32]
pub fn fragment_hashes_mut(&mut self) -> &mut [u32]
Zero-copy mutable view. Resize first — the borrow forbids it after.
pub fn set_fragment_hashes(&mut self, values: &[u32])
pub fn resize_fragment_hashes(&mut self, count: usize)
Sourcepub fn extra_hashes(&self) -> &[u32]
pub fn extra_hashes(&self) -> &[u32]
Secondary hash list (U32_, v2+)
Zero-copy view of the underlying std::vector.
Sourcepub fn extra_hashes_mut(&mut self) -> &mut [u32]
pub fn extra_hashes_mut(&mut self) -> &mut [u32]
Zero-copy mutable view. Resize first — the borrow forbids it after.
pub fn set_extra_hashes(&mut self, values: &[u32])
pub fn resize_extra_hashes(&mut self, count: usize)
Sourcepub fn property_blob(&self) -> &[u8] ⓘ
pub fn property_blob(&self) -> &[u8] ⓘ
Property dictionary (Ref<CHAR>)
Zero-copy view of the underlying std::vector.
Sourcepub fn property_blob_mut(&mut self) -> &mut [u8] ⓘ
pub fn property_blob_mut(&mut self) -> &mut [u8] ⓘ
Zero-copy mutable view. Resize first — the borrow forbids it after.
pub fn set_property_blob(&mut self, values: &[u8])
pub fn resize_property_blob(&mut self, count: usize)
Sourcepub fn unknown_108(&self) -> f32
pub fn unknown_108(&self) -> f32
1.0, 1.5 or 2.0 across the corpus
pub fn set_unknown_108(&mut self, value: f32)
Sourcepub fn unknown_112(&self) -> f32
pub fn unknown_112(&self) -> f32
1.0 in every known record
pub fn set_unknown_112(&mut self, value: f32)
pub fn unknown_116(&self) -> f32
pub fn set_unknown_116(&mut self, value: f32)
Sourcepub fn effect_name_hash(&self) -> u32
pub fn effect_name_hash(&self) -> u32
crc32 of the shader permutation name; 0 = compute it at load
pub fn set_effect_name_hash(&mut self, value: u32)
pub fn unknown_124(&self) -> u32
pub fn set_unknown_124(&mut self, value: u32)
Sourcepub fn padding_128(&self) -> u32
pub fn padding_128(&self) -> u32
Zero in every known record
pub fn set_padding_128(&mut self, value: u32)
pub fn unknown_132(&self) -> i32
pub fn set_unknown_132(&mut self, value: i32)
Sourcepub fn unknown_136(&self) -> u32
pub fn unknown_136(&self) -> u32
Packed bit field
pub fn set_unknown_136(&mut self, value: u32)
pub fn unknown_140(&self) -> u32
pub fn set_unknown_140(&mut self, value: u32)
pub fn unknown_144(&self) -> u32
pub fn set_unknown_144(&mut self, value: u32)
pub fn unknown_148(&self) -> u8
pub fn set_unknown_148(&mut self, value: u8)
Sourcepub fn alpha_fresnel_flags(&self) -> u8
pub fn alpha_fresnel_flags(&self) -> u8
Derived cache the loader recomputes; do not trust over the blob
pub fn set_alpha_fresnel_flags(&mut self, value: u8)
Sourcepub fn shader_type(&self) -> MaterialShaderType
pub fn shader_type(&self) -> MaterialShaderType
Shader family prefix for the permutation name
pub fn set_shader_type(&mut self, value: MaterialShaderType)
pub fn unknown_151(&self) -> u8
pub fn set_unknown_151(&mut self, value: u8)
Sourcepub fn effect_name_hash_2(&self) -> u32
pub fn effect_name_hash_2(&self) -> u32
Second permutation hash, 0xFFFFFFFF = none (v3+)
pub fn set_effect_name_hash_2(&mut self, value: u32)
Sourcepub fn effect_name_hash_3(&self) -> u32
pub fn effect_name_hash_3(&self) -> u32
Third permutation hash, 0xFFFFFFFF = none (v3+)
pub fn set_effect_name_hash_3(&mut self, value: u32)
Sourcepub fn decode_properties(&self) -> Option<DataDrivenProperties>
pub fn decode_properties(&self) -> Option<DataDrivenProperties>
Decode propertyBlob into fragment groups and named properties
Sourcepub fn to_standard_material(&self) -> Option<StandardMaterialConversion>
pub fn to_standard_material(&self) -> Option<StandardMaterialConversion>
Rebuild the StandardMaterial this was converted from, where possible
The engine only converts in the other direction, and does so lossily, so this reverses what it can and reports the rest. See StandardMaterialConversion.
Sourcepub fn approximate_standard_material(
&self,
) -> Option<StandardMaterialConversion>
pub fn approximate_standard_material( &self, ) -> Option<StandardMaterialConversion>
Best-effort StandardMaterial for a material that has no exact one
toStandardMaterial() refuses shader-graph materials, which were authored in the node editor and never had a StandardMaterial form. This infers one anyway, from the node types, the per-node names in extraHashes, and the texture filenames. The blob stores nodes but not the edges between them, so the graph topology cannot be recovered and the result is a likeness, not a conversion — lossy always says so. Materials that are already fixed-function are forwarded to toStandardMaterial() unchanged.