Skip to content

Commit

Permalink
Merge pull request #2870 from Autodesk/gamaj/fix_untextured_surface
Browse files Browse the repository at this point in the history
Fix untextured rendering of ND_surface
  • Loading branch information
seando-adsk authored Feb 16, 2023
2 parents b28eef6 + 2ad7d37 commit fa3bef0
Show file tree
Hide file tree
Showing 6 changed files with 107 additions and 2 deletions.
12 changes: 12 additions & 0 deletions lib/mayaUsd/render/vp2RenderDelegate/material.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -245,6 +245,8 @@ TF_DEFINE_PRIVATE_TOKENS(

(USD_Mtlx_VP2_Material)
(NG_Maya)
(ND_surface)
(ND_standard_surface_surfaceshader)
(image)
(tiledimage)
(i_geomprop_)
Expand Down Expand Up @@ -1860,6 +1862,16 @@ void ConvertNetworkMapToUntextured(HdMaterialNetworkMap& networkMap)
auto eraseBegin = std::remove_if(network.nodes.begin(), network.nodes.end(), isInputNode);
network.nodes.erase(eraseBegin, network.nodes.end());
network.relationships.clear();
#ifdef WANT_MATERIALX_BUILD
// Raw MaterialX surface constructor node does not render. Replace with default
// standard_surface:
for (auto& node : network.nodes) {
if (node.identifier == _mtlxTokens->ND_surface) {
node.identifier = _mtlxTokens->ND_standard_surface_surfaceshader;
node.parameters.clear();
}
}
#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.
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.
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ def assertSnapshotClose(self, imageName, w=960, h=540):
imageUtils.snapshot(snapshotImage, width=w, height=h)
return self.assertImagesClose(baselineImage, snapshotImage)

def _StartTest(self, testName):
def _StartTest(self, testName, textured=True):
mayaUtils.loadPlugin("mayaUsdPlugin")
panel = mayaUtils.activeModelPanel()
cmds.modelEditor(panel, edit=True, displayTextures=True)
cmds.modelEditor(panel, edit=True, displayTextures=textured)

self._testName = testName
testFile = testUtils.getTestScene("MaterialX", self._testName + ".usda")
Expand Down Expand Up @@ -89,6 +89,8 @@ def testMayaSurfaces(self):
self._StartTest('MayaSurfaces_flat')
cmds.modelEditor(panel, edit=True, displayLights="default")

self._StartTest('MayaSurfaces_untextured', False)

@unittest.skipIf(os.getenv('MATERIALX_VERSION', '1.38.0') < '1.38.4', 'Test has a glTf PBR surface only found in MaterialX 1.38.4 and later.')
def testTransparency(self):
mayaUtils.loadPlugin("mayaUsdPlugin")
Expand Down
91 changes: 91 additions & 0 deletions test/testSamples/MaterialX/MayaSurfaces.usda
Original file line number Diff line number Diff line change
Expand Up @@ -344,3 +344,94 @@ def Mesh "pPlatonic2" (
}
}

def Mesh "pSphere1" (
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 = [3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3]
int[] faceVertexIndices = [1, 6, 8, 6, 7, 12, 6, 12, 8, 8, 12, 9, 7, 2, 10, 7, 10, 12, 12, 10, 11, 12, 11, 9, 9, 11, 0, 2, 13, 10, 13, 14, 17, 13, 17, 10, 10, 17, 11, 14, 3, 15, 14, 15, 17, 17, 15, 16, 17, 16, 11, 11, 16, 0, 3, 18, 15, 18, 19, 22, 18, 22, 15, 15, 22, 16, 19, 4, 20, 19, 20, 22, 22, 20, 21, 22, 21, 16, 16, 21, 0, 0, 21, 9, 21, 20, 25, 21, 25, 9, 9, 25, 8, 20, 4, 23, 20, 23, 25, 25, 23, 24, 25, 24, 8, 8, 24, 1, 5, 26, 28, 26, 27, 30, 26, 30, 28, 28, 30, 29, 27, 2, 7, 27, 7, 30, 30, 7, 6, 30, 6, 29, 29, 6, 1, 5, 31, 26, 31, 32, 33, 31, 33, 26, 26, 33, 27, 32, 3, 14, 32, 14, 33, 33, 14, 13, 33, 13, 27, 27, 13, 2, 5, 34, 31, 34, 35, 36, 34, 36, 31, 31, 36, 32, 35, 4, 19, 35, 19, 36, 36, 19, 18, 36, 18, 32, 32, 18, 3, 5, 28, 34, 28, 29, 37, 28, 37, 34, 34, 37, 35, 29, 1, 24, 29, 24, 37, 37, 24, 23, 37, 23, 35, 35, 23, 4]
rel material:binding = </pSphere1/mtl/standardSurface2SG>
normal3f[] normals = [(1, 0, 0), (0.8572056, 0.5149743, -3.262045e-8), (0.8572056, -8.155113e-9, 0.5149743), (0.8572056, 0.5149743, -3.262045e-8), (0.51497436, 0.85720557, -8.155112e-9), (0.5773503, 0.5773503, 0.57735026), (0.8572056, 0.5149743, -3.262045e-8), (0.5773503, 0.5773503, 0.57735026), (0.8572056, -8.155113e-9, 0.5149743), (0.8572056, -8.155113e-9, 0.5149743), (0.5773503, 0.5773503, 0.57735026), (0.5149743, 0, 0.8572056), (0.51497436, 0.85720557, -8.155112e-9), (0, 1, 0), (2.8542896e-8, 0.8572056, 0.51497436), (0.51497436, 0.85720557, -8.155112e-9), (2.8542896e-8, 0.8572056, 0.51497436), (0.5773503, 0.5773503, 0.57735026), (0.5773503, 0.5773503, 0.57735026), (2.8542896e-8, 0.8572056, 0.51497436), (-8.155111e-9, 0.51497436, 0.8572055), (0.5773503, 0.5773503, 0.57735026), (-8.155111e-9, 0.51497436, 0.8572055), (0.5149743, 0, 0.8572056), (0.5149743, 0, 0.8572056), (-8.155111e-9, 0.51497436, 0.8572055), (0, 0, 1), (0, 1, 0), (-0.51497436, 0.8572056, 8.155113e-9), (2.8542896e-8, 0.8572056, 0.51497436), (-0.51497436, 0.8572056, 8.155113e-9), (-0.85720557, 0.51497436, -1.6310224e-8), (-0.57735026, 0.57735026, 0.5773503), (-0.51497436, 0.8572056, 8.155113e-9), (-0.57735026, 0.57735026, 0.5773503), (2.8542896e-8, 0.8572056, 0.51497436), (2.8542896e-8, 0.8572056, 0.51497436), (-0.57735026, 0.57735026, 0.5773503), (-8.155111e-9, 0.51497436, 0.8572055), (-0.85720557, 0.51497436, -1.6310224e-8), (-1, 0, 0), (-0.8572056, 4.0775565e-9, 0.51497436), (-0.85720557, 0.51497436, -1.6310224e-8), (-0.8572056, 4.0775565e-9, 0.51497436), (-0.57735026, 0.57735026, 0.5773503), (-0.57735026, 0.57735026, 0.5773503), (-0.8572056, 4.0775565e-9, 0.51497436), (-0.51497436, 2.8542892e-8, 0.8572056), (-0.57735026, 0.57735026, 0.5773503), (-0.51497436, 2.8542892e-8, 0.8572056), (-8.155111e-9, 0.51497436, 0.8572055), (-8.155111e-9, 0.51497436, 0.8572055), (-0.51497436, 2.8542892e-8, 0.8572056), (0, 0, 1), (-1, 0, 0), (-0.8572056, -0.5149743, -3.262045e-8), (-0.8572056, 4.0775565e-9, 0.51497436), (-0.8572056, -0.5149743, -3.262045e-8), (-0.51497436, -0.85720557, -8.155112e-9), (-0.5773503, -0.5773503, 0.57735026), (-0.8572056, -0.5149743, -3.262045e-8), (-0.5773503, -0.5773503, 0.57735026), (-0.8572056, 4.0775565e-9, 0.51497436), (-0.8572056, 4.0775565e-9, 0.51497436), (-0.5773503, -0.5773503, 0.57735026), (-0.51497436, 2.8542892e-8, 0.8572056), (-0.51497436, -0.85720557, -8.155112e-9), (0, -1, 0), (-1.6310224e-8, -0.8572056, 0.5149743), (-0.51497436, -0.85720557, -8.155112e-9), (-1.6310224e-8, -0.8572056, 0.5149743), (-0.5773503, -0.5773503, 0.57735026), (-0.5773503, -0.5773503, 0.57735026), (-1.6310224e-8, -0.8572056, 0.5149743), (-8.155112e-9, -0.5149744, 0.85720557), (-0.5773503, -0.5773503, 0.57735026), (-8.155112e-9, -0.5149744, 0.85720557), (-0.51497436, 2.8542892e-8, 0.8572056), (-0.51497436, 2.8542892e-8, 0.8572056), (-8.155112e-9, -0.5149744, 0.85720557), (0, 0, 1), (0, 0, 1), (-8.155112e-9, -0.5149744, 0.85720557), (0.5149743, 0, 0.8572056), (-8.155112e-9, -0.5149744, 0.85720557), (-1.6310224e-8, -0.8572056, 0.5149743), (0.5773503, -0.5773503, 0.57735026), (-8.155112e-9, -0.5149744, 0.85720557), (0.5773503, -0.5773503, 0.57735026), (0.5149743, 0, 0.8572056), (0.5149743, 0, 0.8572056), (0.5773503, -0.5773503, 0.57735026), (0.8572056, -8.155113e-9, 0.5149743), (-1.6310224e-8, -0.8572056, 0.5149743), (0, -1, 0), (0.51497424, -0.85720557, 2.4465333e-8), (-1.6310224e-8, -0.8572056, 0.5149743), (0.51497424, -0.85720557, 2.4465333e-8), (0.5773503, -0.5773503, 0.57735026), (0.5773503, -0.5773503, 0.57735026), (0.51497424, -0.85720557, 2.4465333e-8), (0.8572056, -0.51497436, -3.262045e-8), (0.5773503, -0.5773503, 0.57735026), (0.8572056, -0.51497436, -3.262045e-8), (0.8572056, -8.155113e-9, 0.5149743), (0.8572056, -8.155113e-9, 0.5149743), (0.8572056, -0.51497436, -3.262045e-8), (1, 0, 0), (0, 0, -1), (2.0387782e-8, 0.5149743, -0.8572056), (0.5149743, -8.155113e-9, -0.8572056), (2.0387782e-8, 0.5149743, -0.8572056), (8.155113e-9, 0.8572056, -0.51497436), (0.5773503, 0.57735026, -0.5773503), (2.0387782e-8, 0.5149743, -0.8572056), (0.5773503, 0.57735026, -0.5773503), (0.5149743, -8.155113e-9, -0.8572056), (0.5149743, -8.155113e-9, -0.8572056), (0.5773503, 0.57735026, -0.5773503), (0.8572056, 0, -0.5149744), (8.155113e-9, 0.8572056, -0.51497436), (0, 1, 0), (0.51497436, 0.85720557, -8.155112e-9), (8.155113e-9, 0.8572056, -0.51497436), (0.51497436, 0.85720557, -8.155112e-9), (0.5773503, 0.57735026, -0.5773503), (0.5773503, 0.57735026, -0.5773503), (0.51497436, 0.85720557, -8.155112e-9), (0.8572056, 0.5149743, -3.262045e-8), (0.5773503, 0.57735026, -0.5773503), (0.8572056, 0.5149743, -3.262045e-8), (0.8572056, 0, -0.5149744), (0.8572056, 0, -0.5149744), (0.8572056, 0.5149743, -3.262045e-8), (1, 0, 0), (0, 0, -1), (-0.51497436, -4.0775565e-9, -0.8572056), (2.0387782e-8, 0.5149743, -0.8572056), (-0.51497436, -4.0775565e-9, -0.8572056), (-0.85720557, -4.0775565e-9, -0.51497436), (-0.57735026, 0.57735026, -0.57735026), (-0.51497436, -4.0775565e-9, -0.8572056), (-0.57735026, 0.57735026, -0.57735026), (2.0387782e-8, 0.5149743, -0.8572056), (2.0387782e-8, 0.5149743, -0.8572056), (-0.57735026, 0.57735026, -0.57735026), (8.155113e-9, 0.8572056, -0.51497436), (-0.85720557, -4.0775565e-9, -0.51497436), (-1, 0, 0), (-0.85720557, 0.51497436, -1.6310224e-8), (-0.85720557, -4.0775565e-9, -0.51497436), (-0.85720557, 0.51497436, -1.6310224e-8), (-0.57735026, 0.57735026, -0.57735026), (-0.57735026, 0.57735026, -0.57735026), (-0.85720557, 0.51497436, -1.6310224e-8), (-0.51497436, 0.8572056, 8.155113e-9), (-0.57735026, 0.57735026, -0.57735026), (-0.51497436, 0.8572056, 8.155113e-9), (8.155113e-9, 0.8572056, -0.51497436), (8.155113e-9, 0.8572056, -0.51497436), (-0.51497436, 0.8572056, 8.155113e-9), (0, 1, 0), (0, 0, -1), (-2.0387782e-8, -0.5149743, -0.8572056), (-0.51497436, -4.0775565e-9, -0.8572056), (-2.0387782e-8, -0.5149743, -0.8572056), (-8.155113e-9, -0.8572056, -0.51497436), (-0.5773503, -0.57735026, -0.5773503), (-2.0387782e-8, -0.5149743, -0.8572056), (-0.5773503, -0.57735026, -0.5773503), (-0.51497436, -4.0775565e-9, -0.8572056), (-0.51497436, -4.0775565e-9, -0.8572056), (-0.5773503, -0.57735026, -0.5773503), (-0.85720557, -4.0775565e-9, -0.51497436), (-8.155113e-9, -0.8572056, -0.51497436), (0, -1, 0), (-0.51497436, -0.85720557, -8.155112e-9), (-8.155113e-9, -0.8572056, -0.51497436), (-0.51497436, -0.85720557, -8.155112e-9), (-0.5773503, -0.57735026, -0.5773503), (-0.5773503, -0.57735026, -0.5773503), (-0.51497436, -0.85720557, -8.155112e-9), (-0.8572056, -0.5149743, -3.262045e-8), (-0.5773503, -0.57735026, -0.5773503), (-0.8572056, -0.5149743, -3.262045e-8), (-0.85720557, -4.0775565e-9, -0.51497436), (-0.85720557, -4.0775565e-9, -0.51497436), (-0.8572056, -0.5149743, -3.262045e-8), (-1, 0, 0), (0, 0, -1), (0.5149743, -8.155113e-9, -0.8572056), (-2.0387782e-8, -0.5149743, -0.8572056), (0.5149743, -8.155113e-9, -0.8572056), (0.8572056, 0, -0.5149744), (0.57735026, -0.57735026, -0.57735026), (0.5149743, -8.155113e-9, -0.8572056), (0.57735026, -0.57735026, -0.57735026), (-2.0387782e-8, -0.5149743, -0.8572056), (-2.0387782e-8, -0.5149743, -0.8572056), (0.57735026, -0.57735026, -0.57735026), (-8.155113e-9, -0.8572056, -0.51497436), (0.8572056, 0, -0.5149744), (1, 0, 0), (0.8572056, -0.51497436, -3.262045e-8), (0.8572056, 0, -0.5149744), (0.8572056, -0.51497436, -3.262045e-8), (0.57735026, -0.57735026, -0.57735026), (0.57735026, -0.57735026, -0.57735026), (0.8572056, -0.51497436, -3.262045e-8), (0.51497424, -0.85720557, 2.4465333e-8), (0.57735026, -0.57735026, -0.57735026), (0.51497424, -0.85720557, 2.4465333e-8), (-8.155113e-9, -0.8572056, -0.51497436), (-8.155113e-9, -0.8572056, -0.51497436), (0.51497424, -0.85720557, 2.4465333e-8), (0, -1, 0)] (
interpolation = "faceVarying"
)
point3f[] points = [(0, 0, 0.5), (0.5, 0, 0), (0, 0.5, 0), (-0.5, 0, 0), (0, -0.5, 0), (0, 0, -0.5), (0.4472136, 0.22360677, 0), (0.22360681, 0.4472136, 0), (0.4472136, 0, 0.22360677), (0.22360681, 0, 0.4472136), (0, 0.4472136, 0.22360677), (0, 0.22360681, 0.4472136), (0.28867516, 0.28867513, 0.28867513), (-0.22360677, 0.4472136, 0), (-0.4472136, 0.22360681, 0), (-0.4472136, 0, 0.22360677), (-0.22360681, 0, 0.4472136), (-0.28867513, 0.28867516, 0.28867513), (-0.4472136, -0.22360677, 0), (-0.22360681, -0.4472136, 0), (0, -0.4472136, 0.22360677), (0, -0.22360681, 0.4472136), (-0.28867516, -0.28867513, 0.28867513), (0.22360677, -0.4472136, 0), (0.4472136, -0.22360681, 0), (0.28867516, -0.28867516, 0.28867513), (0, 0.22360677, -0.4472136), (0, 0.4472136, -0.22360681), (0.22360677, 0, -0.4472136), (0.4472136, 0, -0.22360681), (0.28867513, 0.28867513, -0.28867516), (-0.22360677, 0, -0.4472136), (-0.4472136, 0, -0.22360681), (-0.28867513, 0.28867513, -0.28867516), (0, -0.22360677, -0.4472136), (0, -0.4472136, -0.22360681), (-0.28867513, -0.28867513, -0.28867516), (0.28867513, -0.28867513, -0.28867516)]
texCoord2f[] primvars:st = [(0.5, 0.5), (0.75, 0.5), (0.5, 1), (0.25, 0.5), (0.5, 1), (1, 0.5), (0.75, 0.6475836), (0.75, 0.8524164), (0.6762082, 0.5), (0.5737918, 0.5), (0.5, 0.8524164), (0.5, 0.64758366), (0.625, 0.69591326), (0.25, 0.8524164), (0.25, 0.64758366), (0.3237918, 0.5), (0.4262082, 0.5), (0.375, 0.6959133), (0.25, 0.3524164), (0.25, 0.14758359), (0.5, 0.14758359), (0.5, 0.3524164), (0.375, 0.30408674), (0.75, 0.14758359), (0.75, 0.3524164), (0.625, 0.3040867), (1, 0.6475836), (1, 0.8524164), (0.9262082, 0.5), (0.8237918, 0.5), (0.875, 0.69591326), (0.073791794, 0.5), (0.1762082, 0.5), (0.125, 0.69591326), (1, 0.3524164), (1, 0.14758359), (0.125, 0.30408674), (0.875, 0.30408674), (1.0737917, 0.5), (1.125, 0.69591326), (1.25, 0.8524164), (1.125, 0.30408674), (1.25, 0.14758359)] (
customData = {
dictionary Maya = {
token name = "map1"
}
}
interpolation = "faceVarying"
)
int[] primvars:st:indices = [1, 6, 8, 6, 7, 12, 6, 12, 8, 8, 12, 9, 7, 2, 10, 7, 10, 12, 12, 10, 11, 12, 11, 9, 9, 11, 0, 2, 13, 10, 13, 14, 17, 13, 17, 10, 10, 17, 11, 14, 3, 15, 14, 15, 17, 17, 15, 16, 17, 16, 11, 11, 16, 0, 3, 18, 15, 18, 19, 22, 18, 22, 15, 15, 22, 16, 19, 4, 20, 19, 20, 22, 22, 20, 21, 22, 21, 16, 16, 21, 0, 0, 21, 9, 21, 20, 25, 21, 25, 9, 9, 25, 8, 20, 4, 23, 20, 23, 25, 25, 23, 24, 25, 24, 8, 8, 24, 1, 5, 26, 28, 26, 27, 30, 26, 30, 28, 28, 30, 29, 27, 2, 7, 27, 7, 30, 30, 7, 6, 30, 6, 29, 29, 6, 1, 5, 38, 26, 31, 32, 33, 38, 39, 26, 26, 39, 27, 32, 3, 14, 32, 14, 33, 33, 14, 13, 39, 40, 27, 27, 40, 2, 5, 34, 38, 34, 35, 41, 34, 41, 38, 31, 36, 32, 35, 4, 42, 35, 42, 41, 36, 19, 18, 36, 18, 32, 32, 18, 3, 5, 28, 34, 28, 29, 37, 28, 37, 34, 34, 37, 35, 29, 1, 24, 29, 24, 37, 37, 24, 23, 37, 23, 35, 35, 23, 4]
uniform token subdivisionScheme = "none"
double3 xformOp:translate = (1.6945269731517678, 1.2408521489350353, 0.3012844703334947)
uniform token[] xformOpOrder = ["xformOp:translate"]

def Scope "mtl"
{
def Material "standardSurface2SG" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
token outputs:mtlx:surface.connect = </pSphere1/mtl/standardSurface2SG/surface1.outputs:out>
uniform float2 ui:nodegraph:node:pos = (0.055555556, 0.055555556)

def Shader "surface1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_surface"
token inputs:bsdf.connect = </pSphere1/mtl/standardSurface2SG/burley_diffuse_bsdf1.outputs:out>
token inputs:edf.connect = </pSphere1/mtl/standardSurface2SG/uniform_edf1.outputs:out>
token outputs:out
uniform float2 ui:nodegraph:node:pos = (4.6277776, 2.0944445)
}

def Shader "uniform_edf1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_uniform_edf"
color3f inputs:color.connect = </pSphere1/mtl/standardSurface2SG/fractal3d1.outputs:out>
token outputs:out
uniform float2 ui:nodegraph:node:pos = (2.6111112, 2.7166667)
}

def Shader "fractal3d1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_fractal3d_color3"
float3 inputs:amplitude = (0.5, 0.5, 0.5)
color3f outputs:out
uniform float2 ui:nodegraph:node:pos = (0.59444445, 2.0222223)
}

def Shader "burley_diffuse_bsdf1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_burley_diffuse_bsdf"
color3f inputs:color.connect = </pSphere1/mtl/standardSurface2SG/ramplr1.outputs:out>
token outputs:out
uniform float2 ui:nodegraph:node:pos = (3.2277777, 0.51111114)
}

def Shader "ramplr1" (
prepend apiSchemas = ["NodeGraphNodeAPI"]
)
{
uniform token info:id = "ND_ramplr_color3"
color3f inputs:valuel = (0, 1, 0)
color3f inputs:valuer = (1, 0.5297, 0)
color3f outputs:out
uniform float2 ui:nodegraph:node:pos = (1.6722223, 0.23333333)
}
}
}
}

0 comments on commit fa3bef0

Please sign in to comment.