Jump to content

Baking textures with multiple materials


StoneDwarf
 Share

You are about to reply to a thread that has been inactive for 4144 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

Hello everyone!

I was wondering how you bake out light maps when using several materials on a single mesh. I am a Maya user, but I suppose it is basically an issue everyone encounters.

To give you an idea of what I mean:Imagine having a mesh with a bunch of faces. I want to apply 8 materials to different groups of faces. After I applied the materials, I need to (and this is how it goes in Maya, not sure how it goes in other 3D programs) lay out the UV shells for each portion of faces that is attached to a material. This means that if I have 8 materials, I have 8 UV shells, overlapping each other.

Now here's the thing. When I select the mesh, Maya sees overlapping UV shells. So if I want to bake out light maps, things go wrong because Maya reads one big mess of overlapping Uvs.

My apologies if it sounds a bit confusing. Every bit of advice is highly appreciated! :)

Link to comment
Share on other sites

The UV set editor works just fine. I was aware of this option, but I never actually used it for SL, which is kinda silly of me because it works great for SL purposes. Basically what it allows you to do is laying out separate portions, pieces or parts of your UV layout, into different UV grids.

This means that I can create 6 separate UV layouts for each and every individual face of a square box. It also works nicely with Turtle.

There's a little drawback though … and that's the integration with Mudbox when working with multiple meshes. In order to paint over several UV layouts, Mudbox wants you to tile UV layouts. You must actually place them in and out of the 0 to 1 space in the Maya UV texture editor, tile everything nicely, then throw it into Mudbox and then (AND ONLY THEN, sadly) you can paint over your mesh without getting overlapping paint layers.

Mudbox doesn't attach your paint layers to individual UV layouts, your paint layers would overlap instead. Think about it as one big UV grid in which you have to tile your UV layouts.

So unlike Maya (where you can say I want this UV layout attached to these faces) you have to set out by hand (positioning your UV layouts) And this sucks lol, because a) I am a turtle fun, which requires me to use the UV set editor in order to have my materials and UV grids nicely set up b) I usually paint my own textures in mudbox and sculpt high poly versions in it, which I can use back in turtle.

I suppose there is way to tackle this problem, but I have yet to test it. What 'should' work I think is tiling everything in Maya just like how it happens in Mudbox. Maya doesn't care whether you are actually in or out the 0 to 1 space, as long as you follow those box/grid lines. So once everything is uv'ed ready for mudbox, I could start assigning UV sets. You would end up with something like: 1 UV set attached to 1 material which has its own UV layout. By doing that I would avoid having those overlapping paint layers in Mudbox and I could tell turtle which portions of my mesh I want to bake out.

I hope this makes any sense! :)

Link to comment
Share on other sites

You hit on just about all the points I was hoping you would (Turtle and Mudbox included). 

Here's how I usually do it.  I almost always put different parts of a model into different UV tiles.  I do this not only in preparation for Mudbox, but also just for organizational purposes.  It's a heck of a lot easier to keep track of everything when nothing appears to overlap. Nearly all target platforms understand the multiple tiles concept (as long as you avoid negative numbering, which some don't understand), so I've always just considered it generally good practice anyway.

It happens it's as easy to tell Turtle to bake any particular tile as it is to tell it to bake any particular UV set, so there's no loss on that front.  There's actually a slight advantage, in that you can tell Turtle to bake the entire UV range into one giant texture, which you can then slice up in Photoshop afterward.  As long as the number of tiles is reasonable, this can be a good semi-hack, for pseudo batch baking of multiple textures from one mesh.

What I've never figured out how to do, sadly, is a true batch bake, from either multiple tiles or multiple UV sets.   I've never found a way to tell it to take all the tiles or all the sets, and output each to a seaparate texture, automatically, in one go.  I have a hard time believing the option doesn't exist, but I just don't know how to enable it.  It would save so much time if I could make it work.  If anyone knows something I don't in this regard, I'm all ears.

Link to comment
Share on other sites

Cool. I'll keep this in mind. I wasn't sure if it would actually work but you just confirmed what I had in mind.

Doing a batch bake with Turtle should be possible, for sure. I've little experience with MEL scripting, but I'd guess a MEL script could do the trick. Not sure how, though. From what I understood, MEL scripts allow you to perform a series of actions, thus it *should* be possible to say bake this, bake that, use this settings, use those settings, etc.

Link to comment
Share on other sites

If I were a competent scriptor, I would never have had to ask. :)

 

Yeah, you can make Maya do literally anything via MEL. In fact, every button you press in the existing UI simply executes preset scripted functions. Users can add any amount of custom functions, or even redesign the whole thing, at will. That's what makes Maya such a powehouse. Everything is controlled the same way. Whether it be simply rezzing a cube or commanding armies of thousands for a Lord of the Rings movie, it's all the same thing, under the hood.

 

Turtle also can use Lua, another scripting language, commonly used in game engines.

 

Unfortunately, although I'm naturally good at a lot of technical things, programming isn't one of them. Hopefully a button-push solution exists.

Link to comment
Share on other sites

So sorry for jumping on the coattails of this topic but my evolution of skills development with Zbrush for SL Mesh models is arriving at this topic / hurdle.

So how are multiple materials defined in Zbrush to be exported by the Zsculpty .dae exporter?

I have just started learning the basics of PolyGroups and I have a suspicion that in Zbrush, you might define zones of materials / textures on the model somehow via the use of polygroups but I am not sure exactly how.

NOOB questions about mulitple materials / texture faces....

1)  Can I use different materials for each of these zones on the model or can a model only work with one Material?  Right now if I change the material to - lets say a Shiny Marble look - the entire model surface changes.  I would like to be able to apply a material to only one part of the model.

2)  The term "material" has been used.  Are we talking only about Materials or also zones of textures?

3)  In Zbrush I use ZMaster for UV mapping my model - an awesome UV creator.  But, if zones of textures seem to be determined by zones or islands of UVs, might this be a limit where ZMaster cant go?

I have a feeling this is where Bouttime will likely know the answers to this regarding the topic in this thread for Zbrush.

Link to comment
Share on other sites

 

not sure entirely what you're after but, to apply a material to specific part of your mesh, just mask out the rest of the model, then up top next to "rgb" select "mrgb" then fill the model as you would with color and the material will be applied as well to that section. then when you change material that section will retain the original one, only the rest of the model will change.

rgb fills color, mrgb fills material and color.

as for UVs, explore UV master, you can create several different types, you can isolate islands or paint where you want the seems to be and so on.

Link to comment
Share on other sites

Don't know how you get it in Zbrush, but what makes different faces (i.e. patches you can put different textures on) inworld is having different materials assigned to them in the collada (.dae) file.

Technically, this means different <triangles>, <polygons> or <polylist> sections inside the <mesh> section in the collada file. Each of these will have a "material" attribute (e.g. <triangles ... material="xyz">). If you feel up to it, you could make a simple cube and look at the collada file to test whether you can get that. Ignore the material description parts and look for "<library geometries>" - the relevant sections are in there.

Link to comment
Share on other sites

Here's an interesting twist.  I was talking about this with a friend/colleague of mine, and it turns out he is able to batch bake textures from multiple UV sets from a single mesh, in Turtle.  He was rather surprised that I couldn't, since for him, it's just always worked. 

All he has to do is make sure $u is in the output string, hit the Render button, and all the textures get spit out.  When I do the exact same thing, only one texture gets generated, from only the current UV set, nothing more.  If I want the others, I have to do them one at a time.

Additonally, for me, the Render -> Batch Render command becomes completely nonfunctional when Turtle is set as the active renderer.  Even the options box won't open.  Switch to any other renderer, and it opens right up.  I'd never noticed this before, since that command is really only used for rendering animation sequences, and I don't typically use Turtle for that.

My friend does not have this issue. He can run a batch render with Turtle, no problem.  

I have to assume these two problems are related.

Stone, I'm curious.  Does the Batch Render command work for you with Turtle?

 

 

Just to be perfectly clear, if I've got more than one model selected (or more than one added to the bake layer), I can batch bake one texture from each, just by hitting the Render button once.  It's only in trying to generate more than one texture from any one model that it fails.  I assume it's the same for you?

Link to comment
Share on other sites

I am having the same as you have, yes. Which version of Maya are you and your colleague using, and do you have service pack 1 installed?

Also, as a follow up to my previous post in which I explained my workflow, I am running against some issues. I sculpted a high poly model (one single mesh that is) in Mudbox, imported it back to Maya, had my UV layouts tiled nicely in preparation for Mudbox which worked just fine (where as the UV layouts are a collection of faces with a material attached to it) and assigned each and every UV layout to its own UV set.

Turtle doesn't read the UV sets out of the 0 to 1 space once I start baking it seems. I end up with a black baked texture. Once I put the UV layout back into the 0 to 1 space, it ... of course .. works again.

How do you do it, without cropping stuff in Photoshop?

I am not sure, but I believe I tested this kind of stuff before and I remember I was quite happy with the results. It did work, somehow. Will have to check it out tomorrow.

Link to comment
Share on other sites


Priestt wrote:

Which version of Maya are you and your colleague using, and do you have service pack 1 installed?

We're both using Maya 2009, and Turtle 5. 

I do not have SP1 installed.  I'm not sure if he does.  Good question.  I'll find out.

 


Priestt wrote:

Turtle doesn't read the UV sets out of the 0 to 1 space once I start baking it seems. I end up with a black baked texture. Once I put the UV layout back into the 0 to 1 space, it ... of course .. works again.

How do you do it, without cropping stuff in Photoshop?

 

In your Turtle settings, go to the Baking tab, and open up the Texture Bake Settings section.  In the bottom part of the section you'll see options for setting the UV range, and specifying the UV set.

turtle_UVrange.jpg

 

If you want to bake a range other than the primary tile, then as shown in the picture above, set the range to User Specified.  Enter in the minimum and maximum coordinates for whatever range you want to bake.  This can be a full tile, part of a tile, several tiles, whatever you want. 

By default, the range will be <0,0,1,1>, the primary tile.  If you want the next tile over horizontally, change it to <1,0,1,1>.   I'm sure you can take it from here. :)

 

As we've discussed, I know of no way (other than via script) to automate the process of shifting focus from one range to the next.  So, you'll have to render one texture at a time this way.  Decide on a case by case basis whether you think it's best to go one at a time, or to do the full range in one go, and then slice it in Photoshop afterward.

 

 

  • Like 1
Link to comment
Share on other sites

Ah. I assumed you two had Maya 2012, which is why I spoke about SP1. I am not sure if Maya 2009 has a SP as well, but yeah its worth checking out. Your collegue actually knows that you are trying to perform a batch bake on one and the same mesh instead of baking out several meshes, right?

Batch bake works for me when I bake several meshes all at once that share the default UV layout settings (the zero to one space). The problem lies in telling Turtle which tiled *sub UV layouts* need to be baked out from the big UV layout and actually doing them all at once, with one single mesh. It should be possible because a) we know Turtle can perform batch bakes in any other scenerio b) its possible to say which UV coordinates must be used when doing a batch bake.

Also, given the fact that we can actually tell Turtle which UV coordinates it must use, I would assume the UV sets are not necessary at all. This is because we can easilycreate 8 UV tiles (1 for each material) in the UV texture editor and by doing what you just said we tell Turtle which coordinates it must use, and thus plenty of UV space and no overlapping UV layouts. I have not tried it yet though, I might forget something.

As for the texture baking ... Thanks! It was 4:50am or something when I wrote the message above and I was not looking good enough. Shame on me! Now that I will keep baking out textures like this I *must* find out how Turtle can do a batch bake. Will give it a try again after a cup of coffee ... or ten.

Link to comment
Share on other sites

Yeah, 2009 does have a service pack available for it.  I've just never installed it.  I'm religious about updates with all my other softwares, but Maya can be a tempramental beast, and I guess I've been afraid something might break.  That fear is probably irrational.

 

Anyway, yeah, the person I mentioned knows exactly what I was trying to do.  We talked about it at length, as we both tried the same things, and kept getting different results from each other.  He mentioned he once had had a similar problem getting Mental Ray to do batch bakes, and the problem turned out to be some sort of internal sub-licensing mismatch, buried way down somewhere or other.  It's possible something like that is going on with certain Turtle installations.  Or it could be something else entirely.

Link to comment
Share on other sites

An internal sub-licensing mismatch? oO

But yes, updates might be the problem. I am using 2012 though, which comes with a different version of Turtle. I think its an error on my side, and that I am doing something not right.

About the UV settings ...

I am playing with the UV range settings which seems to be pretty straight forward, but I am not getting it. :matte-motes-evil: I used fluffy rainbow colors to keep things interesting, but I keep ending up with blue, 2 times half a UV tile yadda yadda. 

aa.jpg

 

Edit,

Never mind it, figured it out. I didn't realize I had to fill in negative values in the MIN sections :matte-motes-big-grin:

Link to comment
Share on other sites

Gald you figured it out.  Generally speaking, it's best practice to avoid negative coordinates.  Not all programs understand them.  Mudbox does, but I know Modo does not, and I'm not sure about Zbrush.  As for target platforms, most do understand them, including SL, but there are some that don't.

Link to comment
Share on other sites

The problem I personally have in attempting to even experiment with figuring out how Zbrush MIGHT create multiple texture zones / surfaces for export to SL is..... I dont know enough about the fundamental concepts that creates these zones and worse yet is Pixelogic's notorious habit of giving stupid confusing names/terms that dont align with any terms used in the industry.  I might be looking for "UV Islands" for Zbrush on google and Zbrush might have termed them "UV Whatchamacallit".

An experienced Zbrusher might know.

I might send an email or postings somehow to the ZSculpty Plug creator - ShinyLife - to see if they have any instructions ... or worse yet if they even support the export of multiple texture surfaces to DAE.

Link to comment
Share on other sites

I still have a problem though. I now know how to tell Turtle which UV layouts I want to bake out. And while I was learning this, I also learned that (from what I have understood) there is only space for 4 UV layouts, instead of 8. You can, of course, throw in as much as you want, but you won't be able to bake the textures out separately

Multiple UV sets might work you would think, but by doing that it wont coorperate with Mudbox because Mudbox want a nice collection of UV layouts tiled next to each other, within one UV set.

See where my problem lies?

What I am trying to say is that in order to bake out all 8 materials with Turtle, you *must* use UV sets. Problem is, though, that Mudbox doesn't work with UV sets, it instead wants you to import a mesh with all UV layouts nicely tiled next to each other

Any tips? :P

@ Toysoldier. Multiple texture surfaces? I assume you are trying to do the multiple materials trick to end up with several faces in-world, right? If so, why would you do this with or in Zbrush?

Link to comment
Share on other sites

You are about to reply to a thread that has been inactive for 4144 days.

Please take a moment to consider if this thread is worth bumping.

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
 Share

×
×
  • Create New...