-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[UsdMtlx] Add support for nodes outside nodegraphs
If material inputs are coming from a node output, we create a nodegraph around that node as well as any upstream nodes or other nodes providing connections to different material inputs. Essentially doing what we previously required the user to do; contain all nodes that ultimately feed into the material/surfaceshader nodes, inside a nodegraph. Fixes #1636 (Internal change: 2242218) (Internal change: 2242222)
- Loading branch information
Showing
6 changed files
with
196 additions
and
8 deletions.
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
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
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
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
32 changes: 32 additions & 0 deletions
32
pxr/usd/usdMtlx/testenv/testUsdMtlxFileFormat.testenv/GraphlessNodes.mtlx
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,32 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.38"> | ||
|
||
<constant name="redClorVal" type="color3"> | ||
<input name="value" type="color3" value="1,0,0" /> | ||
</constant> | ||
<constant name="blueColorVal" type="color3"> | ||
<input name="value" type="color3" value="0,0,1" /> | ||
</constant> | ||
<multiply name="multi1" type="color3"> | ||
<input name="in1" type="color3" nodename="redClorVal" /> | ||
<input name="in2" type="float" value="0.5" /> | ||
</multiply> | ||
<add name="myDiffColor" type="color3"> | ||
<input name="in1" type="color3" nodename="multi1" /> | ||
<input name="in2" type="color3" nodename="blueColorVal" /> | ||
</add> | ||
<constant name="mySpecColor" type="color3"> | ||
<input name="value" type="color3" value="0,1,0" /> | ||
</constant> | ||
|
||
<UsdPreviewSurface name="surface_shader_node" type="surfaceshader"> | ||
<input name="diffuseColor" type="color3" nodename="myDiffColor" /> | ||
<input name="useSpecularWorkflow" type="integer" value="1" /> | ||
<input name="specularColor" type="color3" nodename="mySpecColor" /> | ||
<input name="roughness" type="float" value="0.25" /> | ||
<input name="ior" type="float" value=".9" /> | ||
</UsdPreviewSurface> | ||
<surfacematerial name="surface_material_node" type="material"> | ||
<input name="surfaceshader" type="surfaceshader" nodename="surface_shader_node" /> | ||
</surfacematerial> | ||
</materialx> |
102 changes: 102 additions & 0 deletions
102
pxr/usd/usdMtlx/testenv/testUsdMtlxFileFormat.testenv/baseline/GraphlessNodes.usda
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,102 @@ | ||
#usda 1.0 | ||
|
||
def "MaterialX" | ||
{ | ||
def "Materials" | ||
{ | ||
def Material "surface_material_node" | ||
{ | ||
float inputs:clearcoat | ||
float inputs:clearcoatRoughness | ||
color3f inputs:diffuseColor | ||
float inputs:displacement | ||
color3f inputs:emissiveColor | ||
float inputs:ior = 0.9 | ||
float inputs:metallic | ||
float3 inputs:normal | ||
float inputs:occlusion | ||
float inputs:opacity | ||
float inputs:opacityThreshold | ||
float inputs:roughness = 0.25 | ||
color3f inputs:specularColor | ||
int inputs:useSpecularWorkflow = 1 | ||
token outputs:mtlx:surface.connect = </MaterialX/Materials/surface_material_node/ND_UsdPreviewSurface_surfaceshader.outputs:surface> | ||
|
||
def Shader "ND_UsdPreviewSurface_surfaceshader" ( | ||
prepend references = </MaterialX/Shaders/ND_UsdPreviewSurface_surfaceshader> | ||
) | ||
{ | ||
float inputs:clearcoat.connect = </MaterialX/Materials/surface_material_node.inputs:clearcoat> | ||
float inputs:clearcoatRoughness.connect = </MaterialX/Materials/surface_material_node.inputs:clearcoatRoughness> | ||
color3f inputs:diffuseColor.connect = </MaterialX/Materials/surface_material_node/NodeGraphs/myDiffColor.outputs:out> | ||
float inputs:displacement.connect = </MaterialX/Materials/surface_material_node.inputs:displacement> | ||
color3f inputs:emissiveColor.connect = </MaterialX/Materials/surface_material_node.inputs:emissiveColor> | ||
float inputs:ior.connect = </MaterialX/Materials/surface_material_node.inputs:ior> | ||
float inputs:metallic.connect = </MaterialX/Materials/surface_material_node.inputs:metallic> | ||
float3 inputs:normal.connect = </MaterialX/Materials/surface_material_node.inputs:normal> | ||
float inputs:occlusion.connect = </MaterialX/Materials/surface_material_node.inputs:occlusion> | ||
float inputs:opacity.connect = </MaterialX/Materials/surface_material_node.inputs:opacity> | ||
float inputs:opacityThreshold.connect = </MaterialX/Materials/surface_material_node.inputs:opacityThreshold> | ||
float inputs:roughness.connect = </MaterialX/Materials/surface_material_node.inputs:roughness> | ||
color3f inputs:specularColor.connect = </MaterialX/Materials/surface_material_node/NodeGraphs/mySpecColor.outputs:out> | ||
int inputs:useSpecularWorkflow.connect = </MaterialX/Materials/surface_material_node.inputs:useSpecularWorkflow> | ||
} | ||
|
||
def "NodeGraphs" ( | ||
prepend references = </MaterialX/NodeGraphs> | ||
) | ||
{ | ||
} | ||
} | ||
} | ||
|
||
def "Shaders" | ||
{ | ||
def Shader "ND_UsdPreviewSurface_surfaceshader" | ||
{ | ||
uniform token info:id = "ND_UsdPreviewSurface_surfaceshader" | ||
token outputs:surface | ||
} | ||
} | ||
|
||
def "NodeGraphs" | ||
{ | ||
def Shader "redClorVal" | ||
{ | ||
uniform token info:id = "ND_constant_color3" | ||
color3f inputs:value = (1, 0, 0) | ||
color3f outputs:out | ||
} | ||
|
||
def Shader "blueColorVal" | ||
{ | ||
uniform token info:id = "ND_constant_color3" | ||
color3f inputs:value = (0, 0, 1) | ||
color3f outputs:out | ||
} | ||
|
||
def Shader "multi1" | ||
{ | ||
uniform token info:id = "ND_multiply_color3FA" | ||
color3f inputs:in1.connect = </MaterialX/NodeGraphs/redClorVal.outputs:out> | ||
float inputs:in2 = 0.5 | ||
color3f outputs:out | ||
} | ||
|
||
def Shader "myDiffColor" | ||
{ | ||
uniform token info:id = "ND_add_color3" | ||
color3f inputs:in1.connect = </MaterialX/NodeGraphs/multi1.outputs:out> | ||
color3f inputs:in2.connect = </MaterialX/NodeGraphs/blueColorVal.outputs:out> | ||
color3f outputs:out | ||
} | ||
|
||
def Shader "mySpecColor" | ||
{ | ||
uniform token info:id = "ND_constant_color3" | ||
color3f inputs:value = (0, 1, 0) | ||
color3f outputs:out | ||
} | ||
} | ||
} | ||
|