Skip to content

Commit

Permalink
HYDRA-805 - add test for look through camera&lights (#73)
Browse files Browse the repository at this point in the history
* add test for look through camera&lights

* use different image diff tolerance

* update based on review
  • Loading branch information
lilike-adsk authored Feb 15, 2024
1 parent 09b18f9 commit 5251eca
Show file tree
Hide file tree
Showing 8 changed files with 330 additions and 4 deletions.
1 change: 1 addition & 0 deletions test/lib/mayaUsd/render/mayaToHydra/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES
testMayaLights.py
testUSDLights.py
testArnoldLights.py
testLookThrough.py
testStandardSurface.py
testFlowViewportAPI.py
testStageVariants.py
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
67 changes: 67 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/testLookThrough.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
#
# Copyright 2024 Autodesk, Inc. All rights reserved.
#
# 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 maya.cmds as cmds
import fixturesUtils
import mtohUtils
import mayaUtils
import platform

class TestLookThrough(mtohUtils.MtohTestCase): #Subclassing mtohUtils.MtohTestCase to be able to call self.assertSnapshotClose
# MayaHydraBaseTestCase.setUpClass requirement.
_file = __file__

@property
def imageDiffFailThreshold(self):
return 0.01

@property
def imageDiffFailPercent(self):
# HYDRA-837 : Wireframes seem to have a slightly different color on macOS. We'll increase the thresholds
# for that platform specifically for now, so we can still catch issues on other platforms.
if platform.system() == "Darwin":
return 3
return 0.2

#Test look through camera and maya lights (spot & area).
def test_LookThrough(self):
# Load a maya scene with a maya native cubic
testFile = mayaUtils.openTestScene(
"testLookThrough",
"testLookThrough.ma")
cmds.refresh()

#Verify Default display
panel = mayaUtils.activeModelPanel()
self.assertSnapshotClose("default" + ".png", self.imageDiffFailThreshold, self.imageDiffFailPercent)

#Verify look through camera
cmds.lookThru( panel, 'persp1' )
cmds.refresh()
self.assertSnapshotClose("lookThroughCamera" + ".png", self.imageDiffFailThreshold, self.imageDiffFailPercent)

#Verify look through spot Light
cmds.lookThru( panel, 'spotLight1' )
cmds.refresh()
self.assertSnapshotClose("lookThroughSpotLight" + ".png", self.imageDiffFailThreshold, self.imageDiffFailPercent)

#Verify look through area light, use a small far clip to clip the scene
cmds.lookThru( panel, 'areaLight1', nc=0.0, fc=7.5 )
cmds.refresh()
self.assertSnapshotClose("lookThroughAreaLight" + ".png", self.imageDiffFailThreshold, self.imageDiffFailPercent)

if __name__ == '__main__':
fixturesUtils.runTests(globals())
262 changes: 262 additions & 0 deletions test/testSamples/testLookThrough/testLookThrough.ma

Large diffs are not rendered by default.

4 changes: 0 additions & 4 deletions test/testSamples/testStandardSurface/testStandardSurface.ma
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
//Last modified: Mon, Feb 05, 2024 09:30:35 AM
//Codeset: 1252
requires maya "2025ff02";
requires -nodeType "mayaUsdLayerManager" -dataType "pxrUsdStageData" "mayaUsdPlugin" "0.27.0";
currentUnit -l centimeter -a degree -t film;
fileInfo "application" "maya";
fileInfo "product" "Maya 2025";
Expand Down Expand Up @@ -112,9 +111,6 @@ createNode file -n "file1";
setAttr ".cs" -type "string" "sRGB";
createNode place2dTexture -n "place2dTexture1";
rename -uid "6616C90D-4B36-08C7-8666-33BB13D15663";
createNode mayaUsdLayerManager -n "mayaUsdLayerManager1";
rename -uid "61CE7C31-4E04-09B7-BFEA-F291A58D7E4C";
setAttr ".sst" -type "string" "";
createNode script -n "uiConfigurationScriptNode";
rename -uid "8E0C2C18-4263-5451-E98E-C6B108D65C44";
setAttr ".b" -type "string" (
Expand Down

0 comments on commit 5251eca

Please sign in to comment.