Jump to content
  • Advertisement
Sign in to follow this  

iOS Multisample problem

This topic is 2377 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

I was planning to implement multisampling in my application but I discovered some difficulties
Problem is that if I try to multisample frame buffer which has texture instead of renderbuffer target multisampling simply did not work on device.
[size=2]iPod touch 4G: [size=2]iOS 4.1

When I try to multisample frambuffer with renderbuffer as target everything works as expected.
When I use framebuffer with texture as target i got exact same copy without multisampling.

Both versions work in simulator but yes a lot of things works in simulator :)

if there is any chance that I have bad code here it is
FB generation

glGenFramebuffers(1, &framebuffer);
glBindFramebuffer(GL_FRAMEBUFFER, framebuffer);

glGenTextures(1, &texture);
glBindTexture(GL_TEXTURE_2D, texture);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, resolutionX, resolutionY, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, texture,0);
// msaa //

glGenFramebuffers(1, &msaaFrameBuffer);
glBindFramebuffer(GL_FRAMEBUFFER, msaaFrameBuffer);

glGenRenderbuffers(1, &msaaRenderBuffer);
glBindRenderbuffer(GL_RENDERBUFFER, msaaRenderBuffer);
glRenderbufferStorageMultisampleAPPLE(GL_RENDERBUFFER, 4, GL_RGB8_OES, resolutionX, resolutionY);
glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, msaaRenderBuffer);

and after rendered into msaaFrameBuffer

glBindFramebuffer(GL_READ_FRAMEBUFFER_APPLE, msaaFrameBuffer);
glBindFramebuffer(GL_DRAW_FRAMEBUFFER_APPLE, framebuffer);
GLenum attachments[] = {GL_COLOR_ATTACHMENT0};
glDiscardFramebufferEXT(GL_READ_FRAMEBUFFER_APPLE, 1, attachments);

As I said it works with renderbuffer but no multisample applied when texture used in framebuffer. I've also tried to add depth buffer (for some reasons this should be also problem) but nothing seems to help.

Is there anyone who successfully implemented multisampling with texture as frambuffer target?

Share this post

Link to post
Share on other sites
You would need to have 2 FBOs for that.

The first FBOwill support multisample rendering - This is the actual FBO that our application will render to

The second FBO will be the resolve target - will store the final offscreen texture that will be applied to the full screen quad.

So you render to the First FBO with multisampling and blit ( glBlitFramebuffer ) to the Second one to obtain multisampled texture.

Share this post

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

  • Advertisement

Important Information

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

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!