PDA

View Full Version : Strange effect with MSAA + MRT



RealtimeSlave
10-11-2015, 12:01 PM
Hello,

I am working on Multiple Render Target (MRT) stuff. I have two
RGBA8 color textures attached to my FBO. Everything is fine
without MSAA.

But when I activate MSAA for the FBO I get this strange effect (see image):
http://abload.de/img/msaa-mrt-multiple-rennrky9.png

While the content of the 2nd color attachment (the GBuffer, not shown here) looks as expected,
the content of the 1st color attachment (RGBA) looks weird. Namely as if the triangles are more
and more "blended" with the black background as the MSAA sample count increases (getting darker).

The strange thing is, this happens although blending is disabled

glDrawBuffers(2, &Buffers[0]); // Buffers contains GL_COLOR_ATTACHMENT0 and GL_COLOR_ATTACHMENT1

glDisable(GL_BLEND);
glDrawElements(GL_TRIANGLES, ... );
I can "fix" the effect by telling OpenGL not to modify the alpha channel of the 1st color attachment:


glColorMaski( 0, true, true, true, false);
glDrawElements(GL_TRIANGLES, ... );

This is the relevant shader code:


out vec4 Color; // defines color in 1st color attachment
out vec4 Color1; // defines color in 2nd color attachment
void main(void)
{
Color = CalculateColor(...does not matter...);
if (Color.r <= 1.0) Color = vec4(1.0); // For debugging purposes just set the color to white for the 1st color attachment

Color1 = SetGBuffer(...does not matter...);
Color1.a = 1.0; // For debugging purposes just set the alpha to one for the 2nd color attachment
}

The names of the shader outs (Color, Color1) are set before linking the program via glBindFragDataLocation().

The shader code is validated and works fine. The FBO is also validated and complete. There are no OpenGL errors reported.


I really need help with this, I am debugging this issue for so long and I am out of ideas what could be the reason =/


Help is really appreciated!

RealtimeSlave
01-31-2016, 05:11 AM
No one has an idea? :(

Btw when first downsampling to another single sampled FBO and then blitting to onscreen it works.

But for some reason blitting directly the MSAA FBO to onscreen does not work as you can see above in the screenshot.

RealtimeSlave
01-31-2016, 12:05 PM
Found this thread where somebody mentioned it has to do with "mismatching sample locations"?!

Never heard that before, what does it mean?

http://stackoverflow.com/questions/9104927/why-does-opengl-lighten-my-scene-when-multisampling-with-an-fbo

Dark Photon
02-01-2016, 07:18 AM
Btw when first downsampling to another single sampled FBO and then blitting to onscreen it works.

But for some reason blitting directly the MSAA FBO to onscreen does not work as you can see above in the screenshot.

Not sure if I know exactly the cause of your problem, but I hit something like this once (except it triggered a GL error not rendering artifacts). Check the glBlitFramebuffer docs for details, but IIRC you can't downsample (or otherwise change the samples config) and resize with one blit. So you can run into problems where the target is a different size in pixels from the source and one is MSAA. You can also run into problems where both are MSAA (even if both have the same resolution), but possibly not necessarily the same sample configuration. Check the glBlitFramebuffer docs for specifics though.