Jump to content
  • Advertisement
Sign in to follow this  
david w

Heighmap to Normalmap

This topic is 3547 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've been trying to find some samples for generating a normal map from and existing height map, but I cant really find anything that explains the process or any easy to understand code snippets. So I would like it if someone could expalin or point me to a good link that is easy to understand how to do this. Thank you.

Share this post

Link to post
Share on other sites
I don't know if this can suit your needs, but I have a heightmap of which I need to calculate the vertex normals. I suppose the outcome IS a normal map after all..

The pseudo-code goes like this:

for y=0 to heightmap_cols-1 do
for x=0 to heightmap_rows-1 do
normal.x = heightmap[x-1,y] - heightmap[x+1,y];
normal.y = heightmap[x,y-1] - heightmap[x,y+1];
normal.z = (heightmap_cols/2) + (heightmap_rows/2);

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • 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!