GL_SMOOTH artefacts

Here I am again…

It’s been a long time since I posted one of my problems… Well,let’s go…

I am working on a Computational Fluids Dynamics post-processor.

I am trying to visualize data on the grid by assigning one color per vertex and then render the quads. Of course I set the ShadeModel to GL_SMOOTH.

Everything works perfectly except for one thing that is totally OpenGL-Related.

When you draw a quad (or the two triangles that constitute this quad) with a different color for each vertex, you always have a problem on one of the diagonals (the one that joins the two triangles). What I mean is that you can actually SEE the diagonal !

It is not difficult to guess that this happens because of OpenGL interpolation method and I won’t blame it. The thing is, I would like to know if anyone has got an idea to prevent things like that from happening.

Well, the obvious idea is to tesselate so that the colors for each triangle are so close that you can not notice the artefact but when you already have 1/2million cells or more, you really want to avoid adding more things to display !

Hope someone has got an idea !

Regards.

Eric

are you drawing GL_QUADS or GL_TRIANGLES? (or strips?)

i’ve noticed varying behavior with texturing on quads and triangles with some drivers (other drivers convert to triangles and then texture so you get the same results), but i haven’t played much with GL_SMOOTH.

on the early Apple OpenGL drivers, if you drew a textured GL_QUAD with one vertex had a distorted texture coordinate, the quad would be drawn with the texturing smoothly interpolating across the quad. in later versions, the interpolation was no longer smooth, and the texture would stretch only on one side of the triangular seam. i’ve noticed the triangular behavior on my geForce as well (using detonator2 drivers on win2k).

sorry i’m not any help. all i’m trying to say is that it seems this behavior can vary.

Hi again !

Basically I have tried with various primitives (GL_QUADS, GL_TRIANGLES, GL_TRIANGLE_STRIP) on a very simple test case (drawing a quad with vertices having color (0.3,0.3,0.3),(0.5,0.5,0.5),(0.7,0.7,0.7),(0.9,0.9,0.9). No matter which primitive I choose, I always see the diagonal !

I am using an ELSA Erazor X2 along with Detonator 5.32 for NT 4.0.

I do not think there is a solution (except creating a texture that I would fill myself pixel per pixel but I can not do that with the number of quads I have !) but if someone has got an idea…

Regards.

Eric

What do you mean by “see the diagonal”? Can you post a screenshot?

The reason for the visual artifact is that the color values on the quad are not planar in the RGB color space.
That means starting at two edges, bilinearly interpolating the color values you would not reach the color value on the fourth vertex.
As the basic primitive in hardware rendering is a triangle the quad has to be split diagonally. The direction in which this occurs is not defined in the OpenGL specs, as far as I remember. So there might be implementations in which the image of quads vary.

My 2c:
A possible solution which reduces the effect would be to split the quadrilaterals into triangles based on the color value difference of diagonally opposite vertices.
Split between the lower difference and you crack the quad into two triangles which represent the geometry in the color space more naturally.
However, the effect of seeing the banding is also induced by the human eye increasing the contrast to enhance the perception of borders.