Framebuffer Objects and Multisample?

I see in the Framebuffer Object spec ( 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.”

Hmm, I just found GL_EXT_framebuffer_multisample. Looks like that answers my question.

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?

That would be

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.

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.

Thank you :wink:

This is a short snippet I found helpful for multisampled FBOs.

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

Do I use GL_TEXTURE_2D or GL_TEXTURE_2D_MULTISAMPLE for the target?

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?

Are you unbinding your framebuffer before attempting to draw to the screen?

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

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

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.

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?

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