Skip to content

Commit

Permalink
Add unit tests for default material
Browse files Browse the repository at this point in the history
  • Loading branch information
lanierd-adsk committed Jul 18, 2024
1 parent 14bf139 commit d405039
Show file tree
Hide file tree
Showing 8 changed files with 953 additions and 7 deletions.
7 changes: 0 additions & 7 deletions lib/flowViewport/sceneIndex/fvpDefaultMaterialSceneIndex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,6 @@ namespace{
static const TfToken purposes[] = { HdMaterialBindingsSchemaTokens->allPurpose };
}

TF_DEFINE_PRIVATE_TOKENS(
_tokens,
(UsdPreviewSurface)
(ND_standard_surface_surfaceshader)
(MayaDefaultMaterial)
);

// static
DefaultMaterialSceneIndexRefPtr
DefaultMaterialSceneIndex::New(
Expand Down
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 @@ -49,6 +49,7 @@ set(INTERACTIVE_TEST_SCRIPT_FILES
testMayaComponentsPicking.py
testFlowPluginsHierarchicalProperties.py
testCustomShadersNode.py
testMayaDefaultMaterial.py
cpp/testColorPreferences.py
cpp/testCppFramework.py
cpp/testMayaSceneFlattening.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.
45 changes: 45 additions & 0 deletions test/lib/mayaUsd/render/mayaToHydra/testMayaDefaultMaterial.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#
# 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

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

IMAGE_DIFF_FAIL_THRESHOLD = 0.05
IMAGE_DIFF_FAIL_PERCENT = 1.5

def test_MayaDefaultMaterial(self):

# open a Maya scene with maya mesh, usd prims and custom scene indices prims
testFile = mayaUtils.openTestScene(
"TestDefaultMaterial",
"testMayaDefaultMaterial_Native+Usd+dataProducer.ma", useTestSettings=False)
cmds.refresh()
panel = mayaUtils.activeModelPanel()
self.assertSnapshotClose("sceneLoaded" + ".png", self.IMAGE_DIFF_FAIL_THRESHOLD, self.IMAGE_DIFF_FAIL_PERCENT)

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

if __name__ == '__main__':
fixturesUtils.runTests(globals())
Binary file not shown.
Binary file added test/testSamples/testDefaultMaterial/diffuse.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

0 comments on commit d405039

Please sign in to comment.