Part of the Khronos Group

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: MSAA in OpenGL 4.0

  1. #1
    Intern Contributor
    Join Date
    Mar 2011

    Question MSAA in OpenGL 4.0

    Hi All. I am trying to understand different methods of MSAA in GL 4.0 (CORE) I started with GL 3.3 and used the book "OpenGL Superbible 5" as a primary reference to modern pipeline.In the app I have been working on I needed to implement MSAA manuall because I use FBOs for offscreen rendering.The approach outlined in SB5 looks complex where the sample weights are calculated on CPU then passed to shaders and used by texelFetch . But then I took a look into GL 4.0 specs and found a new "Adaptive multisampling and per-sample processing" technique exposed via GL_ARB_sample_shading. It looks really simple to implement :Just enable multisampling , attach mulitsample texture to the FBO ,then in fragment shader
    use interpolateAtSample + gl_sampleID . Apparently it looks like this approach does the job.But I would like to know if this is how the optimal MSAA should be done in GL 4.0 ?

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    If you really do want MSAA (Multisample Antialiasing), and "optimal" performance MSAA at that, with off-screen render targets, then:

    1. Create multisample textures (or renderbuffers) as render targets (color, depth/stencil, etc.)
    2. Attach to an FBO
    3. Bind the FBO as the DRAW_FRAMEBUFFER
    4. glEnable( GL_MULTISAMPLE )
    5. Render to it
    6. Use glBlitFramebuffer to downsample from multisample (per pixel) to single sample (per pixel)

    That gets you standard MSAA rasterization and MSAA downsample filtering. This is very efficient because the fragment shader only runs once per pixel, but depth/stencil comparisons happen once per "sample" (i.e. several times per pixel), giving you nice antialiased geometry edges without a lot of extra expense.

    Optimal performance generally would not include doing things like sample shading, which effectively allows you to run the fragment shader multiple times per pixel rather than once. This can get expensive very quickly.
    Last edited by Dark Photon; 07-30-2012 at 06:51 PM.

Tags for this Thread

Posting Permissions

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