syr1111's picture

FSAA Causing Artifacting in LineStrip

I have an array of datapoints which I am trying to render as a fairly basic X-Y graph in in Ortho mode. In this case I have data that represents a sine wave as shown in my first attached image.

It all renders fine except that when I scale the graph more in the Y direction to make it taller, then I start getting some really ugly rendering artifacts. Basically random gaps start to form in my LineStrip. If I scale or translate at all in either X or Y then the gaps appear to randomly jump around to different locations in my data. The second attached picture shows an example of this.

The interesting thing is that I found out that if I turn off FSAA then all the artifacts go away. I am create a custom GLControl object as shown here:
public MyGLControl() : base(new OpenTK.Graphics.GraphicsMode(new OpenTK.Graphics.ColorFormat(32), 24, 0, 4, new OpenTK.Graphics.ColorFormat(32)))
And as shown this has the problem. If I change the 4 to a 0 to disable FSAA, then everything renders fine. If I set 2x, or 8x FSAA then it has problems just like 4x.

So I am wondering if anyone has experienced FSAA causing artifacts and how to possibly fix this. I would really like to keep it enabled as high-frequency line plots like I'm showing look terrible without it (moire, etc). Here is my actual plot rendering code. Any input would be very helpful. Thanks.

            GL.PushMatrix();
 
            // Adjust vertical scale so complete range of point values fits into a [0.0-1.0] local rendering area
            GL.Scale(1.0, 1.0 / maxValue, 1.0);
 
            GL.Color4(color);
 
            unsafe
            {
               GL.VertexPointer(2, VertexPointerType.Int, sizeof(Point), data);
               GL.DrawArrays(BeginMode.LineStrip, startIdx, endIdx - startIdx + 1);
            }
 
            GL.PopMatrix();
AttachmentSize
FSAA non-artifacting.jpg39.47 KB
FSAA artifacting.jpg75.41 KB

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
the Fiddler's picture

This looks like a driver bug. If possible, try testing your app on different hardware and/or updating your drivers.

What video card are you using?

syr1111's picture

I'm inclined to agree with you. It's been tried on several machines and only shows on some. It appears to be most pervasive with NVIDIA cards and in particular NVIDIA Quadro. Still, I know there are similar rendering issues with certain cards/drivers that can be avoided by tweaking the approach used in the code, and didn't know if someone might have a nice catch-all solution to this.

the Fiddler's picture

Many people recommend using textured triangles/quads for this kind of use instead of regular FSAA or primitive multisampling. Here is a very thorough comparison of FSAA vs textured primitive techniques. Granted, this is on older hardware but the concepts are still valid.

The basic idea is to replace the line-strip with a quad- or triangle-strip, enable alpha blending and apply a simple gradient texture. In general, this gives more convincing results than FSAA while being more reliable (it can be used even on GL1.1 hardware). The main drawback is that it may cause artifacts when lines overlap.

Edit: spelling.

syr1111's picture

Great thanks. I'll check it out.