Welcome to Python-flavored Magnum! Please note that, while already being rather stable, this functionality is still considered experimental and some APIs might get changed without preserving full backwards compatibility.

magnum.materialtools module

Material tools

Enums

class MergeConflicts: FAIL = 0 KEEP_FIRST_IF_SAME_TYPE = 1 KEEP_FIRST_IGNORE_TYPE = 2
Material merge conflict resolution
class PhongToPbrMetallicRoughnessFlags: KEEP_ORIGINAL_ATTRIBUTES = 1 DROP_UNCOVERTIBLE_ATTRIBUTES = 2 FAIL_ON_UNCONVERTIBLE_ATTRIBUTES = 6 NONE = 0 ALL = -1
Phong to PBR conversion flags

Functions

def copy(material: trade.MaterialData) -> trade.MaterialData
Make an owned copy of the material
def filter_attributes(material: trade.MaterialData, attributes_to_keep: corrade.containers.BitArrayView, types_to_keep: trade.MaterialTypes = trade.MaterialTypes.ALL) -> trade.MaterialData
Filter material attributes
def filter_attributes_layers(material: trade.MaterialData, attributes_to_keep: corrade.containers.BitArrayView, layers_to_keep: corrade.containers.BitArrayView, types_to_keep: trade.MaterialTypes = trade.MaterialTypes.ALL) -> trade.MaterialData
Filter material attributes and layers
def filter_layers(material: trade.MaterialData, layers_to_keep: corrade.containers.BitArrayView, types_to_keep: trade.MaterialTypes = trade.MaterialTypes.ALL) -> trade.MaterialData
Filter material layers
def merge(first: trade.MaterialData, second: trade.MaterialData, conflicts: MergeConflicts = MergeConflicts.FAIL) -> trade.MaterialData
Merge two materials
def phong_to_pbr_metallic_roughness(material: trade.MaterialData, flags: PhongToPbrMetallicRoughnessFlags = PhongToPbrMetallicRoughnessFlags.NONE) -> trade.MaterialData
Convert a Phong material to PBR metallic/roughness
def remove_duplicates(materials: list[trade.MaterialData]) -> tuple[list[int], int]
Remove duplicate materials from a list

Function documentation

def magnum.materialtools.filter_attributes(material: trade.MaterialData, attributes_to_keep: corrade.containers.BitArrayView, types_to_keep: trade.MaterialTypes = trade.MaterialTypes.ALL) -> trade.MaterialData

Filter material attributes

Exceptions
AssertionError If size of attributes_to_keep is different than trade.MaterialData.attribute_data_offset() for trade.MaterialData.layer_count

def magnum.materialtools.filter_attributes_layers(material: trade.MaterialData, attributes_to_keep: corrade.containers.BitArrayView, layers_to_keep: corrade.containers.BitArrayView, types_to_keep: trade.MaterialTypes = trade.MaterialTypes.ALL) -> trade.MaterialData

Filter material attributes and layers

Exceptions
AssertionError If size of attributes_to_keep is different than trade.MaterialData.attribute_data_offset() for trade.MaterialData.layer_count
AssertionError If size of layers_to_keep is different than trade.MaterialData.layer_count

def magnum.materialtools.filter_layers(material: trade.MaterialData, layers_to_keep: corrade.containers.BitArrayView, types_to_keep: trade.MaterialTypes = trade.MaterialTypes.ALL) -> trade.MaterialData

Filter material layers

Exceptions
AssertionError If size of layers_to_keep is different than trade.MaterialData.layer_count

def magnum.materialtools.merge(first: trade.MaterialData, second: trade.MaterialData, conflicts: MergeConflicts = MergeConflicts.FAIL) -> trade.MaterialData

Merge two materials

Exceptions
RuntimeError If merge failed due to a conflict

def magnum.materialtools.phong_to_pbr_metallic_roughness(material: trade.MaterialData, flags: PhongToPbrMetallicRoughnessFlags = PhongToPbrMetallicRoughnessFlags.NONE) -> trade.MaterialData

Convert a Phong material to PBR metallic/roughness

Exceptions
RuntimeError If conversion failed