Sunday, February 22, 2009

3D Guru - Normal Mapping a Character - by Mark Blosser











Editors Note: You can download a PDF version of this article which has all of the full-res images in-line. See the note at the end.
In this article I will explain how I go about creating a normal mapped game character. For those who are unfamiliar what a normal map does, it is an additional texture map that, in essence, will make a low poly model look like a much higher poly model. When done well, the effect can be stunning, and can make a relatively low poly model look like a multi-million poly model!
Normal maps have been around for a few years now, and can almost be considered mandatory for creating next-gen game models. While I can't take credit for "inventing" many of the techniques in this article, I am presenting these tips as tried and true methods of working.

What you'll need is a low-poly game-ready version of your model, and also a detailed high poly version. The sky's the limit as far as how detailed you make your high poly, just remember that a normal map is still just a texture map, and you are limited by the number of pixels in the texture. I've found that normal maps work best for the big details (even though it sounds like an oxymoron!). Also keep in mind the distance from the player your character will be seen, it's easy to get caught up in tiny details, but if your character will never be seen up-close, it's best to leave the smaller details to the diffuse texture.
You won't need UV's on your high poly model, but you WILL need your UV's on your low-poly model, and the rules have changed a bit with normal mapping. Seams are your worst enemy; you could have an absolutely seamless diffuse texture, yet seams will still show up once your normal map is applied, and this almost always happens regardless of the game engine. Try and have as few seams in your UV layout as possible, even if this means wasting a little texture space. Unwrap your model in large contiguous sections, pelt mapping is useful for this. Some seams are unavoidable, so try and hide them in inconspicuous areas, or where real-life seams would occur, such as a break between clothing and armor. Also, try and run your UV's in horizontal or vertical lines as much as possible, this will avoid aliasing in your normal map and produce nice sharp details, rather than "jaggies", especially for non-organic or mechanical details that need crisp detail.
There is one last thing to mention about your UV layout, and that regards mirrored and overlapping UV's. It's long been a common practice to have mirrored UV's that overlap for symmetrical body parts, this saves texture space and also texturing time. But this presents a problem with normal maps, often producing artifacts like "inside-out" lighting when in-game. If your game engine will not correct for mirrored UV's then you must give everything it's own unique UV space. Also, overlapping UV's should be moved outside the 1:1 UV square when baking your normal map to avoid errors. To the left is one of my UV layouts, notice the large UV "chunks", giving as few seams as possible. The red area indicates the main UV square, the UV's outside of that square represent symmetrical areas of the model. They are offset by exactly 1.0, and since UV's tile, they can simply be left there on the exported model.
TIP: In 3ds max's UV Editor menu, go to "select" -> "select overlapped faces". This is a very quick way to see all of your UV's that are overlapping and need fixing.
There are many programs, and some excellent free ones, that can create normal maps from a high poly model. So I will not be walking through a step-by-step process. Some programs are as easy as loading in your low and high poly model and clicking a button to generate the normal map. Others, like 3ds max, offer a bit more control, in the form of a "cage" that surrounds your model, which you can tweak to fine tune your normal map.
TIP: In 3ds max, I recommend doing a few test runs when creating your normal map. Once you are happy with your settings, go into your render settings and turn on "supersampling". This will greatly increase render time, but will smooth out all the jagged edges and pixilation in your normal map, making it look cleaner when applied to your model. Conversely, turn off supersampling to speed up render time when doing test runs!
Once you've generated your normal map, it's time to bring it into Photoshop. You'll want to get the excellent and free NVIDIA Photoshop plugin, which can be downloaded from NVIDIA's website.
Apply your newly created normal map to your model, and have a look. More than likely you'll see a few spots on your model that don't look quite right, maybe there is a few holes, black spots, etc. Very rarely is your normal map perfect at this stage. So it's time to do some cleaning up in Photoshop. My most useful tools for cleaning up a normal map are the smudge tool and clone stamp tool. Use these tools to tidy things up, but before saving, you must run the NVIDIA filter first! Use these settings, this makes sure that the RGB channels add up to 1, which is necessary in a proper normal map.
You can also use the NVIDIA filter to overlay details that would be either too difficult or impossible to model conventionally. Any grayscale image will work, and you create it just like you would make a bump map: white is high and black is recessed.
For this example, I wanted to give my dwarf's wrist cuffs an engraved metal look, and it would have been time consuming if not impossible to model this detail. So, I found an image I liked, desasturated and inverted it, then ran the high-pass filter on it to even out the lighting. Then I played with the contrast to make it pop a little more. On the right you can see the progression of my overlay. On a new layer, once again run the NVIDA filter with these settings.
You can give the "scale" value any number you want, higher values will give more depth to the normal map. After running the filter, set the layer's blending mode to "overlay", then open up the levels menu by going to "adjustments" -> "levels". Set the output for the blue channel to 127 as shown here.
The picture below shows the affected portion of the normal map and the result on the model, where you can clearly see the engraving on the cuffs.
As you can see, the NVIDIA filter is extremely useful, and can be used for all sorts of things, so let your imagination run wild. In this untextured picture the NVIDIA filter was used to give the wizard deep wrinkles in the face, as well as cool looking embroidery on the robe. Just remember to run the NVIDIA filter with "normalize only" checked before saving out the final version of your normal map!
I hope you've enjoyed this series of character modeling articles, please send any questions / comments to mark@hyrumark.com. You can download a complete PDF version of this article, with full-size screen shots from here (1.8 MB in size)

No comments:

Post a Comment