Multisampled FBO-depth-textures

Started by
-1 comments, last by Fnord42 12 years, 4 months ago
Hi there,

I'm currently trying to implement MJP's deferred "MSAA" in OpenGL, where I need a multisampled depth-only geometry-prepass and use the results in a post-processing CFAA-shader.
For that I've created a FBO with a multisampled texture.
My problem is, that all the depth-samples seems to be equal if I query them in the post-processing shader.
The strange thing is, if I profile the time needed for a 8x multisampled and a non-multisampled depth-only pass they both need the same time.
I don't know how efficient hardware-MSAA is, but it I can't really believe that my ATI HD 5700 is that parallel on MSAA.
I use the proprietary-ati-drivers on linux and glxinfo says I have OpenGL 4.2.

This is how I create the FBO and texture:

glEnable(GL_MULTISAMPLE);
glGenTextures(1, &m_msaaDepthTexId);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_msaaDepthTexId);
glTexImage2DMultisample(GL_TEXTURE_2D_MULTISAMPLE, m_msaaSamples, GL_DEPTH_COMPONENT32, width, height, GL_TRUE);

glGenFramebuffers(1, &m_msaaFboId);
glBindFramebuffer(GL_FRAMEBUFFER, m_msaaFboId);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE, m_msaaDepthTexId, 0);
glDrawBuffer(GL_NONE);
glReadBuffer(GL_NONE);


In the prepass-shader I don't explicitly assign a depthvalue.
In the postprocessing-shader I access the multisampled depth-texture like this:

uniform sampler2DMS texDepthMS;
...
void main()
{
ivec2 sampleLocation = ivec2(texCoords * frameSize);
for (int i = 0; i < 4; i++)
float msDepth = texelFetch(texDepthMS, sampleLocation, i).x;
}

But the msDepth-values are all independent from i and equal to the non-ms-depth-value.

I set the texture uniform like that:

glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D_MULTISAMPLE);
glBindTexture(GL_TEXTURE_2D_MULTISAMPLE, m_msaaDepthTexId);
glUniform1i(m_msaaShader->getUniformLocation("texDepthMS"), 1);


Someone had different problems or knows what might be wrong?

Greets and thanks for your time!

This topic is closed to new replies.

Advertisement