Material and Shader Prims for use with the RTX Renderer#

Utility functions for creating, editing, and querying MDL Materials and Shaders for use with the RTX Renderer.

Authoring MDL Shaders for the RTX Renderer#

This module provides functions for creating UsdShadeShaders that map to MDL Shaders and UsdShadeInputs that map to MDL Inputs.

Defining Materials for the RTX Renderer#

The RTX Renderer supports several types of UsdShadeShaders, but it is most performant & results will be more photorealistic when using MDL shaders, especially those from the Core MDL Materials, like:

Several functions below assist with authoring and adding textures to PBR and Glass Materials that are specifically tailored for the RTX Renderer.

To make the authored USD data more portable across the USD Ecosystem, these functions also author a Preview shader network (see Material and Shader Prims applicable to all render contexts), and both shader networks are driven from a top-level “Material Interface” on the UsdShadeMaterial prim. The resulting USD can be rendered in the RTX Renderer for the highest fidelity results, as well as in any other USD capable renderer for a lower fidelity preview.

Warning

If your data is targetted at the RTX Renderer, or other USD native applications or USD Ecosystem leading applications, then using Material Interfaces is recommended. If you favor broad applicability throughout the entire USD Ecosystem, it may be be preferable to avoid Material Interfaces for the time being. In this case, you can call usdex::core::removeMaterialInterface after usdex::rtx::definePbrMaterial

Functions#

bool usdex::rtx::addDiffuseTextureToPbrMaterial(pxr::UsdShadeMaterial &material, const pxr::SdfAssetPath &texturePath)

Adds a diffuse texture to the PBR material.

bool usdex::rtx::addMetallicTextureToPbrMaterial(pxr::UsdShadeMaterial &material, const pxr::SdfAssetPath &texturePath)

Adds a metallic texture to the PBR material.

bool usdex::rtx::addNormalTextureToPbrMaterial(pxr::UsdShadeMaterial &material, const pxr::SdfAssetPath &texturePath)

Adds a normal texture to the PBR material.

bool usdex::rtx::addOpacityTextureToPbrMaterial(pxr::UsdShadeMaterial &material, const pxr::SdfAssetPath &texturePath)

Adds an opacity texture to the PBR material.

bool usdex::rtx::addOrmTextureToPbrMaterial(pxr::UsdShadeMaterial &material, const pxr::SdfAssetPath &texturePath)

Adds an ORM (occlusion, roughness, metallic) texture to the PBR material.

bool usdex::rtx::addRoughnessTextureToPbrMaterial(pxr::UsdShadeMaterial &material, const pxr::SdfAssetPath &texturePath)

Adds a roughness texture to the PBR material.

pxr::UsdShadeShader usdex::rtx::computeEffectiveMdlSurfaceShader(const pxr::UsdShadeMaterial &material)

Get the effective surface Shader of a Material for the MDL render context.

pxr::UsdShadeShader usdex::rtx::createMdlShader(pxr::UsdShadeMaterial &material, const std::string &name, const pxr::SdfAssetPath &mdlPath, const pxr::TfToken &module, bool connectMaterialOutputs=true)

Create a UsdShadeShader as a child of the UsdShadeMaterial argument with the specified MDL.

pxr::UsdShadeInput usdex::rtx::createMdlShaderInput(pxr::UsdShadeMaterial &material, const pxr::TfToken &name, const pxr::VtValue &value, const pxr::SdfValueTypeName &typeName, std::optional< const usdex::core::ColorSpace > colorSpace=std::nullopt)

Create an MDL shader input.

pxr::UsdShadeMaterial usdex::rtx::defineGlassMaterial(pxr::UsdPrim parent, const std::string &name, const pxr::GfVec3f &color, const float indexOfRefraction=1.491f)

Defines a Glass UsdShadeMaterial interface that drives both an RTX render context and the universal render context.

pxr::UsdShadeMaterial usdex::rtx::defineGlassMaterial(pxr::UsdStagePtr stage, const pxr::SdfPath &path, const pxr::GfVec3f &color, const float indexOfRefraction=1.491f)

Defines a Glass UsdShadeMaterial interface that drives both an RTX render context and the universal render context.

pxr::UsdShadeMaterial usdex::rtx::definePbrMaterial(pxr::UsdStagePtr stage, const pxr::SdfPath &path, const pxr::GfVec3f &color, const float opacity=1.0f, const float roughness=0.5f, const float metallic=0.0f)

Defines a PBR UsdShadeMaterial interface that drives both an RTX render context and the universal render context.

pxr::UsdShadeMaterial usdex::rtx::definePbrMaterial(pxr::UsdPrim parent, const std::string &name, const pxr::GfVec3f &color, const float opacity=1.0f, const float roughness=0.5f, const float metallic=0.0f)

Defines a PBR UsdShadeMaterial interface that drives both an RTX render context and the universal render context.