tags:

views:

43

answers:

2

Cube with obvious triangle lines

It's a cube, looking from the corner at two sides. You can pretty easily tell where the four triangles that make up the two sides are. I am drawing it with vertex, color, and index arrays.

What causes the obvious line and how might I be able to avoid it?

+1  A: 

I believe it has to do with the color interpolation used to shade each triangle. The triangle interpolates the color between its 3 points, but has no knowledge of the 4th point. Therefore, there's no reason to assume that the color interpolation will be smooth across the triangle boundary. You can guarantee that the line itself will be colored identically, since pixels on the triangle boundary are only dependant on the 2 points, which will be the same.

So, what you're seeing is a change of the gradient around that point. When you have suddenly changing gradients, the human visual system accentuates the line, resulting in what is called a Mach Band.

The only good way to get rid of the band is to make the gradient change less severe; typically, by increasing tesselation. Use more triangles! The more triangles, the more color-sampling, the less noticable the mach bands.

Nick Gebbie
"Use more triangles!" This is not a nice solution. You can get perfect result with textures/fragment shaders without using extra triangles.
SigTerm
Is true. Texturing is likely the easiest solution. I believe that the shader based solution was a bit beyond the scope of the question, so I omitted it for simplicity.
Nick Gebbie
+3  A: 
SigTerm
Ah. I kinda figured this would be the case but I was hoping there would be an easier solution, like "use vertex normals!" - but of course those only affect lighting... I suppose I shall delve into the realm of texturing then! Thanks. :)
Ricket