PDA

View Full Version : Multisampled FBO => flimmering artifacts on ATI



Nighthawk
01-28-2009, 06:11 AM
Hi,

i render my scene to FBO1 with multisampled renderbuffers, blit FBO1 to FBO2(with GL_TEXTURE_2D as storage) to downsample, and finally render a fullscreen quad to the framebuffer with FBO2's texture.

This works nicely on Nvidia 8800Gt. On Ati X3850, it works basically too, but i get random white flimmering pixels at some multisampled edges.

As long as long as the objects remain static, the white pixels stay at the same position. When i change the modelview slighty, they appear at other random locations, but only at the multisampled regions.

Here an image of some frames with slightly changed positions:
http://img3.imagebanana.com/view/rm8m4612/artifacts.png

My implementation is based on this:
http://www.codermind.com/answers/How-do-I-render-with-HDR-and-antialiasing-at-the-same-time.html

- I tried Catalyst 8.8 and 8.12 and a few driver settings(catalyst ai etc), but nothing changed.
- Tried 16bit-float and 8bit backbuffers => no change
- Tried a different X3850, behaves the same
- When i do glReadpixels of FBO2 after blitting, i see the artifacts already
- When i set numSamples to 0 when creating the renderBuffers of FBO1, everything is ok(but no smoothing then of course)

What might be the cause?
Any idea for a solution/workaround?

Nighthawk
01-28-2009, 08:51 AM
Found a solution: Enabling "Adaptive Anti-Aliasing" in the driver settings seems to fix the white flickering artifacts(i have not verfied yet that it really does in all cases).

It's normally meant to fix aliasing in alpha-test textures like fences in games. I have alpha-blended-textures, but i don't understand why i need to enabled it though...

Anyhow, can this option be set via OpenGL?

dorbie
01-28-2009, 09:52 AM
The adaptive AA is just hiding the problem by diminishing the contribution from aberrant sub-samples. This looks like a backface vs. frontface zfighting artifact at the silhouette where they can become arbitrarily close; if you can, enable backface culling.

It could also be z invariance if you're using multiple passes but that's generally less of an issue on modern hardware.

Nighthawk
01-28-2009, 02:42 PM
Thanks for your input, dorbie. I checked the points you mentioned:
- It's 1 pass only
- Culling is on
So i don't think that's the problem directly.

But while checking, i took a closer look at the scene rendering:
- With all simple shaders(decal only, no lighting) there are no artifacts visible
- If i use a very simple shader pair to show the "vertex.normal.xyz" as "result.color.rgb", i see flimmering pixels as black holes.
(Came up with that idea after pointless hours of debugging my shaders :p They produce white pixels because of those normals)
- With that adaptive AA the holes are also closed when rendering the vertex.normal

The whole thing looks like a zfighting artifact, you are right, but i don't know how to fix it...

skynet
01-29-2009, 12:38 AM
Are you using dFdx or dFdy in your shaders? It might be, that these don't work the way you assume at multisampled polygon edges.

Don't Disturb
01-29-2009, 01:56 AM
I had a problem like this, the solution was to declare all my GLSL varyings as centroid.

Don't Disturb
01-29-2009, 02:03 AM
An explanation for why is here: http://www.opengl.org/pipeline/article/vol003_6/

Nighthawk
01-29-2009, 02:41 AM
Are you using dFdx or dFdy in your shaders? It might be, that these don't work the way you assume at multisampled polygon edges.
Hmm not directly at least. I use the ASM shaders, and just do regular stuff like dot3 bump mapping, shadow mapping etc.

Well, i think i give up finding a solution. :tired:

I just enable "adaptive AA" in the registry and leave it at that. To accomplish that, the key "ASTT" must changed from "0x30,0x00" to "0x31,0x00" (at least for catalyst 8.8 on winXP).

If you have more ideas, i'm still interested in understanding the problem.

Nighthawk
01-29-2009, 03:04 AM
An explanation for why is here: http://www.opengl.org/pipeline/article/vol003_6/

Thanks that's it :)

But there's no way to specify "centroid" for ARB_vertex/fragment_program, right?

Don't Disturb
01-29-2009, 06:33 AM
Centroid support was introduced in the NV_fragment_program4 extension, but as you want to support ATI you'll have to switch to GLSL.
Or just switch to Direct3D (seriously)