MaterialXUSD 0.0.1
Utilities for using MaterialX with USD
|
Sample converter from MaterialX to USD. More...
Public Member Functions | |
__init__ (self, logger=None) | |
Constructor. | |
log (self, msg, level=0) | |
Log a message. | |
get_usd_types (self) | |
Retrieve a list of USD Sdf value type names. | |
map_mtlx_to_usd_type (self, str mtlx_type) | |
Map a MaterialX type to a USD Sdf type.The mapping is easier from MaterialX as the number of type variations is much less. | |
map_mtlx_to_usd_value (self, mtlx_type, mtlx_value) | |
Map a MaterialX value of a given type to a USD value. | |
map_mtlx_to_usd_shader_notation (self, name) | |
Utility to map from MaterialX shader notation to USD notation. | |
emit_usd_connections (self, node, stage, root_path) | |
Emit connections between MaterialX elements as USD connections for a given MaterialX node. | |
emit_usd_value_elements (self, node, usd_node, emit_all_value_elements) | |
Emit MaterialX value elements in USD. | |
set_prim_mtlx_version (self, Usd.Prim prim, str version) | |
Set the MaterialX version on a prim. | |
emit_usd_shader_graph (self, doc, stage, mtlx_nodes, emit_all_value_elements, root="/MaterialX/Materials/") | |
Emit USD shader graph to a given stage from a list of MaterialX nodes. | |
find_materialx_nodes (self, doc) | |
Find all nodes in a MaterialX document. | |
emit_document_metadata (self, doc, stage) | |
Emit MaterialX document metadata to the USD stage. | |
emit (self, mtlx_file_name, emit_all_value_elements) | |
Read in a MaterialX file and emit it to a new USD Stage. | |
create_library_document (self) | |
Create a MaterialX library document. | |
Public Attributes | |
logger = logger | |
int | logger = 1: |
Sample converter from MaterialX to USD.
Definition at line 9 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.__init__ | ( | self, | |
logger = None ) |
Constructor.
logger | Logger object. |
Definition at line 13 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.create_library_document | ( | self | ) |
Create a MaterialX library document.
Definition at line 486 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.emit | ( | self, | |
mtlx_file_name, | |||
emit_all_value_elements ) |
Read in a MaterialX file and emit it to a new USD Stage.
Dump results for display and save to usda file.
mtlx_file_name | Name of file containing MaterialX document. Assumed to end in ".mtlx". |
emit_all_value_elements | Emit value elements based on node definition, even if not specified on node instance. |
Definition at line 457 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.emit_document_metadata | ( | self, | |
doc, | |||
stage ) |
Emit MaterialX document metadata to the USD stage.
doc | MaterialX document. |
stage | USD stage. |
Definition at line 439 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.emit_usd_connections | ( | self, | |
node, | |||
stage, | |||
root_path ) |
Emit connections between MaterialX elements as USD connections for a given MaterialX node.
node | MaterialX node to examine. |
stage | USD stage to write connection to. |
root_path | Root path for connections. |
Definition at line 122 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.emit_usd_shader_graph | ( | self, | |
doc, | |||
stage, | |||
mtlx_nodes, | |||
emit_all_value_elements, | |||
root = "/MaterialX/Materials/" ) |
Emit USD shader graph to a given stage from a list of MaterialX nodes.
doc | MaterialX source document. |
stage | USD target stage. |
mtlx_nodes | MaterialX shader nodes. |
emit_all_value_elements | Emit value elements based on node definition, even if not specified on node instance. |
root | Root path for the shader graph. |
Definition at line 363 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.emit_usd_value_elements | ( | self, | |
node, | |||
usd_node, | |||
emit_all_value_elements ) |
Emit MaterialX value elements in USD.
node | MaterialX node with value elements to scan. |
usd_node | UsdShade node to create value elements on. |
emit_all_value_elements | Emit value elements based on node definition, even if not specified on node instance. |
Definition at line 258 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.find_materialx_nodes | ( | self, | |
doc ) |
Find all nodes in a MaterialX document.
doc | MaterialX document. |
Definition at line 423 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.get_usd_types | ( | self | ) |
Retrieve a list of USD Sdf value type names.
Definition at line 38 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.log | ( | self, | |
msg, | |||
level = 0 ) |
Log a message.
msg | Message to log. |
level | Log level. |
Definition at line 20 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.map_mtlx_to_usd_shader_notation | ( | self, | |
name ) |
Utility to map from MaterialX shader notation to USD notation.
name | MaterialX shader notation. |
Definition at line 108 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.map_mtlx_to_usd_type | ( | self, | |
str | mtlx_type ) |
Map a MaterialX type to a USD Sdf type.The mapping is easier from MaterialX as the number of type variations is much less.
Note that one USD type is chosen with no options for choosing things like precision.
mtlx_type | MaterialX type. |
Definition at line 49 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.map_mtlx_to_usd_value | ( | self, | |
mtlx_type, | |||
mtlx_value ) |
Map a MaterialX value of a given type to a USD value.
TODO: Add all types here. This does not seem to be exposed in Python? See: https://openusd.org/dev/api/struct_usd_mtlx_usd_type_info.html
mtlx_type | MaterialX type. |
mtlx_value | MaterialX value. |
Definition at line 74 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.set_prim_mtlx_version | ( | self, | |
Usd.Prim | prim, | ||
str | version ) |
Set the MaterialX version on a prim.
See: https://openusd.org/dev/api/class_usd_mtlx_material_x_config_a_p_i.html
prim | USD prim. |
version | MaterialX version string. |
Definition at line 343 of file materialxusd_custom.py.
materialxusd.materialxusd_custom.MtlxToUsd.logger = logger |
Definition at line 18 of file materialxusd_custom.py.
int materialxusd.materialxusd_custom.MtlxToUsd.logger = 1: |
Definition at line 26 of file materialxusd_custom.py.