addNormalTextureToPreviewMaterial#
Fully qualified name: usdex::core::addNormalTextureToPreviewMaterial
- bool usdex::core::addNormalTextureToPreviewMaterial(
- pxr::UsdShadeMaterial &material,
- const pxr::SdfAssetPath &texturePath,
Adds a normals texture to a preview material.
It is expected that the material was created by
definePreviewMaterial()The texture will be sampled using texture coordinates from the default UV set (generally named
primvars:st).The UsdPreviewSurface specification requires the texture reader to provide data that is properly scaled and ready to be consumed as a tangent space normal. Textures stored in 8-bit file formats require scale and bias adjustment to transform the normals into tangent space.
This module cannot read the provided
texturePathto inspect the channel data (the file may not resolve locally, or even exist yet). To account for this, it performs the scale and bias adjustment when thetexturePathextension matches a list of known 8-bit formats:["bmp", "tga", "jpg", "jpeg", "png", "tif"]. Similarly, it assumes that the raw normals data was written into the file, regardless of any file format specific color space metadata. If either of these assumptions is incorrect for your source data, you will need to adjust thescale,bias, andsourceColorSpacesettings after calling this function.Note
If you intend to create a Material Interface, it is preferable to author all initial shader attributes (including textures) before calling
addPreviewMaterialInterface(). This function will not attempt to reconcile any existing inputs on the Material.- Parameters:
material – The material prim
texturePath – The
SdfAssetPathto the texture file
- Returns:
Whether or not the texture was added to the material