I'm experiencing a strange problem using OpenGL SampleAlphaToCoverage mode. There are rendering artifacts when using alpha-blending on pixels that have been rendered using alpha-to-coverage - and I can't explain why.

Here's the basic setup:

  1. Render the world. Some batches of vertices are rendered using alpha-to-coverage. Blending is never enabled at this stage.
  2. Disable depth testing an render a screen overlay. At this point I'm using alpha blending. Alpha-to-coverage is never enabled at this stage.

I'm using alpha-to-coverage on the airplanes glass window. This is what the scene looks like: Works as expected

Everything works as expected so far. However, as soon the screen overlays alpha blending is drawn at a screen location where alpha-to-coverage has been previously active, I'm getting this: Blending artifacts

Note that there is no error as long as blending affects different pixels than alpha-to-coverage! enter image description here

I also tested the following cases:

  • Use alpha-to-coverage for the overlay instead of alpha blending: No artifacts.
  • Clear the entire screen before rendering the screen overlay: No artifacts.
  • Clear all buffers except the color buffer: Artifacts
  • Clear only the color buffer: No artifacts

The screen overlay item in question consists of a single textured Quad. The texture is 256x256.

You can download the test application at http://www.fetzenet.de/atc_error.zip Camera controls are WASD + Mouse (Hold left or right button)

Does anyone have a clue whats going on here? Also, can anyone reproduce this behavior?

  • \$\begingroup\$ Tried playing with glSampleCoverage()? \$\endgroup\$ – Michael Slade May 6 '12 at 18:28
  • \$\begingroup\$ Is the MSAA resolve occurring before or after the screen overlay pass? \$\endgroup\$ – John Calsbeek May 6 '12 at 18:29
  • \$\begingroup\$ @JohnCalsbeek Can you tell me how to find out? I'm rendering both in a single frame and do nothing special.. Is there a way to trigger an MSAA resolve explicitly? \$\endgroup\$ – Adam May 6 '12 at 18:34
  • \$\begingroup\$ @MichaelSlade Yes, I set it to 1.0f when rendering the overlay, but that didn't change anything. \$\endgroup\$ – Adam May 6 '12 at 18:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.