Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 4 of 4

Thread: Strange effect with MSAA + MRT

  1. #1
    Intern Contributor
    Join Date
    Nov 2011
    Posts
    61

    Question Strange effect with MSAA + MRT

    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):


    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
    Code :
    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:

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


    This is the relevant shader code:

    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!
    Last edited by RealtimeSlave; 10-11-2015 at 12:08 PM.
    ++i--;

  2. #2
    Intern Contributor
    Join Date
    Nov 2011
    Posts
    61
    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.
    Last edited by RealtimeSlave; 01-31-2016 at 06:28 AM.
    ++i--;

  3. #3
    Intern Contributor
    Join Date
    Nov 2011
    Posts
    61
    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/9...ng-with-an-fbo
    ++i--;

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    4,151
    Quote Originally Posted by RealtimeSlave View Post
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •