Generating Normal maps tangent space directly in Blender

Hi, i’m Zelouille, member of the french community Blender Clan.
Please excuse my bad english writing. But be sure i will try to do my best :).
French people may want to read the french post.

After some headaches, i think i’ve succeed to generate Normal maps Tangent Space in Blender.
This method needs some bakes and much nodes.

Due to the complexity of nodes, I’ve decided to do a .blend file dedicated to this task. You just have to append your mesh, follow the directives and you shoud get your Nmap Tangent space.

So, there is the .blend file :
http://imghost.warrenberberd.org/2007/10/25/Thumbs/38ff641693b013425b709d63b3f9275a-M.blend
v.2007.10.24

It contains the directives in both English and French. Just select your language in the Text files.

Theory

Due to a bad level at mathematics it’s hard to me to explain how it works, but it’s quite clear in my head.

The hi-res map (nmap_pix) is multiplied by a matrix (U,V,Z) wich correspond to the rotation of each face.

This matrix is composed by 3 maps, but one is calculated by the others. nmap_v correspond to the V axis, nmap_vert to the Z axis.

Z axis (nmap_vert) represent the normals per face.

V axis (nmap_v) represent the Y axis of the texture uvmapped.
To get this map, i just used a flat coloured map (RBG = 0.5 ; 1.0 ; 0.5) applied in nmap_TS mode, and bake the normals. It return the Y axis for each face in the global space (camera space).

A screen of the nodes tree in an older version (which needed one bake more) :
http://imghost.warrenberberd.org/2007/10/18/Thumbs/ffd26254017d6396140878ac3ce9171a-S.gif

How to use it

All the three maps you’ll have to create
must be the same size.

1. Importation of your own mesh in this .blend file.
File > Append or Link.
Careful, choose the mesh, not the object.
Select the “Cube” object.
In panel Editing > Link and Materials,
select your mesh in place of “ME:Cube”.
http://imghost.warrenberberd.org/2007/10/23/f30b36c2a7f5c98b4eca66e57316c24c.gif
Go to the UV Face Select mode.
Multires/Level at 1 until the end.

2. Baking of High-Res map “nmap_pix” :
Set the multires_render at maximum.
http://imghost.warrenberberd.org/2007/10/23/772c4ca6c3c685575a76a5c564285a86.gif
In UV window, create a new image “nmap_pix”.
Bake the normals.

3. Baking of Low-Res map “nmap_vert” :
Set the multires_render at level 1.
http://imghost.warrenberberd.org/2007/10/23/dece2a5a4ec6daadca048650026686f8.gif
In UV window, create a new image “nmap_vert”.
Bake the normals.

4. If your mesh is “Set Solid” (goto step 5 if it’s smooth) :
In panel Editing > Modifiers, enable the Edge Split modifier
during rendering (first button next to the modifier’s name).
http://imghost.warrenberberd.org/2007/10/23/a1dc152796e7dbb0e3bbf00e6f779a7d.gif

5_ Baking of the “nmap_V” :
In panel Material > Texture, enable the “V” texture.
http://imghost.warrenberberd.org/2007/10/23/e6aab41fe8c7d7031a1feae671a9b588.gif
In UV window, create a new image “nmap_V”.
Bake the normals.

6. Settings of the Nodes :
In Node Editor window, load the maps in this order, up to down :
nmap_pix
nmap_V
nmap_vert
Set the file path in the File Output node.

7. Check your folder :slight_smile:


The job of my .blend file ends here.


8. Set up the texture onto your object
Create a new texture,
load your normal map tangent space.
In the Shading > Texture buttons > Map Image panel,
enable the “Normal Map” button.
http://imghost.warrenberberd.org/2007/10/27/53f6de00fa1fbb438241b24733bf92ae.gif

In the Material buttons > Shaders panel,
enable the Nmap TS button.
http://imghost.warrenberberd.org/2007/10/27/f157307e39573b7f3cbf369d434e11b2.gif

In the Map To panel
enable the Nor button, and set the nor slider to 1.00
http://imghost.warrenberberd.org/2007/10/27/adf96fffa794a65e8e548df02df62282.gif


I will edit this posts if you need more explanations.


As you see it’s a bit long, but, when you know good the “how to” it becomes quite fast.
You don’t have to rename the baked maps or save them (even it is a bit hazardous… Blender seems to forget unsaved maps after a while) if you want to go faster.

Hmmmm seems very clever!
I don’t know much about them so this is the place to learn !
Well done.

I had tested it out, and i will further testing :slight_smile: It works width smooth faces too?
Btw what is the difference the pixel and the vertex baking result? I changed the multires levels but the result will be the same.

  • Yes, it works with smooth faces too. You have to not enable the modifier during rendering.

  • It seems you confuse the “level” variable and the “render” variable. Mutlires “Level” needs to stay at 1 until the end (in order to not have the “no image to bake” message).
    It is the Multires “Render” you have to modify in order to bake the low resolution, or the high resolution mesh.
    Pixel baking > high res.
    Vertex baking > low res.

I will add some images to the first post.

Awsome! I cant belive it :eek::eek::eek: it is woks perfectly! Thank you Zelouille !
my test:
http://img204.imageshack.us/img204/1730/tangentspaceinblendertl4.th.jpg

Hi Zelouille!! Is it possible to make Displacement maps out of this technique??

I LOVE YOU! :eek: :smiley:

yes! finally! whooh

you could convert the normal to a displacement in crazybump. thanks for the tut. ive been using the camera space normal maps baked from high poly which is aparently not as good

thats some seriusly amazing node setup! thanks

Crazybump is not GNU, and I think the beta version is restricted to 800x600 output.

Hey great :slight_smile: Feel free to post the result on your low poly character.:yes:

I think you save each map after baking them.
You can get a more neutral background (RGB : 0.5 ; 0.5 ; 1) in place of your clear blue if you save the hi_res map in an Alpha friendly type file (.tga for exemple).
You can get it too if you don’t save the maps in a file, just use them “on the fly”.

No, sorry. And i think you’ll never can.
But i’ll think it over…

Me too :stuck_out_tongue:

Hey… is it possible for someone to make a NODE of that whole node setup? I didn’t try it yet, but thanks for the innovation =)!

hmm… i think it could be grouped, but indeed, having savable node group presets would be awesome!

well i wasent sure what it was you wanted. but i know that you can take a normal map in crazybump and convert it to a displacement map

Thank you Zelouille i corrected it as you mentioned.

http://img152.imageshack.us/img152/9194/tangentspace0001sw4.th.jpg

and the low poly character result rendered it in blender (use NMap Ts, Nor (negative) and Normal Map buttons)

http://img505.imageshack.us/img505/6899/lowpolyuq8.th.jpg

Well, you can’t make groups into other groups. So, the trick is to to all ungroup (Alt G) then group all the nodes.

If i make that, it will become so boring to modify if i need it.

Also, nodes don’t make all. If you want to import the all method, you will need to append the material too (mat_uv_baker).

In sum, i think it’s more simple to append your mesh in my .blend file.

Great, the generated map seems to work fine.
Did you put the “Nor” cursor to 1.00 on the “Map To” panel ?

it shouldn’t be too difficult to make a hard-code of it… :smiley:

S.

I used Crazybump to generate maps at a res of 2048x2048 just fine. It not being GNU has nothing to do with nothing.

Great method Zelouille, I had a feeling it was possible to do it with nodes.

[quote= Zelouille

Great, the generated map seems to work fine.
Did you put the “Nor” cursor to 1.00 on the “Map To” panel ?[/quote]

yes im use 1.00 for Nor value slider at “Map To” panel

Tres bien fait, merci beaucoups! Would it be possible for this to be done through a Python script? Then the whole process could be automated?