addPrimvarShaderToPreviewMaterial#

Fully qualified name: usdex::core::addPrimvarShaderToPreviewMaterial

bool usdex::core::addPrimvarShaderToPreviewMaterial(
pxr::UsdShadeMaterial &material,
const std::string &surfaceInputName,
const std::string &primvarName,
const pxr::VtValue &fallbackValue = pxr::VtValue(),
)#

Adds a primvar reader shader to the material prim and connects it to a surface input.

It is expected that the material was created by definePreviewMaterial()

Note

This function will only work on the surface shader, UsdPreviewSurface, not shaders within the shader network. For connecting inputs within a shader network, use connectPrimvarShader().

Parameters:
  • material – The material prim

  • surfaceInputName – The name of the input on the surface shader (not including the inputs: prefix, eg. diffuseColor)

  • primvarName – The name of the primvar to read (not including the primvars: prefix, eg. paintColor)

  • fallbackValue – An optional fallback value to use if the primvar is not found

Returns:

Whether or not the primvar shader was added to the material