Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using get value producing attrs when checking texture assets in NormalMapTextureChecker #2885

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions pxr/usd/bin/usdchecker/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,3 +144,13 @@ pxr_register_test(testUsdChecker12
EXPECTED_RETURN_CODE 1
)

pxr_install_test_dir(
SRC testenv/testUsdChecker
DEST testUsdChecker13
)

pxr_register_test(testUsdChecker13
PYTHON
COMMAND "${CMAKE_INSTALL_PREFIX}/bin/usdchecker clean/cleanNormalMapReader.usda"
EXPECTED_RETURN_CODE 0
)
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,34 @@ def "World"
normal3f inputs:normal.connect = </World/material/NormalMap.outputs:rgb>
}
}
}

# Normal map compliance checker should handle connected asset attributes.
def Material "assetOnMaterial"
{
asset inputs:file = @texture.jpg@

def Shader "ColorMap"
{
uniform token info:id = "UsdUVTexture"
asset inputs:file.connect = </World/assetOnMaterial.inputs:file>
float3 outputs:rgb
}

def Shader "NormalMap"
{
uniform token info:id = "UsdUVTexture"
token inputs:sourceColorSpace = "raw"
float4 inputs:scale = (2.0, 2.0, 2.0, 1.0)
float4 inputs:bias = (-1.0, -1.0, -1.0, 0.0)
asset inputs:file.connect = </World/assetOnMaterial.inputs:file>
float3 outputs:rgb
}

def Shader "Surface"
{
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor.connect = </World/assetOnMaterial/ColorMap.outputs:rgb>
normal3f inputs:normal.connect = </World/assetOnMaterial/NormalMap.outputs:rgb>
}
}
}
14 changes: 11 additions & 3 deletions pxr/usd/usdUtils/complianceChecker.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,13 +458,21 @@ def _TextureIs8Bit(self, asset):
ext = Ar.GetResolver().GetExtension(asset.resolvedPath)
# not an exhaustive list, but ones we typically can read
return ext in ["bmp", "tga", "jpg", "jpeg", "png", "tif"]

def _GetInputValue(self, shader, inputName):
from pxr import Usd
from pxr import Usd, UsdShade
input = shader.GetInput(inputName)
if not input:
return None
return input.Get(Usd.TimeCode.EarliestTime())
# Query value producing attributes for input values.
# This has to be a length of 1, otherwise no attribute is producing a value.
valueProducingAttrs = UsdShade.Utils.GetValueProducingAttributes(input)
if not valueProducingAttrs or len(valueProducingAttrs) != 1:
return None
# We require an input parameter producing the value.
if not UsdShade.Input.IsInput(valueProducingAttrs[0]):
return None
return valueProducingAttrs[0].Get(Usd.TimeCode.EarliestTime())

def CheckPrim(self, prim):
from pxr import UsdShade, Gf
Expand Down