Skip to main content

DataDrivenMaterial

Struct DataDrivenMaterial 

Source
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

Source

pub fn new() -> Self

§Panics

Panics if the native allocation fails.

Source

pub fn material_name(&self) -> String

Material name (Ref<CHAR>)

Source

pub fn set_material_name(&mut self, value: &str)

Source

pub fn fragment_hashes(&self) -> &[u32]

crc32 of each shader fragment name, in link order (U32_) Zero-copy view of the underlying std::vector.

Source

pub fn fragment_hashes_mut(&mut self) -> &mut [u32]

Zero-copy mutable view. Resize first — the borrow forbids it after.

Source

pub fn set_fragment_hashes(&mut self, values: &[u32])

Source

pub fn resize_fragment_hashes(&mut self, count: usize)

Source

pub fn extra_hashes(&self) -> &[u32]

Secondary hash list (U32_, v2+) Zero-copy view of the underlying std::vector.

Source

pub fn extra_hashes_mut(&mut self) -> &mut [u32]

Zero-copy mutable view. Resize first — the borrow forbids it after.

Source

pub fn set_extra_hashes(&mut self, values: &[u32])

Source

pub fn resize_extra_hashes(&mut self, count: usize)

Source

pub fn property_blob(&self) -> &[u8]

Property dictionary (Ref<CHAR>) Zero-copy view of the underlying std::vector.

Source

pub fn property_blob_mut(&mut self) -> &mut [u8]

Zero-copy mutable view. Resize first — the borrow forbids it after.

Source

pub fn set_property_blob(&mut self, values: &[u8])

Source

pub fn resize_property_blob(&mut self, count: usize)

Source

pub fn unknown_108(&self) -> f32

1.0, 1.5 or 2.0 across the corpus

Source

pub fn set_unknown_108(&mut self, value: f32)

Source

pub fn unknown_112(&self) -> f32

1.0 in every known record

Source

pub fn set_unknown_112(&mut self, value: f32)

Source

pub fn unknown_116(&self) -> f32

Source

pub fn set_unknown_116(&mut self, value: f32)

Source

pub fn effect_name_hash(&self) -> u32

crc32 of the shader permutation name; 0 = compute it at load

Source

pub fn set_effect_name_hash(&mut self, value: u32)

Source

pub fn unknown_124(&self) -> u32

Source

pub fn set_unknown_124(&mut self, value: u32)

Source

pub fn padding_128(&self) -> u32

Zero in every known record

Source

pub fn set_padding_128(&mut self, value: u32)

Source

pub fn unknown_132(&self) -> i32

Source

pub fn set_unknown_132(&mut self, value: i32)

Source

pub fn unknown_136(&self) -> u32

Packed bit field

Source

pub fn set_unknown_136(&mut self, value: u32)

Source

pub fn unknown_140(&self) -> u32

Source

pub fn set_unknown_140(&mut self, value: u32)

Source

pub fn unknown_144(&self) -> u32

Source

pub fn set_unknown_144(&mut self, value: u32)

Source

pub fn unknown_148(&self) -> u8

Source

pub fn set_unknown_148(&mut self, value: u8)

Source

pub fn alpha_fresnel_flags(&self) -> u8

Derived cache the loader recomputes; do not trust over the blob

Source

pub fn set_alpha_fresnel_flags(&mut self, value: u8)

Source

pub fn shader_type(&self) -> MaterialShaderType

Shader family prefix for the permutation name

Source

pub fn set_shader_type(&mut self, value: MaterialShaderType)

Source

pub fn unknown_151(&self) -> u8

Source

pub fn set_unknown_151(&mut self, value: u8)

Source

pub fn effect_name_hash_2(&self) -> u32

Second permutation hash, 0xFFFFFFFF = none (v3+)

Source

pub fn set_effect_name_hash_2(&mut self, value: u32)

Source

pub fn effect_name_hash_3(&self) -> u32

Third permutation hash, 0xFFFFFFFF = none (v3+)

Source

pub fn set_effect_name_hash_3(&mut self, value: u32)

Source

pub fn decode_properties(&self) -> Option<DataDrivenProperties>

Decode propertyBlob into fragment groups and named properties

Source

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.

Source

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.

Source

pub fn version(&self) -> i32

Source

pub fn set_version(&mut self, new_version: i32) -> bool

Source

pub fn force_version(&mut self, new_version: i32)

Trait Implementations§

Source§

impl Debug for DataDrivenMaterial

Source§

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

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

impl Default for DataDrivenMaterial

Source§

fn default() -> Self

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

impl Drop for DataDrivenMaterial

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more
Source§

impl Send for DataDrivenMaterial

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<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.