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

HYDRA-1368 - Apply default material on geomSubset #250

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
3 changes: 3 additions & 0 deletions lib/flowViewport/sceneIndex/fvpDefaultMaterialSceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ namespace{
HdPrimTypeTokens->sphere,
HdPrimTypeTokens->capsule,
HdPrimTypeTokens->capsule_1,
#if PXR_VERSION >= 2403 // USD 24.03+
HdPrimTypeTokens->geomSubset,
#endif
#if HD_API_VERSION >= 67 // USD 24.05+
UsdGeomTokens->TetMesh,
#endif
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
15 changes: 14 additions & 1 deletion test/lib/mayaUsd/render/mayaToHydra/testMayaDefaultMaterial.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,19 @@ def test_MayaDefaultMaterialUsdPrims(self):
cmds.modelEditor(panel, edit=True, useDefaultMaterial=True)
cmds.refresh()
self.assertSnapshotClose("defaultMaterialUsdPrims" + ".png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)


def test_MayaDefaultMaterialGeomSubset(self):
# open a Maya scene with usd cube with different materials on some faces (geomSubset)
testFile = mayaUtils.openTestScene(
"testDefaultMaterial",
"testMayaDefaultMaterial_Usd_geomSubset.ma", useTestSettings=False)
cmds.refresh()

#Use Default Material
panel = mayaUtils.activeModelPanel()
cmds.modelEditor(panel, edit=True, useDefaultMaterial=True)
cmds.refresh()
self.assertSnapshotClose("defaultMaterialGeomSubsetUsdPrims.png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test works in all relevant USD versions, even if the fix only applies to 24.03+

if __name__ == '__main__':
fixturesUtils.runTests(globals())
119 changes: 119 additions & 0 deletions test/testSamples/testDefaultMaterial/cube_geomsubset_material.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
#usda 1.0
(
metersPerUnit = 0.01
upAxis = "Y"
)

def Mesh "pCube1"
{
uniform bool doubleSided = 1
float3[] extent = [(-0.5, -0.5, -0.5), (0.5, 0.5, 0.5)]
int[] faceVertexCounts = [4, 4, 4, 4, 4, 4]
int[] faceVertexIndices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 1, 0, 1, 7, 5, 3, 6, 0, 2, 4]
point3f[] points = [(-0.5, -0.5, 0.5), (0.5, -0.5, 0.5), (-0.5, 0.5, 0.5), (0.5, 0.5, 0.5), (-0.5, 0.5, -0.5), (0.5, 0.5, -0.5), (-0.5, -0.5, -0.5), (0.5, -0.5, -0.5)]
color3f[] primvars:displayColor = [(1, 1, 1)] (
customData = {
dictionary Maya = {
bool generated = 1
}
}
)
texCoord2f[] primvars:st = [(0.375, 0), (0.625, 0), (0.375, 0.25), (0.625, 0.25), (0.375, 0.5), (0.625, 0.5), (0.375, 0.75), (0.625, 0.75), (0.375, 1), (0.625, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] (
customData = {
dictionary Maya = {
token name = "map1"
}
}
interpolation = "faceVarying"
)
int[] primvars:st:indices = [0, 1, 3, 2, 2, 3, 5, 4, 4, 5, 7, 6, 6, 7, 9, 8, 1, 10, 11, 3, 12, 0, 2, 13]
uniform token subdivisionScheme = "none"
token visibility = "inherited"

def GeomSubset "back" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
uniform token elementType = "face"
uniform token familyName = "materialBind"
int[] indices = [2]
rel material:binding = </mtl/UsdPreviewSurface1>
}

def GeomSubset "bottom" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
uniform token elementType = "face"
uniform token familyName = "materialBind"
int[] indices = [3]
rel material:binding = </mtl/UsdPreviewSurface2>
}

def GeomSubset "front" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
uniform token elementType = "face"
uniform token familyName = "materialBind"
int[] indices = [0]
rel material:binding = </mtl/UsdPreviewSurface2>
}

def GeomSubset "left" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
uniform token elementType = "face"
uniform token familyName = "materialBind"
int[] indices = [5]
rel material:binding = </mtl/UsdPreviewSurface1>
}

def GeomSubset "right" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
uniform token elementType = "face"
uniform token familyName = "materialBind"
int[] indices = [4]
rel material:binding = </mtl/UsdPreviewSurface1>
}

def GeomSubset "top" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
uniform token elementType = "face"
uniform token familyName = "materialBind"
int[] indices = [1]
rel material:binding = </mtl/UsdPreviewSurface1>
}
}

def Scope "mtl"
{
def Material "UsdPreviewSurface1"
{
token outputs:mtlx:surface.connect = </mtl/UsdPreviewSurface1/UsdPreviewSurface1.outputs:out>

def Shader "UsdPreviewSurface1"
{
uniform token info:id = "ND_UsdPreviewSurface_surfaceshader"
color3f inputs:diffuseColor = (0.11746801, 0.3031008, 0.502)
token outputs:out
}
}

def Material "UsdPreviewSurface2"
{
token outputs:mtlx:surface.connect = </mtl/UsdPreviewSurface2/UsdPreviewSurface1.outputs:out>

def Shader "UsdPreviewSurface1"
{
uniform token info:id = "ND_UsdPreviewSurface_surfaceshader"
color3f inputs:diffuseColor = (0.19255124, 0.369, 0.129888)
token outputs:out
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ createNode mayaUsdProxyShape -n "PoolBallFlat_animatedShape" -p "PoolBallFlat_an
setAttr -k off ".v";
setAttr ".covm[0]" 0 1 1;
setAttr ".cdvm[0]" 0 1 1;
setAttr ".fp" -type "string" "D:/GIT/maya-hydra-opensource/test/testSamples/testMayaDisplayModes/PoolBallFlat_animated.usdz";
setAttr ".fp" -type "string" "./PoolBallFlat_animated.usdz";
setAttr ".pp" -type "string" "";
setAttr ".epp" -type "string" "";
setAttr ".forceCompute" yes;
setAttr ".usdStageLoadRules" -type "string" "/=all";
setAttr ".usdStageTargetLayer" -type "string" "d:/GIT/maya-hydra-opensource/test/testSamples/testMayaDisplayModes/PoolBallFlat_animated.usdz";
setAttr ".usdStageTargetLayer" -type "string" "./PoolBallFlat_animated.usdz";
createNode transform -n "transform2";
rename -uid "A4CC2302-4EF0-4586-50E8-95B561823CB7";
setAttr ".hio" yes;
Expand Down Expand Up @@ -215,7 +215,7 @@ createNode materialInfo -n "materialInfo1";
rename -uid "7EDBBFC1-408E-88F9-60B5-92952E9FF145";
createNode file -n "file1";
rename -uid "5188C934-4F83-B99E-E040-76AC013ACF09";
setAttr ".ftn" -type "string" "D:/GIT/maya-hydra-opensource/test/testSamples/testDefaultMaterial/diffuse.png";
setAttr ".ftn" -type "string" "./diffuse.png";
setAttr ".cs" -type "string" "sRGB";
createNode place2dTexture -n "place2dTexture1";
rename -uid "04CBC7D7-4960-B0CA-41AE-2580A4E5A123";
Expand Down
Loading