Normal map space used by Panda3D shaders

I’m not getting good results when using normal maps baked with tangent space. Is this the kind of normal map used by the auto shaders by default or do we have explicitly say we need to use this for the shaders to work?

Most likely you have to add tangent and binormals. I think egg-trans.exe utility can do the trick.

Yes i already did that. Chicken egg exporter uses this command to generate tangent and binormals:
“egg-trans -tbn UVTex -oElowan.egg Elowan.egg”

So the info is there.

Normal maps baked with tangent space don’t work very well while normal maps baked with object space work perfectly.

I don’t think the problem is the baking of the normal map. I used Blender 2.46RC3 and xNormal separately and both output the same normal map and i have similar problems. The dark areas appear to be random without accounting for the light direction.

I’ve been using Chicken to create normal maps, and whilst it works in most places I find it goes wrong at the seams in the uv map - there is obviously a difference between how blender calculates its tangent and bi-normal and how panda does, at least at the seams.

(There is a solution to this that can go into the chicken exporter, it requires some additions to blender however, so it could be quite a wait before this happens. An alternative solution would be to write an object space to tangent space converter that uses pandas technique, but for now I’m ignoring the graphical glitches in the hope that the correct solution comes together and I don’t have to knock that up.)

That doesn’t sound like your problem however - I’m using tangent space normal maps from Blender/Chicken and can confirm that they do work, despite the problems. An obvious check is to make sure your normals in blender are all calculated on the outside - making that mistake can look quite strange. (Alt-n with all faces selected in blender fixes that.) As for normals created in object space, there is no way that should work with the auto shaders in panda. If your creating your own shaders or using someone elses there is no reason for that to not be what they are expecting of course.

Have you tried using xnormal to bake normals:
xnormal.net/

And then compare it with a Blender normal map? If it works with this and doesn’t work with Blender 2.46 then the problem must be with Blender.

The technique i’m using now is to use xNormals to bake an height map and then the Gimp normal filter to convert it to a normal map. It works all the time.

PS: I couldn’t bake height maps with Blender very well. The output was getting stairs of gray colors. Nothing i tried could change this.

Zingbat, can you post sshots along with uv layout and normal map? I don’t use blender, but I still might be able to recognize the problem.

Have you tried viewing the normal map in real time in anything other than panda?

Also… when you are converting a heightmap to a normal map you lose a lot of data… best if you can avoid doing that.

I have already modified the demo, but i can try doing it again later. Right now i’m working on other things.

“Also… when you are converting a heightmap to a normal map you lose a lot of data… best if you can avoid doing that.”

The heightmap i use has a greater resolution, usually 2048x2048. I then use the Gimp filter and shrink the image. Didn’t had much problems with this that i noticed.

It doesn’t calculate it the same way, but in some cases it might not matter. It is a pretty common misconception that they are the same though, I’ve tried to explain why it isn’t to a lot of people before and while they’ll usually end up understanding techinically why they are different they haven’t quite understood what kind of a difference it makes visually. So I did a quick test/sanity check of a normal map and height map projected on to a flat poly.

The geometry source
Normal map texture
Height map
Height to normal (generated with nvidia’s photoshop plugin, filter type: 3x3)
Normal map applied
Height to normal applied (normal map multiplied 4x, was too faded at 1x)

So, to me there is a pretty big difference… and this is just baking to a flat surface, more weird things happen when baking to angled surfaces.

Tanks for the images. It shows some nasty effects that can plague heightmaps. I don’t get so much noise in my height maps when i use xNormal however. It should be a lot better if you can work with a 16-bit grayscale image but i haven’t looked much into this alternative yet. Using heightmaps has some advantages, like for example being able to edit and combine them easily with an image editor.