PDA

View Full Version : Multisampled color buffer with non-MSAA depth?



Leadwerks
10-08-2008, 05:58 PM
Is it possible to create an FBO with a multisampled color buffer, and a non-multisampled depth buffer? Or must the framebuffer_multisample extension make all components of the FBO multisampled?

Also, with an MSAA FBO, would the depth values be interpolated? So if you had a pixel that was right along a building's edge, the antialiased depth might be halfway between the wall's depth and the background, i.e. a totally wrong value?

arekkusu
10-08-2008, 06:32 PM
Read the spec (http://www.opengl.org/registry/specs/EXT/framebuffer_multisample.txt), and look at
Modification to 4.4.4.2 (Framebuffer Completeness)

Leadwerks
10-08-2008, 08:49 PM
Modification to 4.4.4.2 (Framebuffer Completeness)

Add an entry to the bullet list:

* The value of RENDERBUFFER_SAMPLES_EXT is the same for all attached
images.
{ FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT }

Also add a paragraph to the end of the section:

"The values of SAMPLE_BUFFERS and SAMPLES are derived from the
attachments of the currently bound framebuffer object. If the
current DRAW_FRAMEBUFFER_BINDING_EXT is not "framebuffer complete",
then both SAMPLE_BUFFERS and SAMPLES are undefined. Otherwise,
SAMPLES is equal to the value of RENDERBUFFER_SAMPLES_EXT for the
attached images (which all must have the same value for
RENDERBUFFER_SAMPLES_EXT). Further, SAMPLE_BUFFERS is one if
SAMPLES is non-zero. Otherwise, SAMPLE_BUFFERS is zero.
That would seem to indicate that they must all use the same sampling, but it's written in Geek.

What about the depth interpolation? I cannot think of a single reason you would ever want depth interpolation like that, because all the blended values would be completely wrong.

Korval
10-08-2008, 09:17 PM
Is it possible to create an FBO with a multisampled color buffer, and a non-multisampled depth buffer?

Um, what would that mean in terms of the multisample algorithm? Even if it worked, it wouldn't make any sense, unless you don't actually use a depth-buffer. You need the per-sample depth information in order to be able to combine the colors together properly.


The value of RENDERBUFFER_SAMPLES_EXT is the same for all attached images.

That line seems to be pretty clear. The sample count for all renderbuffers attached to an FBO must be the same, or else the framebuffer object is not complete.


Also, with an MSAA FBO, would the depth values be interpolated?

I don't think the depth buffer of a multisample depth buffer is ever converted into it's non-multisample form. I suppose you could do a blit to manually convert it, but I wouldn't expect it to make sense even if the spec allows it.

V-man
10-08-2008, 10:47 PM
Is it possible to create an FBO with a multisampled color buffer, and a non-multisampled depth buffer? Or must the framebuffer_multisample extension make all components of the FBO multisampled?

If I'm not mistaken, typically the actual buffer is twice the size. Then when you will present the color buffer, the multisampling operation takes place.
So the depth buffer must be of the same sampling as the MSAA color buffer.


Also, with an MSAA FBO, would the depth values be interpolated? So if you had a pixel that was right along a building's edge, the antialiased depth might be halfway between the wall's depth and the background, i.e. a totally wrong value?

No, the depth test operation takes place while you are rendering to the MSAA-FBO. Then, when you want to blit the MSAA-FBO to a std FBO, the multisample operation takes place.
So, you would only blit the color layer. No need for the depth layer.

Leadwerks
10-09-2008, 01:57 PM
I will be reading the depth buffer to perform deferred lighting. I know this may create some visual artifacts, but the architecture firm I am doing this for wants to try it...they really like their fine geometry.

When I read from the depth texture, are those values going to be interpolated between a 2x2 grid?

V-man
10-09-2008, 02:45 PM
You can't have a MSAA depth texture from all that I have read.
You need to blit the MSAA-depth-buffer to a depth-texture (FBO).
When you blit, the multisample operation will be done.

PS : you can't even have a MSAA color texture either.

Korval
10-09-2008, 04:07 PM
When you blit, the multisample operation will be done.

To slightly clarify this, after the blit, it won't be multisampled anymore. So no more anti-aliasing.

Really, you can't use deferred lighting and multisampling. You can do a depth pre-pass just fine, but deferred lighting isn't possible.