IVERY CHEN

USD MATERIAL TOOL

a weekend project, May 2024
Team:
Ivery Chen
Role:
Software Developer
Tools:
Python, Houdini, USD
01 
Context

Creating a tool that creates USD materials and binds to models

This project converts meshes and texture files in an `Assets` directory and creates a folder named `materials` inside with materials created from the input. The script prints out a visual representation of a dependency graph and reports any missing meshes or textures.
Developed Holofilter in Javascript, a web interaction system that uses screen gyroscopes to enhance user engagement with a mixture of 2D SVGs and 3D assets integrating Three.js.
02 
Research

Learning USD system

The biggest challenge for me is that I haven't previously worked with USD files before. After failing to install OpenUSD, I decided to swtich to Houdini Karma which has a tool similar to OpenUSD. Using that I was able to debug my code. I also looked into USD documentation to learn how to bind materials.
03 
Process

The Approach

The code creates a copy of the input usd file, creates a material from the texture files and bind the material to the output mesh in the usd. For this project, I chose to output a .usd file.
I created a class called `Material`, a class called `Mesh`, and a dictionary called `meshes` that has key value pairs of name -> Mesh.
The script accounts for missing textures and meshes by reporting it in the terminal.
The main call to `create_materials()` is at the bottom of the file. `create_materials()` goes through every file in the input directory, `extract_info` to properly extract the file_name and file_types of the files, populates the `meshes` dictionary, and goes through all items in `meshes` to `create_use_material()`. It also makes a call to `output_dependency_graph()`, which prints out the dependency graph in the terminal with error messages for missing textures or meshes.
Inside `create_usd_material()`, `copy_usd_file()` is called to make a duplicate of the input usd file, create Shaders and bind to the output usd file that is located in ./Assets/materials.
`check_materials()` can be called to check if a material is correctly bounded to a mesh.
04 
Solution

What were some of the assumptions?

Inside `create_usd_material`, assumption is made that for the MetallicRoughnessTexture, two separate inputs of `metallic` and `roughness` are created. I dug around online to find some information about which channel they each are and decided to gow ith `b` and `g` for metallic and roughness respectively.

Outcome

usd_output4usd_output5
usd_output3usd_output1usd_output2
Example output USD files with binded materials