Ejemplo n.º 1
0
    def test_XInclude(self):
        """
        Verify documents referenced via XInclude statements are read
        properly.
        """
        stage = UsdMtlx._TestFile('include/Include.mtlx')
        stage.GetRootLayer().Export('Include.usda')

        stage = UsdMtlx._TestFile('include/Include.usdz[Include.mtlx]')
        stage.GetRootLayer().Export('Include_From_Usdz.usda')
Ejemplo n.º 2
0
    def test_MultiBindInputs(self):
        """
        Test MaterialX conversion with mutliple bind inputs.
        """

        stage = UsdMtlx._TestFile('MultiBindInputs.mtlx')

        # Get the node graph and make sure there are exactly 3 inputs
        nodeGraph = UsdShade.NodeGraph.Get(
            stage, Sdf.Path('/MaterialX/Materials/layered/ND_layerShader'))
        inputs = nodeGraph.GetInputs()
        self.assertEqual(len(inputs), 3)

        # Make sure each input is connected as expected
        inputToSource = {
            'weight_1':
            '/MaterialX/Materials/layered/NodeGraphs/layered_layer1_gradient',
            'weight_2':
            '/MaterialX/Materials/layered/NodeGraphs/layered_layer2_gradient',
            'weight_3':
            '/MaterialX/Materials/layered/NodeGraphs/layered_layer3_gradient'
        }
        for inputName, source in inputToSource.iteritems():
            input = nodeGraph.GetInput(inputName)
            self.assertEqual(input.HasConnectedSource(), True)
            self.assertEqual(input.GetConnectedSource()[0].GetPath(), source)
Ejemplo n.º 3
0
    def test_Looks(self):
        """
        Test general MaterialX look conversions.
        """

        stage = UsdMtlx._TestFile('Looks.mtlx')
        stage.GetRootLayer().Export('Looks.usda')
Ejemplo n.º 4
0
    def test_NodeGraphs(self):
        """
        Test general MaterialX node graph conversions.
        """

        stage = UsdMtlx._TestFile('NodeGraphs.mtlx', nodeGraphs=True)
        stage.GetRootLayer().Export('NodeGraphs.usda')
Ejemplo n.º 5
0
    def test_Looks(self):
        """
        Test general MaterialX look conversions.
        """

        stage = UsdMtlx._TestFile('Looks.mtlx')
        with open('Looks.usda', 'w') as f:
            print >> f, stage.GetRootLayer().ExportToString()
Ejemplo n.º 6
0
    def test_NodeGraphs(self):
        """
        Test general MaterialX node graph conversions.
        """

        stage = UsdMtlx._TestFile('NodeGraphs.mtlx', nodeGraphs=True)
        with open('NodeGraphs.usda', 'w') as f:
            print >> f, stage.GetRootLayer().ExportToString()
    def test_Looks(self):
        """
        Test general MaterialX look conversions.
        """

        stage = UsdMtlx._TestFile('Looks.mtlx')
        with open('Looks.usda', 'w') as f:
            print >>f, stage.GetRootLayer().ExportToString()
    def test_NodeGraphs(self):
        """
        Test general MaterialX node graph conversions.
        """

        stage = UsdMtlx._TestFile('NodeGraphs.mtlx', nodeGraphs=True)
        with open('NodeGraphs.usda', 'w') as f:
            print >>f, stage.GetRootLayer().ExportToString()
Ejemplo n.º 9
0
    def test_EmbedInUSDZ(self):
        """
        Verify that a MaterialX file can be read from within a .usdz file.
        """

        stage = UsdMtlx._TestFile(
            'usd_preview_surface_gold.usdz[usd_preview_surface_gold.mtlx]')
        stage.GetRootLayer().Export('usd_preview_surface_gold.usda')
Ejemplo n.º 10
0
    def test_StdlibShaderRefs(self):
        """
        Test that we can use a shader nodedef from the MaterialX stdlib.
        """

        stage = UsdMtlx._TestFile('usd_preview_surface_gold.mtlx')
        # check stage contents
        mprim = stage.GetPrimAtPath("/MaterialX/Materials/USD_Gold")
        self.assertTrue(mprim)
        material = UsdShade.Material(mprim)
        self.assertTrue(material)
        input = material.GetInput("specularColor")
        self.assertTrue(input)
        self.assertEqual(input.GetFullName(),"inputs:specularColor")
Ejemplo n.º 11
0
    def test_MultiOutputNodes(self):
        """
        Test MaterialX nodes with multiple outputs
        """

        stage = UsdMtlx._TestFile('MultiOutputNode.mtlx')
        testInfo = [('/MaterialX/Materials/test_m/test_ng/specular',
                     'artistic_ior', 'extinction'),
                    ('/MaterialX/Materials/test_m/test_ng/ior', 'artistic_ior',
                     'ior')]

        for path, connNodeName, connectionName in testInfo:
            node = UsdShade.Shader.Get(stage, path)
            conn = node.GetInput('in').GetConnectedSource()
            self.assertEqual(conn[0].GetPrim().GetPath().name, connNodeName)
            self.assertEqual(conn[1], connectionName)
Ejemplo n.º 12
0
 def test_MissingFile(self):
     """
     Verify that a missing MaterialX file fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestFile('non-existent-file.xml')
 def test_MissingFile(self):
     """
     Verify that a missing MaterialX file fails.
     """
     with self.assertRaises(Tf.ErrorException) as e:
         UsdMtlx._TestFile('non-existent-file.xml')