-
Notifications
You must be signed in to change notification settings - Fork 202
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2378 from Autodesk/vlasovi/MAYA-123350
Creating a testVP2RenderDelegateLight test
- Loading branch information
Showing
10 changed files
with
178 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+8.03 KB
...r/vp2RenderDelegate/VP2RenderDelegateLightsTest/baseline/RenderLights_moved.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10.1 KB
...p2RenderDelegate/VP2RenderDelegateLightsTest/baseline/RenderLights_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+8.92 KB
...enderDelegate/VP2RenderDelegateLightsTest/baseline/RenderLights_stage_moved.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.9 KB
...erDelegate/VP2RenderDelegateLightsTest/baseline/RenderLights_stage_selected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+10 KB
...RenderDelegate/VP2RenderDelegateLightsTest/baseline/RenderLights_unselected.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added
BIN
+9.63 KB
...erDelegate/VP2RenderDelegateLightsTest/baseline/RenderLights_with_new_light.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
125 changes: 125 additions & 0 deletions
125
test/lib/mayaUsd/render/vp2RenderDelegate/testVP2RenderDelegateLights.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,125 @@ | ||
#!/usr/bin/env mayapy | ||
# | ||
# Copyright 2022 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 ufe as mayaUsdUfe | ||
|
||
from maya import cmds | ||
|
||
import ufe | ||
import os | ||
|
||
class testVP2RenderDelegateLights(imageUtils.ImageDiffingTestCase): | ||
""" | ||
Tests imaging using the Viewport 2.0 render delegate when using lights | ||
""" | ||
|
||
@classmethod | ||
def setUpClass(cls): | ||
inputPath = fixturesUtils.setUpClass(__file__, | ||
initializeStandalone=False, loadPlugin=False) | ||
|
||
cls._baselineDir = os.path.join(inputPath, | ||
'VP2RenderDelegateLightsTest', '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) | ||
mayaUtils.loadPlugin("mayaUsdPlugin") | ||
self._testName = testName | ||
testFile = testUtils.getTestScene("light", self._testName + ".usda") | ||
mayaUtils.createProxyFromFile(testFile) | ||
|
||
def _RunTest(self): | ||
cmds.setAttr('stageShape.cplx', 1) | ||
|
||
# reparent one of the lights to verify that the proxy light handles this properly | ||
# !this check is temporarily disabled because of a bug in PathSubject::addRemoveAllCallbackHelper | ||
#cmds.parent('|stage|stageShape,/lights/spotLight', '|stage|stageShape,/lights2') | ||
|
||
# unselect all and compare images | ||
globalSelection = ufe.GlobalSelection.get() | ||
globalSelection.clear() | ||
self.assertSnapshotClose('%s_unselected.png' % (self._testName)) | ||
|
||
# select all 4 lights and compare images | ||
selection = ufe.Selection() | ||
selection.append(self._GetSceneItem('|stage|stageShape', '/lights/spotLight')) | ||
selection.append(self._GetSceneItem('|stage|stageShape', '/lights/pointLight')) | ||
selection.append(self._GetSceneItem('|stage|stageShape', '/lights/directionalLight')) | ||
selection.append(self._GetSceneItem('|stage|stageShape', '/lights/areaLight')) | ||
globalSelection.replaceWith(selection) | ||
self.assertSnapshotClose('%s_selected.png' % (self._testName)) | ||
|
||
# move all 4 lights and compare images | ||
cmds.move(-2, -2, -2, relative=True) | ||
self.assertSnapshotClose('%s_moved.png' % (self._testName)) | ||
|
||
# rename the stage to verify that the proxy light handles this properly | ||
cmds.rename('|stage', 'stage2') | ||
|
||
# select the stage and compare images | ||
globalSelection.clear() | ||
cmds.select('|stage2') | ||
self.assertSnapshotClose('%s_stage_selected.png' % (self._testName)) | ||
|
||
# delete one of the lights to verify that the proxy light handles this properly | ||
cmds.delete('|stage2|stage2Shape,/lights/pointLight') | ||
|
||
# move the stage and compare images | ||
cmds.move(4, 4, 4, absolute=True) | ||
self.assertSnapshotClose('%s_stage_moved.png' % (self._testName)) | ||
|
||
# add a new USD light and compare images | ||
stage = mayaUsdUfe.getStage("|stage2|stage2Shape") | ||
stage.DefinePrim('/lights2/pointLight2', "SphereLight") | ||
cmds.select( clear=True ) | ||
self.assertSnapshotClose('%s_with_new_light.png' % (self._testName)) | ||
|
||
def _GetSceneItem(self, mayaPathString, usdPathString): | ||
mayaPathSegment = mayaUtils.createUfePathSegment(mayaPathString) | ||
usdPathSegment = usdUtils.createUfePathSegment(usdPathString) | ||
ufePath = ufe.Path([mayaPathSegment, usdPathSegment]) | ||
ufeItem = ufe.Hierarchy.createItem(ufePath) | ||
return ufeItem | ||
|
||
def testPoints(self): | ||
self._StartTest('RenderLights') | ||
|
||
cmds.move(-10, 15, 20, 'persp') | ||
cmds.rotate(-30, -30, 0, 'persp') | ||
cmds.modelEditor('modelPanel4', edit=True, grid=False, displayLights = 'all') | ||
cmds.displayColor('light', 21, active=True) | ||
|
||
self._RunTest() | ||
|
||
|
||
|
||
if __name__ == '__main__': | ||
fixturesUtils.runTests(globals()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#usda 1.0 | ||
( | ||
) | ||
|
||
def Xform "lights" | ||
{ | ||
def SphereLight "spotLight" | ||
{ | ||
double3 xformOp:translate = (3, 3, 0) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
|
||
color3f inputs:color = (1, 1, 1) | ||
|
||
float inputs:shaping:focus = 0.5 | ||
float inputs:shaping:cone:angle = 50 | ||
float inputs:shaping:cone:softness = 0.1 | ||
} | ||
|
||
def SphereLight "pointLight" | ||
{ | ||
double3 xformOp:translate = (0, 3, 0) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
|
||
color3f inputs:color = (1, 0, 0) | ||
} | ||
|
||
def DistantLight "directionalLight" | ||
{ | ||
color3f inputs:color = (0, 0, 1) | ||
float inputs:intensity = 1 | ||
} | ||
|
||
def RectLight "areaLight" | ||
{ | ||
double3 xformOp:translate = (3, 0, 0) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
|
||
color3f inputs:color = (0, 1, 0) | ||
} | ||
} | ||
|
||
def Xform "lights2" | ||
{ | ||
} | ||
|
||
def Sphere "sphere1" | ||
{ | ||
float3 xformOp:translate = (2.78, 0, -2.56) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters