Exporting out as MaterialX

   3861   9   3
User Avatar
Member
647 posts
Joined: Aug. 2013
Offline
Hi. Woudl anyone know how to export materialX subnets out as a Material X shader?

Best

Mark
User Avatar
Member
7762 posts
Joined: Sept. 2011
Offline
I'm not sure if you can from Houdini. It seems like solaris can't make use of materialX nodegraph based shaders either. Only the built-in ones have worked for me.
User Avatar
Staff
1448 posts
Joined: July 2005
Offline
There is a `vop2mtlx.py` script that exports a VOP HDA as a Material X shader. This is how we generate ramp .mtlx from the HDAs.

There is also `saveShaderNetwork()` function in there, that can save .mtlx from VOP nodes rather than HDA. But it can only handle one-level of subnet, since currently MaterialX does not officially support nested compound node graphs. Compound node graph is one that does not specify shader node definition (nodedef).
User Avatar
Member
710 posts
Joined: July 2005
Online
So essentially materials have to live at the root of the material library if we want to export .mtlx?
User Avatar
Staff
1448 posts
Joined: July 2005
Offline
Not necessarily. You should be able to right-click on any VOP node > Save > MaterialX...

This menu item essentially calls vop2mtlx.saveShaderNetwork(), which traverses the input chains. If one of the node in an input chain is a subnet, that subnet will be saved as a node graph. But if that subnet has another subnet inside, it will result in an error, because MaterialX node graph can't have another node graph inside.
User Avatar
Member
647 posts
Joined: Aug. 2013
Offline
Hi all. I just came across this which may help...

https://www.youtube.com/watch?v=RpShFmwjMzg [www.youtube.com]

Best. Mark
User Avatar
Member
51 posts
Joined: Oct. 2019
Offline
rafal
Not necessarily. You should be able to right-click on any VOP node > Save > MaterialX...

This menu item essentially calls vop2mtlx.saveShaderNetwork(), which traverses the input chains. If one of the node in an input chain is a subnet, that subnet will be saved as a node graph. But if that subnet has another subnet inside, it will result in an error, because MaterialX node graph can't have another node graph inside.

Hello,
I'm testing this right now and I can't for the world in me read the mtlx file back in again. When I test with the built in shader examples it's works (testing standard_surface_chrome.mtlx as example).
But if I create a standard surface and then export that it will not work.
If I copy paste the code from the mtlx file but change the name from "SR_Chrome" to "My_Test"., and also the same for nodename..it will not work.

So is there anything else we can do to make it work?
Testing this on 19.0.561 (linux)

regards
stefan
CG Supervisor - Important Looking Pirates
http://www.ilpvfx.com/ [www.ilpvfx.com]
User Avatar
Staff
1448 posts
Joined: July 2005
Offline
The terminal node in your VOP network may need to be the "Mtlx Surface Material" VOP. Ie, you need to feed your standard surface to it as an input. Otherwise USD file plugin won't detect which shader to start loading from.
User Avatar
Member
2 posts
Joined: April 2022
Offline
rafal
The terminal node in your VOP network may need to be the "Mtlx Surface Material" VOP. Ie, you need to feed your standard surface to it as an input. Otherwise USD file plugin won't detect which shader to start loading from.

Hello Rafal,
Without Mtlx surface material node it will not write anything to the xml file. but with mtlx surface material node to export from houdini will not write the shader under <nodeGraph> so it will read just the shader when importing it back without any other nodes connected to that shader like mtlxImage or any other nodes. I know clarisse can read the .mtlx file even if it hasn't <nodeGraph>. but houdini can't!

So, what should i do to export correctly a materialX shader from Houdini and read it back in houdini without losing the nodes connected to the main shader?
User Avatar
Member
7762 posts
Joined: Sept. 2011
Offline
azab4d
So, what should i do to export correctly a materialX shader from Houdini and read it back in houdini without losing the nodes connected to the main shader?

I don't think you can round trip mtlx yet.
  • Quick Links