Join Adam Crespi for an in-depth discussion in this video Baking occlusion using the Batch Bake dialog, part of Creating Game Environments in Maya and Photoshop.
With my model unwrapped and my high-res pieces in place, I'm going to use Batch Bake to bake the occlusion from the high-res garage door on to the low-res. However, I need to do a quick fix in here first. I'll zoom in on that door. Remember, from the occlusion demonstration that occlusion tends to occur in the corners where adjacent objects block bounce light. What we can see here in the low-res door on the left is that the door is recessed into that frame by 6 inches. The high-res door is in the right place but not far back enough.
I'll hide it temporarily. I will move it forward first so I can see what I'm doing, and then press Ctrl+H to hide. Now what I'm going to do is extract the low-resed garage door face out of this mesh. I'll press F3 to go over to the Polygons menu, and right-click, and choose Face. I'll pick that large face, and choose Mesh > Extract. I'll press W for Move, and reselect just that garage door, making sure I right-click and pick Object Mode. With the low-res door selected, I'll choose Display > Show > Show Geometry > Poly Surfaces, and then pick that low-res door if it's not already.
Then I'll press Ctrl+H to hide it, and finally then, I take the high-res door, and move it back. I'll press V and D to move the pivot, and snap the pivot down on one of the corners. Then hold V for Snap and snap on one axis back into the right place in the frame. It's important to do this, and the reason is I want the adjacent wall to cast occlusion on to that garage door correctly, as if it had sat there for years closed and all kinds of dirt and schmut accumulated in the corner.
Now I'm ready for a bake. I'll press F6, and under Lighting and Shading, choose Batch Bake (mental ray), opening up the dialog. In my Batch Bake, the default settings are using the existing bake sets. What I will do is use the bake set override and change my Color mode down to Occlusion, because we can see in here, I've got options for baking out lighting color or even just illumination, and I can also bake out just lighting if I need to map it on as a light map. I'll pick Occlusion and there is my occlusion rays and falloff, similar to the Occlusion Shader I showed previously.
This is another reason why modeling in real-world scale is so important, making sure that if things are in real-world scale, the occlusion goes far enough. Occlusion rays are a sampling quality. Rays of 128 will result in a decent size render, but a nice smooth occlusion. I'm going to try it like this and see how it looks. It's put a prefix in called baked. I'm going to change this to high res garage door, and there is an X and Y resolution. What I usually do is to bake twice as big.
What this means is that I'm aiming for a texture that is 1024 square. So I'm going to bake at 2048, and paint at 2048 for my other work in Photoshop. Then I'll take this map, and when I save it out, I'll try it both reduced out in Photoshop, and also letting Unity reduce it in size to see which one looks better. It's okay to experiment along the way. For occlusion, I want to bake to one map, baking a complete map here, and then I'd like to bake the alpha as well because I can use it to select.
I'm going to bake this as a TIFF with a bit depth of 8 per channel. If it's too low in quality, if there is some aliasing or other issues, I can always up the samples here. If we need, we can have final gather quality and reflection factor in. Although for occlusion, it doesn't matter. Finally, I am going to use the 0 to 1 range, the normal range of the UVs, because I've unwrapped everything into that 0 to 1 quadrant in my texture editor. If we can accept other parts of the UV range, such as the entire range or a user-specified min and max, we can put it in here, but I'm going to leave it alone.
If we've added on a new UV set, or we'd like to bake into something besides Map 1, we can override the mesh set assignments as needed. I'll scroll up, make sure everything looks good, and hit Convert and Close. This may take a minute, but I'll do it and show what it looks like when I'm done. My bake is finished. What we can see here, and I will close this Bake dialog, is that mental ray has done the bake, and it's added on a new material on to this which is actually a black lambert with the baked image in the incandescence map.
I'll right-click and choose Material Attributes and check out what this looks like. I haven't deleted the history yet which is okay as I'm going to do it before I export anyway. I'll go into Lambert2, I'll open up this file in Photoshop, and see how this occlusion came out. Here in Photoshop, I'll go find that occlusion. I'll press Ctrl+O to open up the image. It actually nested fairly deep in that Environments project. Here in Game Environments, I've got renderData. In renderData, there is mental ray, in mental ray, here is lightMap, and finally, there is my high-res garage door.
We could set our project in the secondary locations to go somewhere different. However, I'm comfy leaving it here because I'm going to go dig it out and use it anyway. I'll click Open and I'm going to turn off my Grid, choosing View > Show > Grid. There is the occlusion. And when I zoom in, I can see it looks pretty good. What I've got here very nicely is the darkness around the edge from the door frame, and then darkness on each panel. Really makes the detail pop out nicely. When I map this on to a low-res door as either dirt, or rust, or maybe both, it's going to look like there is an enormous amount of detail and shading on just that single polygon.
What I probably should do is adjust that falloff a little bit. Right now, I think 12 is a little big. I am getting a little bit of a crossing right here in the corners where I could probably back off the distance of the occlusion just a touch, so it's not quite so bold in the panels. And that way, it just sits in as dirt instead of spreading as a uniform gray across. Back here in Maya then, what I'll do is reassign those checkers, choosing Assign Existing Material > Unwrap Checkers. I'll go back into my Batch Bake, and adjust this Occlusion falloff.
I'll pull it down to 8 and try it again. As I said, this may require some experimentation. Although, once you've got it going pretty nicely, you can apply that to other objects. I'll hit Bake and see how this looks; getting the occlusion baked out, so I can use it in the next video as a foundation for dirt, as occlusion, dirt, and rust, and to cluster in the same places. I can apply the idea of the Batch Bake here on anything I have modeled in high-res. I've got the other windows, the doors, and the other windows on the cashier station to do.
Finally, I can even use a Bake on a low-res object if I need occlusion from other things on it. As an example, I may want some occlusion on my foundation elements, but I've stacked the UV, so that may not be an option. What we need to do as part of baking then is really consider, how do things stack up? If UVs are stacked and an occlusion bake is in place for one, all those stacked UVs will share that darkness, and it may look kind of odd. So I tend to reserve it for things I can isolate, like these high-res doors where I really need the detail to pop out.
I'll run this bake again and see how it looks, and move on to do some texture painting in the next video.
- Analyzing concept art for contours, texture, and shadow detail
- Blocking out the basic form of a building
- Modeling modular elements
- Planning for occlusion and texture stacking
- Creating the low-poly-count elements
- Planning a texture sheet
- Stacking UVs
- Transferring maps
- Baking occlusion and normal maps
- Drawing detail at the right size
- Painting layers of dirt and wear
- Adding lights and refining materials