View Full Version : Smooth shading not working correctly
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?
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.
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.
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.
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.
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.