Shading and lighting

The attached jpg file is drawn as a series of GL_QUADS. Note how the shades of red/orange/yellow in the center merge together smoothly, but the yellow/blue/black on the outside have very sharp edges that seem to be highlighted. My intent is to make the yellow/blue/black merge as smoothly as the red/orange/yellow.

I have tried numerous settings of shading and lighting without success. It’s almost as if the settings have no effect whatsoever, so maybe I am not initializing something correctly?

This is a normal problem with rendering triangles. Look at the steps on the right side of your image. Start at the yellow step with blue on it sitting on it. That square sitting on the step is made up of two triangles. The upper left one has a yellow-orange bottom left vertex, a yellow top-left vertex, and a blue top-right vertex. The other triangle has similar coloring, but it’s flipped across the hypotenuse. Because of this, you’re getting a lot of blue in the middle of the triangle.

If you triangulated the squared the opposite way, it would look correct. That’s why the image looks fine in the top left corner. You see, it’s not a problem with yellows to blues (although it’s more apparent there). It’s a triangulation issue. You can either triangulate differently on the right side or increase the tessellation on your whole mesh.

Another option is to interpolate the data and compute your color in the fragment shader. That’s probably the most robust fix if you have access to shaders.

Yet another option might be to write the colours into a texture and use linear filtering to zoom it up to a high magnification. Again, if you have shaders, you could use a blur filter to get even smoother shading. If not you could do your own blur in software to bring it up to something like 32x32, then let linear interpolation do the rest.

One texel would correspond to one quad, so you’d have an 8x8 texture. At this kind of resolution you could update it dynamically each frame if need be and you’d possibly get better performance than drawing multiple quads.

Yeah, if you don’t have access to shaders, putting into a texture and drawing it out as one quad probably would be better.