flat/gourad shading question
For a project I have a terrain (height map), for which I preferably would only like to use 1 vertex per height point, but the problem is that I would like to have hard edges. If I use flat shading it looks good without any lights, but if I add lights it will light up the terrain on triangle basis, instead of per vertex, and this doesn't look good. If I use gourad shading however, I can't seem to get around making 3 vertices for each triangle, so that I can point the normals for each triangle outwards so I can the hard edges. But it seems a waste of vertices. Is there another way that i can achieve a lighting similar to gourad, have hard edges, and only use 1 vertex per height-point in my map?
Thanks a lot for any information!!
It's not clear what it is you mean by "have hard edges". Edges only matter in terms of lighting. Where do you want hard edges? And if you want hard edges across every edge, then this means you must use flat shading.
yes I mean they have to be flat looking... I'm going for terrain-look like simcity 2000, but then in 3d..
But I CAN get flat looking faces use gouraud shading, as long as I point all the normals of a face in the same outward direction. For example a standard cube has that. If I turn on gouraud shading it does better lighting because it interpolates colors/lighting between triangles, and flat shading doesn't seem to do that. you can clearly see that each triangle has 1 color, which is not the case with gouraud. So basically I do want gouraud shading, but I want to try to share vertices between triangles....
Have you tried fooling around with glShadeModel ?
Thanks for pointing that out! I was looking at it and found the following discussion, which seems to answer my question. Seems it is possible to calculate the face normals in a a fragment shader so you can ignore vertex normal (and thus save a lot of vertices) and do a custom flat shading