PDA

View Full Version : Framebuffer Objects and Multisample?



PickleWorld
03-02-2010, 08:57 AM
I see in the Framebuffer Object spec (http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt) the following comment....

"There is no multisample buffer so the value of the implementation-dependent state variables SAMPLES and SAMPLE_BUFFERS are both 0"

Is there any way to get GL_MULTISAMPLE support with FBOs? This comment would seem to indicate no but I wanted to double check? As there is a comment later about "defer this (multisample support) until (shortly) after this extension."

PickleWorld
03-02-2010, 09:04 AM
Hmm, I just found GL_EXT_framebuffer_multisample. Looks like that answers my question.

PickleWorld
03-02-2010, 09:10 AM
Ok next question, the EXT_framebuffer_multisample specs says that...

"No method is provided for creating multisample texture images"

Is that still the case? Or is there a way to create a framebuffer texture image (eg maybe using glFramebufferTexture2DEXT) and have it multisampled?

skynet
03-02-2010, 09:25 AM
That would be
http://www.opengl.org/registry/specs/ARB/texture_multisample.txt

Groovounet
03-02-2010, 09:49 AM
Framebuffer multisample is part of OpenGL 3.0 and texture multisample is part OpenGL 3.2 specification.

If you want to spare the ***EXT and ***ARB functions.

Stanley L
03-02-2010, 09:57 AM
There is also a vendor-specific NV_multisample_coverage extension if you're interested in using the CSAA capabilities available on GeForce 8 series and above NVIDIA cards.

PickleWorld
03-02-2010, 10:55 AM
That would be
http://www.opengl.org/registry/specs/ARB/texture_multisample.txt


Thank you ;)

strattonbrazil
03-02-2010, 12:12 PM
This is a short snippet I found helpful for multisampled FBOs.

http://blog.dexta.ch/2008/08/27/gl_ext_framebuffer_object-with-multisampling/

PickleWorld
03-02-2010, 03:18 PM
So, next question. If I do the following...


glGenFramebuffersEXT( 1, &m_fboID );
glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_fboID );

glGenTextures( 1, &m_colorRB );
glBindTexture( GL_TEXTURE_2D_MULTISAMPLE, m_colorRB );

glTexImage2DMultisample( GL_TEXTURE_2D_MULTISAMPLE, 4, GL_RGBA8, m_width, m_height, GL_FALSE );

glFramebufferTexture2DEXT( GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, ????, m_colorRB, 0 );

For the call to glFramebufferTexture2DEXT()... do I use GL_TEXTURE_2D or GL_TEXTURE_2D_MULTISAMPLE as the target?

The spec says GL_TEXTURE_2D_MULTISAMPLE is only accepted by the <target> parameter of BindTexture and TexImage2DMultisample??

Also, later on when I want to use the texture. Normally I would call...


glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, m_fboID );
glBindTexture( target, m_colorRB );
doDraw();

Do I use GL_TEXTURE_2D or GL_TEXTURE_2D_MULTISAMPLE for the target?

PickleWorld
03-03-2010, 08:08 AM
This is a short snippet I found helpful for multisampled FBOs.

http://blog.dexta.ch/2008/08/27/gl_ext_framebuffer_object-with-multisampling/

Nice fine. However I want to use the ARB_texture_multisample extension instead, don't suppose anyone has any example code for that?

I keep getting a big black screen?

Stanley L
03-03-2010, 01:58 PM
Are you unbinding your framebuffer before attempting to draw to the screen?



glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
glBindTexture( target, m_colorRB );
doDraw();

PickleWorld
03-04-2010, 09:16 AM
Are you unbinding your framebuffer before attempting to draw to the screen?



glBindFramebufferEXT( GL_FRAMEBUFFER_EXT, 0 );
glBindTexture( target, m_colorRB );
doDraw();


Err ya sorry that was a typo... the glBindFramebufferExt call should not have been there.

My problem was actually in my Fragment shader, I was using sampler2D instead of sampler2DMS to access the texture. Once I switched that everything now works fine.

Thanks All ;)

sgsrules
04-01-2010, 02:57 PM
Could someone please post some complete code that uses TexImage2DMultisample on a fbo? I'm currently using glRenderbufferStorageMultisample and blitting which works.. for the most part whenever i try to use rgba16f as a pixelformat and also multisample i get random white and black pixels on the multisampled areas. It works fine with rgba8 but thats not what i want so i'm looking for an alternative and this looks like it fits the bill.

sgsrules
04-03-2010, 04:54 PM
specifically i'd like to know:

Do i have to call glTexImage2D or just glTexImage2DMultisample?
Do i have to do anything else when binding or unbinding my FBO(like blitting). How do i access this texture in the shader?

Dark Photon
04-05-2010, 04:40 AM
How do i access this texture in the shader?
Haven't done it, but access it via a sampler2DMS uniform (or sampler2DMSArray, if you use a multisampled texture array). See the GLSL spec for details.


Do i have to call glTexImage2D or just glTexImage2DMultisample?
If you want a multisampled (MSAA) target, the latter I'd expect (or use glRenderbufferStorageMultisample to allocate a MSAA renderbuffer -- however since you want to feed the result back into a shader as a multisampled target, you want an MSAA texture).

Try allocating a GL_R32F pixel format. See if you get artifacts with that.

And don't cross post! (link (http://www.opengl.org/discussion_boards/ubbthreads.php?ubb=showflat&amp;Number=275136#Post2751 36)).