A couple of problems with Bake Texture ROP

   6876   11   2
User Avatar
Member
467 posts
Joined: Aug. 2014
Offline
Hello.
I'm currently exploring Bake Texture ROP and I'm having two problems.

The first one is that I'm trying to bake point colors of a reference mesh into the uv object. I believe that “Surface Unlit Base Color (basecolor)” is best suited for this job because it seems that GameDev Baker uses that and it does work indeed. However when I render it with the Bake Texture ROP itself, mantra outputs basecolor image plane as pure black.
What might be the culprit here?

The second problem happens when I attempt to bake textures of multiple objects (added with UV Render Objects multiparm block). All objects are in the same UDIM tile and use the same material, so nothing special about them. When I bake them, mantra overwrites contents of my output texture file every time it processes each consecutive object, and ultimately leaves me with a texture of the most recently processed object.
Can this can be avoided and how?
User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
The bake texture rop can only bake exports that actually exist in the material. If your material does not export ‘basecolor,’ then nothing will appear in that channel. The gamedev baker forces the same material to be applied to everything being baked, and can only bake point color out as the basecolor. Most of the built-in materials export basecolor already, are you using something custom? Perhaps there is something else going on if you are using, for example the principled shader, and it is not exporting the expected value for basecolor.

As for the naming conflict, you have to put the name of the object in the image path, or they will all overwrite each other. see: http://www.sidefx.com/docs/houdini/nodes/out/baketexture.html#object-pattern-matching [www.sidefx.com]
User Avatar
Member
467 posts
Joined: Aug. 2014
Offline
Hi @jsmack! Thank you for your reply.
jsmack
The bake texture rop can only bake exports that actually exist in the material. If your material does not export ‘basecolor,’ then nothing will appear in that channel. The gamedev baker forces the same material to be applied to everything being baked, and can only bake point color out as the basecolor. Most of the built-in materials export basecolor already, are you using something custom? Perhaps there is something else going on if you are using, for example the principled shader, and it is not exporting the expected value for basecolor.
I had Principled shader assigned to UV objects only. After assigning it also to reference objects, basecolor finally bakes properly. Many thanks!

As for the naming conflict, you have to put the name of the object in the image path, or they will all overwrite each other. see: http://www.sidefx.com/docs/houdini/nodes/out/baketexture.html#object-pattern-matching [www.sidefx.com]
Using wildcards produces another two problems on my end.
My objects use the following naming convention:
(object_name)_(retopo|cage|reference)
If I enter the following into UV Render Objects multiparm item 1 fields:
UV Object 1      : /obj/*_retopo
UV Cage Object 1 : /obj/*_cage
High Res Object 1: /obj/*_reference
Output Picture 1 : $HIP/render/*_%(CHANNEL)s.%(UDIM)d.rat
Then nothing renders out correctly (even Nt comes out all gray for each object).

That's one problem.
The other one is that with wildcards Mantra bakes textures of each object to a separate file, which is something I do not want.
What I'm after, is an output similar to the internal baker of Substance Painter: while each object is baked separately (Painter's “By Mesh Name” matching), output textures are generated per material/UDIM (ergo number of output textures is independent on the number of objects).
User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
The default is to name each texture after the matching object name string. If you need more complex control, you will probably need to look into the shell rop so you can set variables your self to be referenced by the bake texture rop. The wedge rop might get what you need without having to write the scripts yourself, but I find it generally falls short of doing exactly what I need and fall back to the shell rop anyways.
User Avatar
Member
467 posts
Joined: Aug. 2014
Offline
You mean in order to script in post-bake compositing of the output textures?
This is getting more complicated than I thought it would. Especially if to consider that many image planes (line Nt) do not output alpha.
User Avatar
Member
7771 posts
Joined: Sept. 2011
Offline
I mean to change the nature of the loop. The bake rop gives an object-centric flow control. Multiple objects are processed independently, the naming follows that structure. To have the naming follow a different structure, you would have to design your own logic.

Processing multiple objects without having the textures correspond specifically to each object doesn't really make sense, since more than one object can share the same material, but will produce different results when baking. If your workflow involves non-overlapping materials, and a single material per object, you could build your own script for naming the output based on the material assigned to the object instead of the object name.
User Avatar
Member
14 posts
Joined: March 2018
Offline
jsmack
The bake texture rop can only bake exports that actually exist in the material. If your material does not export ‘basecolor,’ then nothing will appear in that channel. The gamedev baker forces the same material to be applied to everything being baked, and can only bake point color out as the basecolor. Most of the built-in materials export basecolor already, are you using something custom? Perhaps there is something else going on if you are using, for example the principled shader, and it is not exporting the expected value for basecolor.

Was looking for an answer to this and stumbled upon this thread through google. Nice explanation - just realized that my material does not export basecolor…
User Avatar
Member
385 posts
Joined: July 2018
Offline
Is it possible to pass a primitive attribute to the filename? like a name attribute.
User Avatar
Member
8555 posts
Joined: July 2007
Offline
papsphilip
Is it possible to pass a primitive attribute to the filename? like a name attribute.
I don't think there is any partitioning happening based on attributes apart from udim
But this should be straightforward using TOPs
Tomas Slancik
FX Supervisor
Method Studios, NY
User Avatar
Member
385 posts
Joined: July 2018
Offline
tamte
papsphilip
Is it possible to pass a primitive attribute to the filename? like a name attribute.
I don't think there is any partitioning happening based on attributes apart from udim
But this should be straightforward using TOPs

Could you provide a hip file i can reference?
User Avatar
Member
385 posts
Joined: July 2018
Offline
Here is my take on this problem.
I haven't found a way to get the name primitive attribute inside TOPs.

I am trying to have the name attribute appear on the final render and using another attribute set the resolution of the render so that it is custom for each geo.

i import the geo using the Geometry Import node and use the data extraction tab to bring in the resolution attribute, but it feels like a hack and also when i cook this graph its not working as expected. its a bit confusing, the bake texture rop reads a sop node outside the top network, maybe it should be reading the geo import? i am not sure, but right now when i cook its not working properly
Edited by papsphilip - Sept. 26, 2021 15:13:25

Attachments:
Capture.JPG (183.3 KB)
Capture.JPG (209.6 KB)
untitled.hip (2.0 MB)

User Avatar
Member
385 posts
Joined: July 2018
Offline
i have made some progress but its very slow and i think its calculating more stuff than it should. But it kind of works. I am sure there is a better way, this one seems like a hack to me.

Any advice would be very much appreciated!
Here is the demo scene

Attachments:
baketextures.hip (2.2 MB)

  • Quick Links