PDA

View Full Version : Smooth shading not working correctly



11-02-2002, 02:15 AM
Hi there seems to be a problem with the smoothshading when you are using lots of vertices on a polygon. I have a circle and all the vertices on the left are one color and the ones on the right are another because I want a smoothing across the circle. It looks like openGl interoplates a line from that starting point to every other vertex, because all lines going to the starting vertex interpolate correctly. However it makes solid lines to the top and bottom where the colors change so it looks like a pack man, the pack man part is solid with some smooth shading going on in it;s mouth. How can I fix this?

mm_freak
11-02-2002, 10:26 AM
I'm a beginner as well, but why would you draw a circle as a polygon? I would recommend you to draw it as a single textured square and calculate the shading yourself, then use it as an RGBA (partially transparent) texture. This would greatly improve performance and is much easier to do.

11-02-2002, 04:55 PM
is a shape textured on a plane faster, then just drawing that shape with vertices? I didn't know that. It still wouldn't be easier for me as I don't know how to load a targa.

However this is for a school project. It is implementing very simple 2d shadowing. I have a light that looks at all the vertices in the scene, and colors them "lit" based on if the light ray reached that vertex. That's all working correctly, but when I render the sphere say with 1/3 lit and 2/3 unlit, it doesn't smooth shade properly. I can't use a texture because there is animation going on and the way the objects are "lit" is changing at any given time.

11-02-2002, 05:09 PM
sorry I read you wrong, I thought you were talking about loading a texture. Your idea sounds good but I don't know how to do all that. I can see how to interpolate from one vertex to the rest or scanline by scanline, but how do you make it so every possible line from any two points on the polygon is interpolated correctly? Is it a n squared algorithm where every pixel is based on an intensity from every line that runs through that point? That seems like a lot of work.

jmg
11-02-2002, 05:41 PM
Stumped, for now, try using triangles rather than multi-vertex polygons. For a circle, try GL_TRIANGLE_FAN.

When using GL_POLYGON, note that the poly you specify must not intersect itself and also must be convex. If you break either of these rules, the results are unpredictable.

---j