Jump to content
  • Advertisement


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


Generated normals of heightmap

This topic is 6062 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!