In order to implement "depth-peeling", I render my OpenGL scene in to a series of framebuffers each equipped with a rgba color texture and depth texture. This works fine if I don't care about anti-aliasing. If I do, then it seems the correct thing to do is enable GL_MULTISAMPLING
and use a GL_TEXTURE_2D_MULTISAMPLE
instead of GL_TEXTURE_2D
. But I'm confused about which other calls need to be replaced.
In particular, how should I adapt my framebuffer construction to use glTexImage2DMultisample
instead of glTexImage2D
?
Do I need to change the calls to glFramebufferTexture2D
beyond using GL_TEXTURE_2D_MULTISAMPLE
instead of GL_TEXTURE_2D
?
If I'm rendering both color and depth into textures, do I need to make a call to glRenderbufferStorageMultisample
?
Finally, is there some glBlit*
that I need to do in addition to setting up textures for the framebuffer to render into?
There are many related questions on this topic, but none of the solutions I found seem to point to a canonical tutorial or clear example putting all these together.
glBlitFramebuffer
function for that purpose, but you can get a lot more flexibility just setting up an ortho projection and identify MV matrix and rendering textured quads using the FBO color attachment texture(s). It'll allow you to then process the results in a fragment shader and do post-processing like AA or deferred shading. – user4842163glBlitFramebuffer
to resolve an image from a multisample target and how we can access texels from a multisampled texture usingsampler2DMS
in the frag shader. One thing I'm not clear on is whether you can have a single multisample FBO contain both depth and color attachments at the same time. We might need two passes there. – user4842163