Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 2 of 2 FirstFirst 12
Results 11 to 17 of 17

Thread: Reading a texture from multisample back-buffer

  1. #11
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    81
    Drawing directly on the FBO with texture I get a texture without antialiasing.

    I will try to use a multisample FBO and see what happens, but I'm losing hope...
    Last edited by Devdept2; 05-15-2012 at 06:51 AM.

  2. #12
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    728
    You need to create multi-sample textures with glteximage2dmultisample, not normal textures and enable mutli-sampling

  3. #13
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    81
    I tried drawing on a multisample FBO with the same number of Samples of my pixel format (that is 2) and then copying it to my back buffer.

    The situation improved but it's still not pixel perfect yet (near horizontal and near vertical lines are the same, oblique lines are not)...

    Code :
                    int nSamples;
                    nSamples = 2;
     
                    //Now make a multisample color buffer
                    rbColorMS= gl.GenRenderbuffersEXT();
                    gl.BindRenderbufferEXT(gl.RENDERBUFFER_EXT, rbColorMS);
                    gl.RenderbufferStorageMultisampleEXT(gl.RENDERBUFFER_EXT, nSamples, gl.RGBA8, fboTexSize, fboTexSize);
                    gl.BindRenderbufferEXT(gl.RENDERBUFFER_EXT, 0);
     
                    //Make a depth multisample depth buffer
                    rbDepthMS = gl.GenRenderbuffersEXT();
                    gl.BindRenderbufferEXT(gl.RENDERBUFFER_EXT, rbDepthMS);
                    gl.RenderbufferStorageMultisampleEXT(gl.RENDERBUFFER_EXT, nSamples, gl.DEPTH_COMPONENT, fboTexSize, fboTexSize);
                    gl.BindRenderbufferEXT(gl.RENDERBUFFER_EXT, 0);
     
                    // Create FBO and attach the 2 render buffers
                    fboMS = gl.GenFramebuffersEXT();
                    gl.BindFramebufferEXT(gl.FRAMEBUFFER_EXT, fboMS);                           
                    gl.FramebufferRenderbufferEXT(gl.FRAMEBUFFER_EXT, gl.COLOR_ATTACHMENT0_EXT, gl.RENDERBUFFER_EXT, rbColorMS);
                    gl.FramebufferRenderbufferEXT(gl.FRAMEBUFFER_EXT, gl.DEPTH_ATTACHMENT_EXT, gl.RENDERBUFFER_EXT, rbDepthMS);
     
                    status = gl.CheckFramebufferStatusEXT(gl.FRAMEBUFFER_EXT);
                    CheckFboStatus(status);
                    gl.BindFramebufferEXT(gl.FRAMEBUFFER_EXT, 0);
     
                // Enable Multisample FBO
                gl.BindFramebufferEXT(gl.FRAMEBUFFER_EXT, fboMS);
     
                gl.Clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
     
                // DRAW THE SCENE on the multisample FBO....
     
    ...
                // Later on, copy the Mutlisample FBO to the Backbuffer
     
                gl.BindFramebufferEXT(gl.READ_FRAMEBUFFER_EXT, fboMS);
                gl.BindFramebufferEXT(gl.DRAW_FRAMEBUFFER_EXT, 0);
                gl.BlitFramebufferEXT(0, 0, Width, Height, 0, 0, Width, Height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
                gl.BindFramebufferEXT(gl.READ_FRAMEBUFFER_EXT, 0);
                gl.BindFramebufferEXT(gl.DRAW_FRAMEBUFFER_EXT, 0);

  4. #14
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    81
    So is there no way to get a pixel perfect capture of a Multisampled framebuffer on NVidia cards?

    If I was doing antialiasing by myself (through Accumulation buffer) would I still get this problem? (I'm afraid of the penalty of having to draw the scene multiple times, though...).

    I could also always draw in the multisampled FBO and copy it to the backbuffer at every frame (instead of drawing directly to the backbuffer for standard frames and use the draw to FBO + copy to Backbuffer for the quick repaints at the end of a movement of the scene).
    This way I would always pay the cost of the copy from FBO to BackBuffer (is it much?), but the frames would be consistent because I would be drawing them always in the same way.
    Last edited by Devdept2; 05-22-2012 at 02:03 AM.

  5. #15
    Junior Member Newbie
    Join Date
    May 2012
    Location
    chennai
    Posts
    1
    thanks for ur posting. i used to try to draw in multisampled FBO but i cant to get perfect pixel on nivida card
    Xenomi Software Technologies Private Limited
    Plot No. 94, 1st Floor, 9th Street, Chowdri Nagar,
    Valasaravakkam, Chennai - 600087,India.
    T: 91 44 42128949 M: 91 9884812627 F: 91 44 4355 2490
    santosh@xenomisoft.com
    www.xenomisoft.com

  6. #16
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    2,882
    Quote Originally Posted by Devdept2 View Post
    So is there no way to get a pixel perfect capture of a Multisampled framebuffer on NVidia cards?
    To your question, obtaining exactly the same output relies on either 1) you replicating exactly the downsample filter that NVidia is using, or 2) just using NVidia's downsampling. #2 is probably the safest since #1 is potentially vendor-specific magic.

    As far as obtaining the actual framebuffer samples, you can read back the actual subsamples from an MSAA FBO (possibly with help of a tiny frag shader). You can also read back the downsampled pixel values of course. So getting the actual data pre- and post- isn't a problem. You canalso query sample positions IIRC. But you still come back to needing to replicate the downsample filter being used (or just using the one that's built-in).

    I could also always draw in the multisampled FBO and copy it to the backbuffer at every frame ... This way I would always pay the cost of the copy from FBO to BackBuffer (is it much?), but the frames would be consistent because I would be drawing them always in the same way.
    Should be fairly cheap. I mean, the GPU has to downsample the image to render it anyway, and if you do timing in an MSAA video mode you'll see that this is rolled into your SwapBuffer time. So forcing your own downsample via glBlitFramebuffer and blitting from an MSAA FBO to a single-sample system FB should just be making this downsample explicit in your code.

  7. #17
    Intern Contributor
    Join Date
    Nov 2010
    Posts
    81
    Thank you very much.

    I went down the route of drawing my scene on the Multisample FBO always and copying it at every frame on the Single Sample BackBuffer and it works nice.

Posting Permissions

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