Archived

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

GimpBoy

Question about Gouraud shading.

Recommended Posts

I'm new to OpenGL and I've run into a little problem regarding this project that I'm working on. I have a large array of vectors from which I render a landscape. In order to get this landscape to look nice, I want to apply lighting to the scene, and so far I've been successful. I calculate normals for every polygon in the scene and create a diffuse and ambient light source. The problem is that each polygon gets shaded with one shade of color, rather than follow the gouraud shading approach which blends the colors between vertices. How is gouraud shading achieved? So far all the turorials I've seen specify normals for a 3 or more vertex polygon, but the end result just looks so hideous!! Here's any example of my problem: http://members.shaw.ca/GimpBoy/eww.JPG How would I go about smoothing this out and making it look good? I've already been able to set the color of the vertices using glColor3f, but it seems like when glEnable(GL_LIGHTING) is turned on it overrides the color shading that I give the vertiices. Maybe combining this with the lighting would work, but I'm not sure how. Any help or advice is welcomed. Thanks. [edited by - GimpBoy on March 28, 2004 2:53:46 AM]

Share this post


Link to post
Share on other sites
for each vertex in the height feild (each unique vertex I mean) average the normals of each triangle connected to that vertex. Then, whenever rendering that vertex, use that average normal. Currently, each vertex of each triangle you draw shares the same normal will all other vertices of the triangle. hence it''s flat shaded

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
I assume you''ve enabled smooth shading?

glShadeModel (GL_SMOOTH);

Share this post


Link to post
Share on other sites