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 8 of 8

Thread: Multisampled FBO problem

  1. #1
    Junior Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    249

    Multisampled FBO problem

    I have a problem with multisampled FBO's. I just don't get any anti-alaising unless i specify the max supported value.
    Code

    Code :
            GLint maxSamples;
     
            glGetIntegerv(GL_MAX_SAMPLES_EXT, &maxSamples);
     
            glGenRenderbuffersEXT        ( 1, &mColourBuffer );
            glBindRenderbufferEXT        ( GL_RENDERBUFFER_EXT, mColourBuffer);
            glRenderbufferStorageMultisampleEXT(GL_RENDERBUFFER_EXT, maxSamples, GL_RGBA, mFBOTextureWidth, mFBOTextureHeight );
     
            glGenRenderbuffersEXT        ( 1, &mDepthBuffer );
            glBindRenderbufferEXT        ( GL_RENDERBUFFER_EXT, mDepthBuffer );
            glRenderbufferStorageMultisampleEXT( GL_RENDERBUFFER_EXT, maxSamples, GL_DEPTH_COMPONENT, mFBOTextureWidth, mFBOTextureHeight );
     
            glGenFramebuffersEXT        ( 1, &mFrameBufferMulti );
            glBindFramebufferEXT        ( GL_FRAMEBUFFER_EXT, mFrameBufferMulti );
            glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, mColourBuffer );
            glFramebufferRenderbufferEXT( GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, mDepthBuffer );
     
            GLenum status = glCheckFramebufferStatusEXT( GL_FRAMEBUFFER_EXT );

    I set my FBO

    Code :
    glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, mFrameBufferMulti );

    draw a bunch of stuff

    Then final blit to another FBO, do some shaders on it and swap buffers
    Code :
        glBindFramebufferEXT(GL_READ_FRAMEBUFFER_EXT, mFrameBufferMulti);
        glBindFramebufferEXT(GL_DRAW_FRAMEBUFFER_EXT, mFrameBuffer);
        glBlitFramebufferEXT(0, 0, mFBOTextureWidth, mFBOTextureHeight, 0, 0, mFBOTextureWidth, mFBOTextureHeight, GL_COLOR_BUFFER_BIT, GL_LINEAR);

    Pic


    For some reason only the value 16x seems to work. There is no glEnable for FBOs to set anti-alaising ?

  2. #2
    Member Regular Contributor
    Join Date
    Apr 2009
    Posts
    268
    Quote Originally Posted by dukey View Post
    There is no glEnable for FBOs to set anti-alaising ?
    Nope. There is single enable for multisampling, and its enabled by default.

  3. #3
    Junior Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    249
    Is it possible to disable multisampling for a multisampled FBO ?

    This kind of reminds me of when I was using a multisampled back buffer and setting a value of 16x, then disable multisampling. You would still get something like 4x multisampling anyway with nvidia ..

  4. #4
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,126
    Quote Originally Posted by dukey View Post
    Is it possible to disable multisampling for a multisampled FBO ?
    There are two pieces to multisample rendering: multisample rasterization and multisample downsample filtering. The first happens while rendering, the second happens internally to SwapBuffers (or explicitly when downsampling via glBlitFramebuffer).

    You can easily disable the first: glDisable( GL_MULTISAMPLE ). For the system FB, don't think you can disable the multisample downsample filtering. But if you render to an off-screen multisample texture/renderbuffer via an FBO, then you can chose what to do after rendering the multisampled render target. You could write your own trivial downsample shader that that basically just takes the first sample in each pixel (or whatever) as the pixel's value.

    This kind of reminds me of when I was using a multisampled back buffer and setting a value of 16x, then disable multisampling. You would still get something like 4x multisampling anyway with nvidia ..
    Right. I've seen the same. I think this is because you disabled multisample rasterization but not the multisample downsample filtering.
    Last edited by Dark Photon; 06-07-2012 at 06:52 AM.

  5. #5
    Junior Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    249
    My source and destination FBOs are the same size. I just don't understand why I don't get any anti-aliasing unless I specify the max value. Interestingly 16x seems to look more like 4x anti-alaising.

  6. #6
    Intern Newbie
    Join Date
    Jun 2010
    Posts
    41
    Quote Originally Posted by dukey View Post
    My source and destination FBOs are the same size. I just don't understand why I don't get any anti-aliasing unless I specify the max value. Interestingly 16x seems to look more like 4x anti-alaising.
    Yup, you're certainly getting 4x SUPERsampling (and no useful multisampling).
    On nVidia cards, at least up to GT200 series, so-called 16x multisampling is achieved by cumulating 4x multisampling with 4x supersampling.
    That results in images being anti-aliased even if multisampling is disabled while rendering to a 16x multisample buffer. I encountered the exact same problem (except I wanted to have no anti-aliasing to implement a stencil-routed K-buffer).

    For some reason it seems as if multisampling is disabled in your case. Did you try glEnable( GL_MULTISAMPLE ) before rendering?
    Did you try to blit from your multisample buffer to your output buffer another way (e.g. the infamous glCopyPixels)?

  7. #7
    Junior Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    249
    On nVidia cards, at least up to GT200 series, so-called 16x multisampling is achieved by cumulating 4x multisampling with 4x supersampling.
    Yeah I remember something like this was true. I found it myself when using a multisampled back buffer. Trying to disable multi sampling still leaves you with some super sampling.

    For some reason it seems as if multisampling is disabled in your case
    I know, I have been stuck on this problem for a while now. I didn't think it was possible to disable multisampling on a multisampled FBO ..
    I can try
    glEnable( GL_MULTISAMPLE )

    and just see what happens.

    I haven't tried glCopyPixels either, but I guess I can give it ago.

  8. #8
    Junior Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    249
    okay,
    there was a stray call to glDisable(GL_MULTISAMPLE_ARB)
    that was doing it !
    Solved thankfully

Posting Permissions

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