Ability to work around MaterialX conversion limits in existing graphs

I’m maintaining a couple of packages where Polyspatial support would be great, but I can’t break the existing functionality just for that. Ideally there would be a way to make some specific changes to a graph similar to how keywords work.

I found the (undocumented) “MATERIAL_X” keyword that is always assumed to be true when exporting to PolySpatial; I believe this is close to what I’m looking for but happy to learn more.

Turns out that there’s a “built-in keyword” for that too (also can’t find it in the docs).
However, that does not allow to pass through texture data, only numeric data. So a custom function node that modifies a Sampler2D can’t be “skipped” as far as I can see.

Right; if you branch on the built-in MaterialX keyword, you can provide different implementations for MaterialX export versus use within Unity (that is, conversion to ShaderLab).

As you note, the keyword nodes select between numeric values. However, anything that’s behind the MaterialX Off input (including any custom function nodes) won’t be included in the MaterialX output.

Thanks for the reply!
The issue in my case is that there’s a custom function node inside a subgraph, and that subgraph has a texture input and texture output which also runs through the custom function node for UV manipulation.

For MaterialX I would want to basically “bypass” the custom function node:

Any ideas? Can I somehow attach a custom MaterialX node writer and teach it to bypass this?

As far as I know, this should work; the only problem is that the custom function node will still be “converted” and thus generate warnings for invalid HLSL. The result of that conversion will be discarded, however. I think we can fix that in a future release (avoid converting the custom function node if it’s upstream from a MaterialX Off input).

Is that your issue, though? That the conversion is generating warnings? Or is the output actually incorrect? Feel free to submit a bug report with a repro case and let us know the incident number (IN-#####); that will help us track the issue.