Archived

This topic is now archived and is closed to further replies.

Blaster

Generated normals of heightmap

Recommended Posts

I am working on a terrain renderer, because nobody has done that before and I want to be the first I am happy with what I have so far, except my normal generation code. I do 2 things. First I generate the normals orthogonal to each triangle. Here is a screen shot of the result http://www.blastersoft.com/OrthoNormals.jpg . As you can see, it''s half smooth. One of the two triangles in each quad is darker than it should be. I can''t figure out why. The second thing I do is smooth the normals. That is, I replace the normals at each position with the average of all the normals at that position. The result is a lot better, but still I have the same problem, only smoothed. Here is a screen shot http://www.blastersoft.com/Smoothed.jpg One thing I noticed is that the second triangle is not darker for triangles almost facing the directional light. When I move my directional light, I can see a patch of perfectly lit triangles with no darkers parts. Can you help me out from the screen shots I provided?

Share this post


Link to post
Share on other sites
Yes, my normals are normalized.
But anyway, I''m dumb... I found out what the problem was.

My terrain is mirrored (the Y of the heightmap image is the same as the Z or the terrain). I was averaging the normals of the wrong vertex. (I do one average for each quad).

Thank you.

Share this post


Link to post
Share on other sites