Advertisement Jump to content
Sign in to follow this  
Fnord42

OpenGL Multisampled FBO-depth-textures

This topic is 2590 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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!

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!