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

MAYA-104490 Add a basic test for Vp2RenderDelegate geom subset material binding support. #1255

Merged
merged 1 commit into from
Mar 16, 2021
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
4 changes: 4 additions & 0 deletions test/lib/mayaUsd/render/vp2RenderDelegate/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ set(TARGET_NAME VP2_RENDER_DELEGATE_TEST)
# Unit test scripts.
set(TEST_SCRIPT_FILES "")

list(APPEND TEST_SCRIPT_FILES
testVP2RenderDelegateGeomSubset.py
)

if (CMAKE_UFE_V2_FEATURES_AVAILABLE AND PXR_VERSION GREATER_EQUAL 2008)
# The point instance selection tests requires UsdImaging API version 14 or
# later, which is only provided by core USD 20.08 or later.
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env mayapy
#
# Copyright 2021 Autodesk
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

import fixturesUtils
import imageUtils
import mayaUtils
import usdUtils
import testUtils

from mayaUsd import lib as mayaUsdLib
from mayaUsd import ufe as mayaUsdUfe

from maya import cmds

import ufe

import os


class testVP2RenderDelegateGeomSubset(imageUtils.ImageDiffingTestCase):
"""
Tests imaging using the Viewport 2.0 render delegate when using per-instance
inherited data on instances.
"""

@classmethod
def setUpClass(cls):
# The test USD data is authored Z-up, so make sure Maya is configured
# that way too.
cmds.upAxis(axis='z')

inputPath = fixturesUtils.setUpClass(__file__,
initializeStandalone=False, loadPlugin=False)

cls._baselineDir = os.path.join(inputPath,
'VP2RenderDelegateGeomSubsetTest', 'baseline')

cls._testDir = os.path.abspath('.')

def assertSnapshotClose(self, imageName):
baselineImage = os.path.join(self._baselineDir, imageName)
snapshotImage = os.path.join(self._testDir, imageName)
imageUtils.snapshot(snapshotImage, width=960, height=540)
return self.assertImagesClose(baselineImage, snapshotImage)

def _StartTest(self, testName):
cmds.file(force=True, new=True)
cmds.move(2, -2, 1.5, 'persp')
mayaUtils.loadPlugin("mayaUsdPlugin")

self._testName = testName
testFile = testUtils.getTestScene("geomSubset", self._testName + ".usda")
mayaUtils.createProxyFromFile(testFile)
globalSelection = ufe.GlobalSelection.get()
globalSelection.clear()
self.assertSnapshotClose('%s_unselected.png' % self._testName)

def testPerInstanceInheritedData(self):
self._StartTest('perFaceShaders')



if __name__ == '__main__':
fixturesUtils.runTests(globals())
67 changes: 67 additions & 0 deletions test/testSamples/geomSubset/perFaceShaders.usda
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#usda 1.0
(
defaultPrim = "pCube1"
metersPerUnit = 0.01
upAxis = "Z"
)

def Mesh "pCube1" (
prepend apiSchemas = ["MaterialBindingAPI"]
kind = "component"
)
{
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)]
texCoord2f[] primvars:map1 = [(0.375, 0), (0.625, 0), (0.625, 0.25), (0.375, 0.25), (0.625, 0.5), (0.375, 0.5), (0.625, 0.75), (0.375, 0.75), (0.625, 1), (0.375, 1), (0.875, 0), (0.875, 0.25), (0.125, 0), (0.125, 0.25)] (
interpolation = "faceVarying"
)
int[] primvars:map1:indices = [0, 1, 2, 3, 3, 2, 4, 5, 5, 4, 6, 7, 7, 6, 8, 9, 1, 10, 11, 2, 12, 0, 3, 13]
uniform token subsetFamily:materialBind:familyType = "partition"

def Scope "Looks"
{
def Material "initialShadingGroup"
{
}

def Material "lambert2SG"
{
token outputs:surface.connect = </pCube1/Looks/lambert2SG/lambert2.outputs:surface>

def Shader "lambert2"
{
uniform token info:id = "UsdPreviewSurface"
color3f inputs:diffuseColor = (0.8, 0, 0)
normal3f inputs:normal = (1, 1, 1)
float inputs:roughness = 1
int inputs:useSpecularWorkflow = 1
token outputs:displacement
token outputs:surface
}
}
}

def GeomSubset "initialShadingGroup" (
prepend apiSchemas = ["MaterialBindingAPI"]
)
{
uniform token elementType = "face"
uniform token familyName = "materialBind"
int[] indices = [1, 2, 3, 4, 5]
rel material:binding = </pCube1/Looks/initialShadingGroup>
}

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