-
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, hdMtlx, hdSt] Add Texture support for MaterialX custom node…
…s defined in libraries Custom nodes defined in a separate library indicated with the PXR_MTLX_PLUGIN_SEARCH_PATHS envar that use textures need to have the 'textureuser' group so that UsdMtlx and hdMtlx know they use textures and can properly initialize texture coordinates. Similarly custom nodes that use texcoords need the 'texcoorduser' group. These custom nodes now work in both Storm and HdPrman. Changes in hdSt are since custom nodes can name the input for the file anything instead of 'file' which the stdlib texture nodes use. Note: - users need to add 'textureuser' or 'texcoorduser' as the custom node's nodegroup - need to use the fallback texture coordinates - cannot use mutliple textures inside one custom node Fixes #1636 Fixes #1786 (Internal change: 2242208)
- Loading branch information
Showing
13 changed files
with
460 additions
and
47 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
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
Binary file added
BIN
+1.4 MB
pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLMaterialXCustomNodes/StinsonBeach.hdr
Binary file not shown.
Binary file added
BIN
+170 KB
...agingGL/testenv/testUsdImagingGLMaterialXCustomNodes/baseline/customTexNode.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
58 changes: 58 additions & 0 deletions
58
...ing/usdImagingGL/testenv/testUsdImagingGLMaterialXCustomNodes/customNodeDefs/nodeDef.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,58 @@ | ||
<?xml version="1.0"?> | ||
<materialx version="1.38"> | ||
|
||
<!-- custom node using texture coordinates --> | ||
<nodedef name="ND_checker_float" node="checker3" nodegroup="texcoorduser"> | ||
<input name="scale" type="vector2" value="8.0, 8.0" /> | ||
<output name="out" type="color3" /> | ||
</nodedef> | ||
<nodegraph name="NG_checker_float" nodedef="ND_checker_float"> | ||
<texcoord name="texcoord1" type="vector2"> | ||
<input name="index" type="integer" value="0" /> | ||
</texcoord> | ||
<multiply name="mult1" type="vector2"> | ||
<input name="in1" type="vector2" nodename="texcoord1" /> | ||
<input name="in2" type="vector2" interfacename="scale" /> | ||
</multiply> | ||
<swizzle name="swizz_x" type="float"> | ||
<input name="in" type="vector2" nodename="mult1" /> | ||
<input name="channels" type="string" value="x" /> | ||
</swizzle> | ||
<swizzle name="swizz_y" type="float"> | ||
<input name="in" type="vector2" nodename="mult1" /> | ||
<input name="channels" type="string" value="y" /> | ||
</swizzle> | ||
<floor name="floor1" type="float"> | ||
<input name="in" type="float" nodename="swizz_x" /> | ||
</floor> | ||
<floor name="floor2" type="float"> | ||
<input name="in" type="float" nodename="swizz_y" /> | ||
</floor> | ||
<add name="add1" type="float"> | ||
<input name="in1" type="float" nodename="floor1" /> | ||
<input name="in2" type="float" nodename="floor2" /> | ||
</add> | ||
<modulo name="mod1" type="float"> | ||
<input name="in1" type="float" nodename="add1" /> | ||
<input name="in2" type="float" value="2.0" /> | ||
</modulo> | ||
<swizzle name="swizz_xxx" type="color3"> | ||
<input name="in" type="float" nodename="mod1" /> | ||
<input name="channels" type="string" value="xxx" /> | ||
</swizzle> | ||
<output name="out" type="color3" nodename="swizz_xxx" /> | ||
</nodegraph> | ||
|
||
<!-- custom node using textures --> | ||
<nodedef name="custom_image_nodedef" node="custom_image_node" nodegroup="textureuser"> | ||
<input name="file_input" type="filename" /> | ||
<output name="out_color" type="color3" /> | ||
</nodedef> | ||
<nodegraph name="custom_image_nodegraph" nodedef="custom_image_nodedef"> | ||
<image name="image_node" type="color3"> | ||
<input name="file" type="filename" colorspace="gamma22" interfacename="file_input" /> | ||
</image> | ||
<output name="out_color" type="color3" nodename="image_node" /> | ||
</nodegraph> | ||
|
||
</materialx> |
61 changes: 61 additions & 0 deletions
61
pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLMaterialXCustomNodes/customTexNode.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,61 @@ | ||
#usda 1.0 | ||
( | ||
upAxis = "Z" | ||
) | ||
|
||
def "CustomNodeDef" ( | ||
references = @texturedSphere.usda@ | ||
) | ||
{ | ||
rel material:binding = </MaterialX/Materials/test_material> | ||
color3f[] primvars:displayColor = [(0.1, 0.5, 0.8)] | ||
double radius = 9.0 | ||
matrix4d xformOp:transform = ( (1, 0, 0, 0), | ||
(0, 1, 0, 0), | ||
(0, 0, 1, 0), | ||
(-10, 0, 0, 1) ) | ||
uniform token[] xformOpOrder = ["xformOp:transform"] | ||
} | ||
|
||
def "ImageCustomNodeDef" ( | ||
references = @texturedSphere.usda@ | ||
) | ||
{ | ||
rel material:binding = </MaterialX/Materials/test_image_material> | ||
color3f[] primvars:displayColor = [(0.1, 0.5, 0.8)] | ||
matrix4d xformOp:transform = ( (1, 0, 0, 0), | ||
(0, 1, 0, 0), | ||
(0, 0, 1, 0), | ||
(10, 0, 0, 1) ) | ||
uniform token[] xformOpOrder = ["xformOp:transform"] | ||
} | ||
|
||
def Scope "MaterialX"( | ||
references = @./material.mtlx@</MaterialX> | ||
) | ||
{ | ||
} | ||
|
||
def Xform "lights" | ||
{ | ||
def DomeLight "DomeLight" | ||
{ | ||
asset inputs:texture:file = @./StinsonBeach.hdr@ | ||
float xformOp:rotateX:Zup = 90 | ||
uniform token[] xformOpOrder = ["xformOp:rotateX:Zup"] | ||
} | ||
def SphereLight "Light" | ||
{ | ||
float inputs:radius = 20 | ||
float inputs:intensity = 5 | ||
Vec3f xformOp:translate = (0, -50, 0) | ||
uniform token[] xformOpOrder = ["xformOp:translate"] | ||
} | ||
} | ||
|
||
def Camera "Camera" | ||
{ | ||
double3 xformOp:translate = (0, 0, 125) | ||
float xformOp:rotateX:Zup = 90 | ||
uniform token[] xformOpOrder = ["xformOp:rotateX:Zup","xformOp:translate"] | ||
} |
Binary file added
BIN
+77.4 KB
pxr/usdImaging/usdImagingGL/testenv/testUsdImagingGLMaterialXCustomNodes/grid.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.