Tutorial: Blender and Normal Maps
By olivS, mardi 23 août 2005 à 14:15 :: Blender tutorials :: #43 :: rss :: PDF
Bump mapping is a well known but old technique for faking 3d reliefs. The relief information is stored in a gray-scale image. But a new and very popular method in the 3D game industry offers to store the relief information in a RGB image, increasing the precision and, obviously, the realism of fake reliefs on your 3D models: Normal mapping. This short tutorial is about showing you how to build your own Normal maps without expensive tools, and of course how to use them.

File(s) Attached :
- No file available for download
:: Creating Normal maps ::
For this part, you will need the following:
- a 3D model from which the relief information will be calculated
- a camera, oriented toward the model, and rendering in Ortho mode
- a material with multiple Blend textures that will provide the color information for the Normal Map
Of course, alternatively, you could download the following file, make your experimentations with it, or simply Append (SHIFT+F1) the material from it, in order to reuse in your own Normal maps generation.
The 3D model
OK, we will get busy start Blender or start a new scene (CTRL+X), and erase (X key) the default cube. Toggle into the Top view (NUM-7 key). Press the SPACE key in order to get the menu: SPACE > Add > Mesh > Monkey. Without exiting the Edit mode, press the Set Smooth button of the Link and Materials tab in the Editing menu (F9). Now add a Plane: SPACE > Add > Mesh > Plane. Use the S key to scale it a bit (Size X = SizeY = SizeZ = 3.0 for example) and in Front (NUM-1) or Side (NUM-3) view, move it (G key) downward by one constrained unit (CTRL key held while grabbing the plane). You can now exit the Edit mode (TAB key).

- Hint:
You can enhance the look of your Normal map if you SubSurf (or at least Set Smooth) your model before rendering it. The only issue you will face is that the plane will get rounded on the edges. But you can easily overcome it by appling Crease to the Plane to get back its square shape: select the plane vertice, press SHIFT+E, and drag your mouse until the Crease value in the 3DWindow header reads +1, and then LMB (or press ENTER)
The camera
Select the default Camera, and press ALT+G and ALT+R to clear its location and rotation, respectively; then, in front view or side view (resp. NUM-1 or NUM-3 keys), move (G key) the camera to the next major grid intersection point above the monkey mesh. Toggle to the Editing menu (F9) and in the Camera tab, press the Ortho button.

- Hint: A good option would be to play with the Scale property of the Ortho Camera so that the 3D object occupies most of the Camera view and you eventually get the most details possible for the least resolution at render-time.
The material
And now, the most interesting part! With your reference 3D model selected, go in the Shading menu (F5), select the Material buttons. In the Material tab, press the Add New button. Don't change anything to the defautl material, except two things:
- Change the Col to black: R = 0.0, G = 0.0 and B = 0.0
- Turn on the Shadeless button

Now, toggle to the Texture buttons (F6), and in the Texture tab, press the Add New button. As Texture Type, choose Blend and keep the default Lin option in the Blend tab.

Toggle back to the Material buttons. In the Texture tab, select the first texture, and then in the Map Input tab, press the Nor button. Still in the Texture tab, use the arrow up icon in order to copy the current texture channel into memory. Select the second texture channel, and use the arrow down icon to paste the texture information. Paste it again a third time into the third texture channel.
We will now map the Blend of the first texture channel to the X axis, and change its color to Red:
- In the Map Input tab, select X button in the first line of coordinates, and select the blank box of the second and third lines of coordinates.
- In the Map To tab, set to Red the color of the Blend using the three sliders: R = 1.0, G = 0.0 and B = 0.0. Make sure that the texture mapping is set to Mix.

For the second texture channel, we will do the same for the Y axis with a Green color:
- In the Map Input tab, select Y button in the first line of coordinates, and select the blank box of the second and third lines of coordinates.
- In the Map To tab, set to Green the color of the Blend using the three sliders: R = 0.0, G = 1.0 and B = 0.0. Make sure that the texture mapping is set to Add.

Finally, we will map the Blend of the third texture channel to the Z axis, and change its color to Blue:
- In the Map Input tab, select Z button in the first line of coordinates, and select the blank box of the second and third lines of coordinates.
- In the Map To tab, set to Blue the color of the Blend using the three sliders: R = 0.0, G = 0.0 and B = 1.0. Make sure that the texture mapping is set to Add.

That's it! Now hit the F12 key to render and see your brand new Normal map, ready for use!

- Hint: make sure to save the Normal Map in a convenient format (PNG, JPEG or whatever) but also the Blend file you used to build the Normal Map; you certainly would like to re-use it, or make slight modifications in near future!
--
:: Using Normal maps ::
Using a Normal map does not differ from using any other texture Image. Select the object that will receive the Normal map, if it doesn't have a Material yet, give him one first. Then go to the Texture buttons (F6), select a free Texture slot in the Texture pannel, and click on the Add New button to add a new texture. Please select Image in the Texture Type menu. In the Image panel, press the Load Image button and browse up to the location of your Normal Map. Once selected, turn 'on' the Normal Map button and toggle back into the Material buttons. Finally, in the Map To tab, press the Nor button. Optionally, you can play with the Nor slider, too.

Of course, you will have, in the Map Input tab, to choose the mapping type of the Normal map between Flat, Cube, Cylinder and Sphere. You can also choose to UV map the Normal map, if a better control on the mapping is needed.


--
:: And what about the most complex Normal maps to be UV mapped? ::
Well, let's face it. There are some high-end softwares around that work in 2.5D; the most famous is ZBrush, but it's a proprietary software, you need to buy a license, and it's only available for Windows and Macintosh users. The demo on the website are breath-taking about the amount of details that can be achieved with a regular high poly model. But we will forget about it and go the cheaper way. There's also an Open Source project for modeling the same way than ZBrush: SharpConstruct. Even if the project is in a early stage, it is very useable and gives very interesting results, and there are fair chances its tool will be integrated to Blender, thanks to 2006 Google Summer of Code.
Here are some solution I read about, but not necessarily tried myself; if you have more information, please feel free to post comments, at the bottom of the page!
There are various workflows based on building Normal maps on the basis of two models: one high poly, and the second low poly. As much detail as possible is modeled on the high poly model; the low poly model is unwrapped. The high poly and the low poly models are both attributed to some sort of engine that will calculate (and store in the UV map of the low poly) the geometric differences between the high and the low poly, and translate these differences into a Normal map that will be sticked into the UV map of the low poly model. Here are three tools doing such works:
- Let me introduce you to NVIDIA Melody, for example; the good new is that this tool will cost you nothing, but unfortunately, it is available only for Windows users.
- On the Internet lurks an interesting project, primarily intended for exporting Blender models to the Ogre game engine, that uses ATI's NormalMapper tool to generate and export the Normal maps. Unfortunately, it's still for Windows and Macintosh users (ATI's tool, I mean, the Blender exporter is obviously cross-platform).
- You can also pay attention to the DENormGen tool. Like the two previous tools, it builds a normal map for a low poly model according to the relief information given by the same but high poly model. It's freely available for all users, but I never tried it at this time, so I can't review it for you.
But the down-side with these three solutions is that you have to do twice as much work: create a low and also a high poly model. Perhaps you don't have the patience for this. So if you want a quick solution that is sufficient for most common cases, then jump to the next part of this tutorial! 
--
:: Tutorial for building UV Normal maps ::
Let's start with a brand new Blender scene: CTRL+X to get rid of the all scene, and get back to the default scene. Part the 3D screen in two halves; in the second one, hit SHIFT + F10 to display the UV/Image Editor. In the first one, select the Cube and enter the Edit mode (TAB key). Select edges one by one, and Mark Seams (CTRL + E) accordingly to the following picture:

Make sure you have all the vertice selected and enter the UV Face Select Mode. With your mouse cursor located in the UV/Image Editor window, press the E key to start the LSCM unwrap; the unwrapped cube appears in the UV/Image editor, but with a wrong orientation. Select all the vertices (B key) in the UV/Image Editor and then rotate them (R key) until they have a proper orientation.


- Hint:
It is also possible to activate LSCM unwrap with your mouse cursor in the 3DWindow, by first going to Object mode (TAB key), press F key to enter UV Face select mode, and then press U key.
Now check the UV/Image Editor menu, and search for the UVs entry. Click on it, and choose the Save UV Face Layout entry. Choose the path you want to store the UV layout to, and press the EXPORT button.

The cube layout you obtain in the specified path has the name Cube.tga, and should look like the following picture if viewed in a picture browser:

Save your blender file, I will get back to it soon.
For the moment, re-open the normal-monkey.blend file. Select the "monkey-on-plane" object, and delete it using the X key. Check the menu of the 3D window, and look for the View entry. Click on it and then choose Background image. A flying window appear, inviting you to Use Background Image. Press the button, and then click on the small Image Browser icon in order to choose the Cube.tga you saved earlier.

It appears in the background of the 3D window. Now, insert a Suzanne head (SPACE > Add > Mesh > Monkey) in the center of each face of the virtual unwrap. Move (G key) and resize (S key) them as needed. Also add a plane (SPACE > Add > Mesh > Plane) that you resize accordingly to the size of the background image.

Select the plane and all the monkey heads, and Join them into a single mesh (CTRL + J). If you used the normal-monkey.blend file as a basis, go to the Shading buttons (F5) and give it the pre-existing multicolored material. Also change the Ortho camera Scale to 14. Press the render button F12 and get your UV normal map ready to use: press F3 to save the normal map with an explicit file name like monkey-cube-normal.png, for example.

Optionally, you can use a tool such as Gimp to make sure that the new normal map fits perfectly the UV layout, or alternatively, tweak a little the UV itself in the UV/Image Editor.
Now, go back to the file you previously saved. Select the Cube you unwrapped. In the Texture buttons, add a new Image texture as if it was a regular image: choose the new normal map, and press the Normal Map button, as explained previously in this tutorial. Now turn to the Material buttons, and in the Map Input tab, select UV: the picture will be wrapped according to the LSCM unwrap. In the Map To tab, deselect the Col button and select the Nor button.

This method is particularly useful if you want to add details such as veins, scars and wrinkles on human skins, folds on clothes, holes and details on a wall, etc. Now you can see that, given your knowledge of how to UV unwrap your models, you can build interesting normal maps for them without resorting to expensive or difficult tools.








Comments
1. On jeudi 25 août 2005 à 09:55, by olivS
2. On vendredi 14 octobre 2005 à 17:03, by Lloyd
3. On mercredi 17 mai 2006 à 08:51, by Kaolin Fire
4. On mercredi 17 mai 2006 à 08:52, by Kaolin Fire
5. On mercredi 17 mai 2006 à 09:44, by olivS
6. On lundi 22 mai 2006 à 09:22, by kevin
7. On lundi 5 juin 2006 à 00:34, by yogyog
8. On samedi 7 juin 2008 à 14:39, by KAASKOP
9. On lundi 16 juin 2008 à 10:37, by sushi
10. On mardi 21 octobre 2008 à 18:46, by meesh
11. On jeudi 13 novembre 2008 à 00:13, by art4med
12. On lundi 6 avril 2009 à 14:34, by matelix
13. On mardi 5 mai 2009 à 16:58, by DarkCoiote
14. On mercredi 6 mai 2009 à 09:14, by Krang
Add a comment