Generated normals of heightmap

Started by
1 comment, last by Blaster 22 years, 4 months ago
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?
Advertisement
Have you normalized your normals? Maybe it can cause such a problem. I''m not sure though.
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.

This topic is closed to new replies.

Advertisement