Sign in to follow this  
Giedrius

Making my heightmap look more smooth

Recommended Posts

Giedrius    164
First of all, 2 screenshots of my heightmap: Both images are the same, but one is drawn filled, other wireframed. I believe that the problem is with the lighting. It seems that the mesh of the heightmap is quite smooth from the wireframed picture. I think that the normal calculation is correct. I am using gl lights for the lighting.

Share this post


Link to post
Share on other sites
HansDampf    106
The problem you have has nothing to do with the smoothness of your height-map. It's the lighting model, which is the problem. Right now you use flat shading, meaning every triangle get's shaded according to it's normal vector. What you need is phong shading, where the normals are interpolated along the triangle, starting from the mean normal at the each point, where three/four triangles meet. Okay, I guess that's too much theory.

Simply go to http://www.xmission.com/~nate/tutors.html and search for the files glm.h and glm.c in the tutorial zip. There you can find different drawing modes (look for GLM_FLAT and GLM_SMOOTH).

Hope that helps.

Share this post


Link to post
Share on other sites
Giedrius    164
Thanks for your help, I have solved my problem. But I don't think that my solution is most efficient. First I used a very slow solution. My height map (64x64) has 24576 vertices and 8192 triangles. With the first solution it took around 3-4 minutes to calculate the normals for each vertex on a P4 3.2GHz processor. Then I scrapped it all and remade it, now it loads instantly, but it's still not the optimal solution. For a better one I should change the way my meshes are stored, as it is just an array of vertices with some additional info, like color and tex coords. It takes more memory space than it should.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this