Multi-Texture Bake In Maya?

Greetings!

Please let me know what I’m doing wrong here, as I seem so close to getting it right… :?

What i’ve been doing in Maya is selecting groups of faces on an object and assigning materials to just those faces. Then I’ll select a different group of faces on the same object and assign a different material to those. Everything works fine until I attempt to bake these various materials into a single texture.

I follow all steps for traditional baking, including setting up a UV map and then selecting the object and then materials and it works fine with a single material.

Is there anyway to get this working with multiple materials on a single object and if so, how?

Any help is GREATLY appreciated.

:smile:

multiple shaders don’t really work that way when you want to bake them. The way your doing it you would have to bake each shader individually and then combine them in photoshop. But if you want to do it with a single shader in maya then u would have to use a layered shader or an mib_color_mix node. For that you would have to lay out the UVs similar to the way you applied the separate shaders, and then use alpha channels to mix the two. Hope that helps

Well, thats not entirely true. Yes Maya is dumb when it comes to baking, but if you aren’t afraid of a little mel script, then you can get the job done quite easily. Here is part of a larger script I wrote:

============================================

// Create bake set
string $bakeSet = createNode "textureBakeSet" -n "myBakeSet";
setAttr ($bakeSet + “.colorMode”) 0;
setAttr -type “string” ($bakeSet + “.prefix”) (“BAKEDTEXTURE_” + $name);
setAttr ($bakeSet + “.xResolution”) 2048;
setAttr ($bakeSet + “.yResolution”) 2048;
setAttr ($bakeSet + “.fileFormat”) 6;
setAttr ($bakeSet + “.bakeToOneMap”) 1;
setAttr ($bakeSet + “.fillTextureSeams”) 4;
setAttr ($bakeSet + “.overrideUvSet”) 1;
setAttr -type “string” ($bakeSet + “.uvSetName”) “bakedUVs”;

// Perform Bake
string $lightMap = "convertLightmap -sh -bo “+$bakeSet+” -ulb "+$shaders;
string $result[ ] = eval($lightMap);

============================================

Basically you make your own bake set, then run the “convertLightmap” command. This is essentially what the mental ray batch bake is doing, but if you do it manually u have a bit more control.

The trick to get Maya to bake all your shaders in one go is to supply that command with all the shading groups on your mesh. So say you have blinn1 blinn2 and blinn3 assigned to your mesh, which is named mesh1. In order for it to bake all of them, the convertLightmap command would look something like this:

convertLightmap -bo $bakeSet -sh blinn1SG mesh1 blinn2SG mesh1 blinn3SG mesh1;

Where $bakeSet is a bakeset you already have somewhere. Each shading group needs to be followed by the name of the mesh, even if u only have 1 mesh. Kinda stupid, but whatever.

That will get maya to render them all together for you, but the really dumb part comes when you have multiple shaders assigned to your mesh, and you want to bake final gather. For some reason you cannot render them all in one pass, it will sit there and recalculate the final gather points, and rerender your mesh, for each shader you have on the mesh. If it takes 20 min to render 1 shader, and you have 20 shaders, it accumulates in time dramatically.

Hope this helps, any questions just ask.

Oh one more thing I would like to point out when it comes to baking.

Say you have 3 cubes that you laid your UVs out on, and they all have their own shader assigned to them, but their UV’s overlap, and are not suitable to baking.

Well, a trick is to combine them so you have 1 mesh, then do an automatic projection, but when you do, tell it to lay out the UV’s in a new UV channel. For example lets call them bakeUVs.

Then when you go to bake your texture, tell it to use bakeUVs when it bakes. It will bake the final texture out to the automatic UV layout, while it reads textures from the original / overlapping UV layout.

Then when you are done, copy the UV’s from the bakeUVs set to the main UV set and apply your new texture.