diff --git a/pxr/usd/bin/usdchecker/CMakeLists.txt b/pxr/usd/bin/usdchecker/CMakeLists.txt index 173f584a57..18e489c09b 100644 --- a/pxr/usd/bin/usdchecker/CMakeLists.txt +++ b/pxr/usd/bin/usdchecker/CMakeLists.txt @@ -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 +) diff --git a/pxr/usd/bin/usdchecker/testenv/testUsdChecker/clean/cleanNormalMapReader.usda b/pxr/usd/bin/usdchecker/testenv/testUsdChecker/clean/cleanNormalMapReader.usda index c11e3caf47..aa8ef11c44 100644 --- a/pxr/usd/bin/usdchecker/testenv/testUsdChecker/clean/cleanNormalMapReader.usda +++ b/pxr/usd/bin/usdchecker/testenv/testUsdChecker/clean/cleanNormalMapReader.usda @@ -35,5 +35,34 @@ def "World" normal3f inputs:normal.connect = } } -} + # 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 = + 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 = + float3 outputs:rgb + } + + def Shader "Surface" + { + uniform token info:id = "UsdPreviewSurface" + color3f inputs:diffuseColor.connect = + normal3f inputs:normal.connect = + } + } +} diff --git a/pxr/usd/usdUtils/complianceChecker.py b/pxr/usd/usdUtils/complianceChecker.py index 3d19cb3bef..b3e6182de0 100644 --- a/pxr/usd/usdUtils/complianceChecker.py +++ b/pxr/usd/usdUtils/complianceChecker.py @@ -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