How to bake MaterialX shader to textures?
2493 6 3-
- alexmajewski
- Member
- 109 posts
- Joined: Aug. 2017
- Offline
-
- ajz3d
- Member
- 654 posts
- Joined: Aug. 2014
- Offline
Yes, it's possible.
First, if you haven't already, look into this thread [www.sidefx.com] on how to set up the LOP network for Karma texture baking.
Then, look into Karma AOV 2.0 VOP [www.sidefx.com] and the screenshot that I posted below, which shows an example setup inside the Material Builder. Whatever you put into "AOV Name" parameter, will become a RenderVar in the LOP Net, which you will then have handle with a Render Product or Karma Render Products LOP

I'm using a similar setup in my automated Karma Texture Baker HDA, on which I've been working for some time. HOWEVER, I'm on a stage where I have not yet tested this setup with a tri-planar mapping yet, so let me know if this solution worked for you. I'm very interested in this. My optimistic guess is that there shouldn't be any problems with it.
EDITED because the forum still doesn't display webp images. Ugh.
First, if you haven't already, look into this thread [www.sidefx.com] on how to set up the LOP network for Karma texture baking.
Then, look into Karma AOV 2.0 VOP [www.sidefx.com] and the screenshot that I posted below, which shows an example setup inside the Material Builder. Whatever you put into "AOV Name" parameter, will become a RenderVar in the LOP Net, which you will then have handle with a Render Product or Karma Render Products LOP
I'm using a similar setup in my automated Karma Texture Baker HDA, on which I've been working for some time. HOWEVER, I'm on a stage where I have not yet tested this setup with a tri-planar mapping yet, so let me know if this solution worked for you. I'm very interested in this. My optimistic guess is that there shouldn't be any problems with it.
EDITED because the forum still doesn't display webp images. Ugh.
Edited by ajz3d - April 30, 2025 19:01:31
-
- ajz3d
- Member
- 654 posts
- Joined: Aug. 2014
- Offline
I'd like to bake multiple shadeless maps: (...) as separate images
I forgot to address this part of your question. Karma Render Products LOP provides this by default for each multiparm entry. See the "Product Name" parameter for the file name that will be generated from each product. Render Product LOP comes with an empty "Product Name", so it will have to be filled manually with something like
$HIP/render/$HIPNAME_Roughness.png, for example.Also, in order to be rendered, custom render products need to be added to Render Settings LOP's Ordered Products parameter. I'm using the following pattern:
/Render/Products/* ^/Render/Products/Vars
Edited by ajz3d - May 1, 2025 06:26:14
-
- alexmajewski
- Member
- 109 posts
- Joined: Aug. 2017
- Offline
@ajz3d Thank you very much
You gave me all the missing pieces to finally figure it out.
But I'm stuck on one last thing: my bakes have an ugly UV border line on all passes. Here's a 4K basecolor texture assigned to my geo after baking:

Do you know if there's a setting that helps minimize this effect? My current solution is to run my textures through Extrapolate Boundaries COP.
As for baking triplanar, it works most of the time, but I got this weird bake on a small concave side of my object, it appears only when using triplanar (it's already visible in the camera with the UV lens in the viewport):
EDIT: I got the same glitch in a COPs-based triplanar projection, I think something's just messed up with my mesh. This means Karma triplanar baking is probably fine. EDIT2: UV was overlapping itself (auto uv), so two UV faces were fighting for the same pixels. Triplanar projection is definitely fine.
You gave me all the missing pieces to finally figure it out.But I'm stuck on one last thing: my bakes have an ugly UV border line on all passes. Here's a 4K basecolor texture assigned to my geo after baking:
Do you know if there's a setting that helps minimize this effect? My current solution is to run my textures through Extrapolate Boundaries COP.
As for baking triplanar, it works most of the time, but I got this weird bake on a small concave side of my object, it appears only when using triplanar (it's already visible in the camera with the UV lens in the viewport):
EDIT: I got the same glitch in a COPs-based triplanar projection, I think something's just messed up with my mesh. This means Karma triplanar baking is probably fine. EDIT2: UV was overlapping itself (auto uv), so two UV faces were fighting for the same pixels. Triplanar projection is definitely fine.
Edited by alexmajewski - May 1, 2025 11:57:26
-
- alexmajewski
- Member
- 109 posts
- Joined: Aug. 2017
- Offline
I actually feel like my use case is probably better addressed by Copernicus, so I'm going to most likely switch to it, but I thought I'll write down some notes on things that tripped me up, if anyone finds this in the future:
The UI has shifted a bit, Karma UV Lens is now available in the CVEX Shader Builder in a Material Library, or directly in a Material Network. The documentation has a proper walkthrough [www.sidefx.com] on setting it up.
The bake is viewable through the camera in a live render viewport after the render settings have been set.

Here's the general minimal setup and order of nodes

Karma Render Products LOP has a button that generates products based on existing AOVs in the connected stage:

Keep camera position&rotation at 0,0,0. And lastly, as already mentioned, products need to be ordered in render settings.
Everything else works just like in CGWiki's tutorial.
The UI has shifted a bit, Karma UV Lens is now available in the CVEX Shader Builder in a Material Library, or directly in a Material Network. The documentation has a proper walkthrough [www.sidefx.com] on setting it up.
The bake is viewable through the camera in a live render viewport after the render settings have been set.
Here's the general minimal setup and order of nodes
Karma Render Products LOP has a button that generates products based on existing AOVs in the connected stage:
Keep camera position&rotation at 0,0,0. And lastly, as already mentioned, products need to be ordered in render settings.
Everything else works just like in CGWiki's tutorial.
Edited by alexmajewski - May 1, 2025 09:19:21
-
- ajz3d
- Member
- 654 posts
- Joined: Aug. 2014
- Offline
alexmajewskiLike you already observed, the problem with visible UV seams can be addressed with Extrapolate Boundaries COP. For simple bakes (single UDIM, no baking with name matching), you can also use image filters, available in Render Settings LOP → Karma → Global → Image → Image Filters. There are three boundary extrapolating algorithms: UV Average Fill, UV Flood Fill and UV Diffuse Fill, each with its own advantages and disadvantages.
my bakes have an ugly UV border line on all passes.
(...)
My current solution is to run my textures through Extrapolate Boundaries COP.
However, don't use them if you intend to further process baked textures down the stream (compositing, blending, etc.), as boundary extrapolation should be (at least according to my own experience) one of the very last operations applied to textures. Perhaps succeeded only by dithering during texture conversion from 16/32-bit to 8-bit pixel depth.
alexmajewskiThanks for letting me know.
Triplanar projection is definitely fine.

alexmajewskiSimilar artifacts may also appear if Ray Bias of
weird bake on a small concave side of my object
(...)
UV was overlapping itself
kma_uvlensis too small.
-
- alexmajewski
- Member
- 109 posts
- Joined: Aug. 2017
- Offline
@ajz3d I'm doing this purely for sport now, but this seems like exactly what is needed.
Unfortunately the filter doesn't handle black background on an RGB AOV, it leaves black pixels around the shape (somewhat expected):

So how about we convert it to RGBA first so there's no bg:

And it works in the viewport flawlessly:

But after rendering, it turns out the final image is saved as Raw colorspace, despite specifying sRGB in the product, which has worked before this conversion.
No idea if that's a bug or what. I only noticed that my rendervar's dataType changed from color3f to float4 instead of color4f, not sure if that's important.
Edit: I just scrolled back up and realized you set RGBA on the image node itself. I now tried it, but it has the exact same result.
Unfortunately the filter doesn't handle black background on an RGB AOV, it leaves black pixels around the shape (somewhat expected):
So how about we convert it to RGBA first so there's no bg:
And it works in the viewport flawlessly:
But after rendering, it turns out the final image is saved as Raw colorspace, despite specifying sRGB in the product, which has worked before this conversion.
No idea if that's a bug or what. I only noticed that my rendervar's dataType changed from color3f to float4 instead of color4f, not sure if that's important.
Edit: I just scrolled back up and realized you set RGBA on the image node itself. I now tried it, but it has the exact same result.
Edited by alexmajewski - May 2, 2025 05:17:32
-
- Quick Links

