MaterialX | Importing Node Definitions/Graphs

   4207   13   4
User Avatar
Member
37 posts
Joined: March 2017
Offline
Hi All,

I've tried exporting a simple MaterialX graph with a diffuse bsdf, surface and surfacematerial and haven't had any luck.

I'm assuming this is due to Node Definitions/Graphs not being supported yet.

I was wondering if anyone has had any luck or knows of any developments into this area as it would be great to be able to import graph definitions such as the lama node set as well as import custom node graphs exported as mtlx.



Best,
Rich
Edited by Hypershader - March 16, 2022 11:07:03

Attachments:
Screenshot 2022-03-16 150519.png (30.4 KB)

User Avatar
Staff
4200 posts
Joined: Sept. 2007
Offline
The only mechanism we currently have for importing MaterialX is the UsdMtlX format plugin, which lets you reference MtlX materials out of the xml-based .mtlx files, and into USD.

The Lama nodes should import into USD fine, but I'm not sure how well, if at all, they will render with Karma just yet. Those were added to a version of MaterialX after H19 was released.

The way to export to a .mtlx file currently is via the RMB menu (see screenshot). I haven't personally used this feature at all though.

Hope this helps, sorry if I misunderstood the questions!

Attachments:
screenshot_2022-03-16_22.11.10_img.png (31.2 KB)

I'm o.d.d.
User Avatar
Member
37 posts
Joined: March 2017
Offline
Hey,

Thanks for the reply!

As far as I am aware, the UsdMtlx file format allows for nodegraph transfer as listed on the documentation but could it be the case its not properly supported yet? here [graphics.pixar.com]

Unfortunately it does say that nodedefs are not currently supported but this shouldn't affect node graphs, right?

It does seem to work when plugging a standard surface into a surface material but this is the only situation I can get it to work. for any materialX files with node graph definitions. It does not seem to work when plugging a BSDF into a surface. I cannot open this file in MaterialX View either as you can see in the attachment below.

see attachment 1:

Taking a look at the exported BSDF nodes Mtlx file and comparing it to the node definition which works in MaterialXView there seems to be some discrepancies. those being the lack of:

<nodegraph> and <output>



see attachment 2: file on the left is the node definition and the right is a mtlx file saved from Houdini using the method above.



When i add <nodegraph> and <output> manually, I can succesfully load this file into MaterailXView.

see attachment 3:


Unfortunately, I cannot reimport this file back into Houdini through a sublayer. So im assuming this is due to a lack of support on USD end for importing MaterialX node graphs despite what it says in the documentation? This would explain why we cannot import the lama nodes as well as they are node graph definitions.

If you have any more insight I would love to know. It would be amazing if we could have an alternative way of importing node graph definitions into houdini as currently through USD it does not seem to work restricting the use of Houdini's implementation of MaterialX massively. I cannot stress how impressed I am with the implementation this far, and i look forward to see what's to come!
Edited by Hypershader - March 17, 2022 09:03:35

Attachments:
diffuseTest.png (48.7 KB)
comparison.png (40.9 KB)
materialX view Working.png (296.6 KB)

User Avatar
Member
8043 posts
Joined: Sept. 2011
Online
Hypershader
Hey,

Thanks for the reply!

As far as I am aware, the UsdMtlx file format allows for nodegraph transfer as listed on the documentation but could it be the case its not properly supported yet? here

Unfortunately it does say that nodedefs are not currently supported but this shouldn't affect node graphs, right?

As far as I can tell, writing out mtlx files is completely non-functional. The resulting mtlx is either invalid, or missing all of the nodes from the graph.

It works fine if it's used entirely within the context of usd, and not for exporting to mtlx.
User Avatar
Member
8043 posts
Joined: Sept. 2011
Online
goldleaf
The way to export to a .mtlx file currently is via the RMB menu (see screenshot). I haven't personally used this feature at all though.

There doesn't seem to be any combination of nodes that produces a valid mtlx shader that can be read back into Houdini.
User Avatar
Member
37 posts
Joined: March 2017
Offline
jsmack
As far as I can tell, writing out mtlx files is completely non-functional. The resulting mtlx is either invalid, or missing all of the nodes from the graph.

It works fine if it's used entirely within the context of usd, and not for exporting to mtlx.

I agree, the output file does seem broken due to the lack out <nodegraph> and <output> but if manually added they do work successfully in MaterialXView.

The issue seems to be you cannot import nodegraphs back into Houdini even after the syntax is fixed as they are not supported to import through USD through a sublayer.

That being said, it works for the standardsurface for some odd reason??? I’m assuming as it’s recognised as a material by USD instead of as a shader/node.

I’m assuming this is because <nodegraph> and <output> are not required for these shaders as they are pre compiled in the material. If not then I have no clue.

Would definitely be interesting to hear why this is happening and what’s causing the issue because as far as I can see it is on the USD/Solaris side and not with MaterialX files as the shaders do work in MaterialX once tweaked to have the correct syntax. That being said, the syntax does need to be fixed when exporting nodegraphs. Having a Save -> MaterialX Nodegraph which fixes the syntax issues would be a great option so you don’t have to manually edit it.

Either way, it’s exciting to see SideFX implement such an exciting project and at least on the Karma side it’s running very well in general.
User Avatar
Staff
1455 posts
Joined: July 2005
Offline
While you can Save -> MaterialX... to save any portion of VOPs to MaterialX document, only invoking it on a Mtlx Surface Material will save a somewhat correct material to .mtlx file. The .mtlx document is expected to have a material (eg, 'surfacematerial') in order for USD mtlx file format plugin to read it back into Houdini.

There are some limitations related to MaterialX (no support for nested NodeGraphs, so no nested VOP subnets are allowed) and to USD (some concepts don't have USD counterpart, like looks or geominfos).

Anyway, try saving starting from Mtlx Surface Material VOP, and things may be smoother.
User Avatar
Member
8043 posts
Joined: Sept. 2011
Online
rafal
Anyway, try saving starting from Mtlx Surface Material VOP, and things may be smoother.

That's what I was trying. I couldn't get it to read back into Houdini.
User Avatar
Member
37 posts
Joined: March 2017
Offline
rafal
Anyway, try saving starting from Mtlx Surface Material VOP, and things may be smoother.

Likewise, I have tried this and still no results as it produces a broken MaterialX file with incorrect syntax.

What I originally tried is:

Oren-nayar diffuse —-> surface —-> surface material

The exported mtlx file does not work.

MaterialX view claims the syntax is wrong and Houdini cannot read the BSDF nodes back (see my first post)

It does not seem to include <output> or <nodegraph> in the MaterialX file so not even MaterialXView cant identify it is a Material so no wonder it can’t be read back into Houdini as it’s not even exporting valid materials.

As far as I am aware, I have not seen a single person get this to work.

But even totally functioning MaterialX nodegraphs in MaterialXView cannot be imported into Houdini which would say this isn’t an issue of the correct node graph setup as anything other than a standard surface fails, this is an issue with the USD Mtlx importer as a whole as it does not support nodegraphs with BSDFs as it only imports the surface (see screenshot from my first post).

Even if it does support it, when saving out the MaterialX file, the syntax is still incorrect and can’t even be read into MaterialXView, therefore it is not a valid mtlx material

Would be great to know if sideFX are aware of these issues/limitations and what plans there are to overcome them as otherwise MaterialX has no real advantage over the vex shaders as you cant even export and import <nodegraphs> from one Houdini session to another, let alone between other softwares.

Best,
Rich
Edited by Hypershader - March 19, 2022 03:15:14
User Avatar
Member
8043 posts
Joined: Sept. 2011
Online
Hypershader
But even totally functioning MaterialX nodegraphs in MaterialXView cannot be imported into Houdini which would say this isn’t an issue of the correct node graph setup as anything other than a standard surface fails, this is an issue with the USD Mtlx importer as a whole as it does not support nodegraphs with BSDFs as it only imports the surface (see screenshot from my first post).

mtlx nodegraphs from other sources have worked when imported to Houdini most of the time, such as from the AMD material library.
User Avatar
Member
37 posts
Joined: March 2017
Offline
jsmack
Hypershader
But even totally functioning MaterialX nodegraphs in MaterialXView cannot be imported into Houdini which would say this isn’t an issue of the correct node graph setup as anything other than a standard surface fails, this is an issue with the USD Mtlx importer as a whole as it does not support nodegraphs with BSDFs as it only imports the surface (see screenshot from my first post).

mtlx nodegraphs from other sources have worked when imported to Houdini most of the time, such as from the AMD material library.

as I mentioned in that bit you quoted, everything other than standard surface materials fails.

as far as I'm aware the AMD material node graphs are all using the standard surface so they work totally fine right? I could be wrong as I have only tried one or two materials from there
Edited by Hypershader - March 18, 2022 12:27:17
User Avatar
Member
37 posts
Joined: March 2017
Offline
Basically all I’m asking is will sideFX create an alternative import/export for MaterialX that supports NodeDefs at some point. USD currently does not support NodeDefs for MaterialX meaning we cant import the majority of MaterialX materials that ship with MaterialXView or any materials made in Houdini from BSDFs

This means the syntax from the saved file is wrong and even if the syntax was correct, it would still not be able to be reimported through USD as NodeDefs are not supported yet.

This is the reason the Lama nodes are not working and why we cannot transfer BSDFs but can transport Standard Surface meaning we need an alternative way to import MaterialX or hope that USD supports NodeDefs in the future

Best,
Rich
User Avatar
Staff
1455 posts
Joined: July 2005
Offline
I looked closer at the this, and the problem seems to be with the USD MaterialX file format plugin that reads in the .mtlx files. It is very picky about the XML document structure. The <surfacematerial> node and the surface shader (eg, <surface> or <standard_surface>) node are at the top level MaterialX document level, and any shader nodes feeding into the surface shader need to be inside a <nodenraph>. See the attached mtlx_export.hip file for details.

Hypershader
Unfortunately it does say that nodedefs are not currently supported but this shouldn't affect node graphs, right?
Correct. RMB > Save > MaterialX... does not produce any nodedefs. Ie, it does not define new shader node types. It saves the shader node network that consists of the known shader types.

Hypershader
When i add <nodegraph> and <output> manually, I can succesfully load this file into MaterailXView.
The 'materiallibrary2' LOP in the attached file saves out the nodegraph and output automatically. Sounds like it should be loadable in MaterialXView. But that still does not work in Houdini via the USD MaterialX file format plugin.

Hypershader
Unfortunately, I cannot reimport this file back into Houdini through a sublayer. So im assuming this is due to a lack of support on USD end for importing MaterialX node graphs
Correct.

jsmack
There doesn't seem to be any combination of nodes that produces a valid mtlx shader that can be read back into Houdini.
There seems to be, if you are initiated to the secret society of the nodegraph-feeding-into-final-shader worshipers. See the 'materiallibrary3' in the attached example.

Hypershader
it works for the standardsurface for some odd reason???
You probably did not try to feed any pattern shaders into it. As I mentioned, the material and the surface shader nodes can be at the top document level, but any pattern shaders that drive them cannot. They need to be either absent or put into a subnet. So it seems.

Hypershader
Having a Save -> MaterialX Nodegraph which fixes the syntax issues would be a great option so you don’t have to manually edit it.
As I mentioned above, you can build VOP nodes in such a way that Save > MaterialX... writes the nodegraph and an output, and you should not need to manually edit it. See 'materiallibrary2' as an example.

Hypershader
will sideFX create an alternative import/export for MaterialX
Our primary platform is USD and not MaterialX, so rather than providing an alternative MaterialX support, we are more likely to fix the USD MaterialX file format plugin for importing .mtlx files. There is also an ongoing effort in the ASWF community to improve MaterialX support in USD (see the ust-materialx working sub-group). All this should result in a better experience with MaterialX in Houdini.

Attachments:
mtlx_export.hip (145.8 KB)

User Avatar
Member
37 posts
Joined: March 2017
Offline
Hey Rafal,

appreciate you doing a deep dive into this!



As you expected, the 2nd option (using the subnets for <nodegraph> and <output>) works perfectly in MaterialXView although as you said there is issues reimporting through Usd Mtlx file format plugin back into Houdini.



In the third example (which allows for BSDFs to be re imported) works great for reimporting into houdini but unfortunaly is not able to be imported into MaterialXView due to syntax errors.

I thought including this inside a subnet may fix the issues but I get a message saying:

"nodegraph_subnet contains a subnet subnet1, this is not supported by MaterialX currently"

I'm assuming this is due to MaterialX not supporting nested node graphs?


Thanks again for all your help as at least now we know a method of saving out BSDFs and as a .mtlx between Houdini files which is a great thing to know!

Best,
Rich
Edited by Hypershader - March 25, 2022 13:21:00
  • Quick Links