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:
- Render the world. Some batches of vertices are rendered using alpha-to-coverage. Blending is never enabled at this stage.
- 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:
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:
Note that there is no error as long as blending affects different pixels than alpha-to-coverage!
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?