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

Heighmap to Normalmap

This topic is 3454 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
Advertisement
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
begin
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);
normalize(normal);
end;

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!