How does multisample really work?
Asked Answered
I

1

12

I am very interested in understanding how multisampling works. I have found a large literature on how to enable or use it, but very little information concerning what it really does in order to achieve an antialiased rendering. What I have found, in many places, is conflicting information that only confused me more.

Please note that I know how to enable and use multisampling (I actually already use it), what I don't know is what kind of data really gets into the multisampled renderbuffers/textures, and how this data is used in the rendering pipeline.

I can understand very well how supersampling works, but multisampling still has some obscure areas that I would like to understand.

here is what the specs say: (OpenGL 4.2)

Pixel sample values, including color, depth, and stencil values, are stored in this buffer (the multisample buffer). Samples contain separate color values for each fragment color.

...

During multisample rendering the contents of a pixel fragment are changed in two ways. First, each fragment includes a coverage value with SAMPLES bits.

...

Second, each fragment includes SAMPLES depth values and sets of associated data, instead of the single depth value and set of associated data that is maintained in single-sample rendering mode.

So, each sample contains a distinct color, coverage bit, and depth. What's the difference from a normal supersampling? Seems like a "weighted" supersampling to me, where each final pixel value is determined by the coverage value of its samples instead of a simple average, but I am very unsure about this. And what about texture coordinates at sample level?

If I store, say, normals in a RGBF multisampled texture, will I read them back "antialiased" (that is, approaching 0) on the edges of a polygon?

A fragment shader is called once per fragment, unless it uses gl_SampleID, glSampleIn or has a 'sample' storage qualifier. How can a fragment shader be invoked once per fragment and get an antialiased rendering?

Infracostal answered 14/1, 2012 at 10:2 Comment(6)
An explanation by NVIDIA: nvidia.com/object/feature_hraa.htmlPermalloy
sorry but this link provides absolutely no information on how ms works, you can get even better info from wikipediaInfracostal
This one then, a 2007 Stanford CS lecture: graphics.stanford.edu/courses/cs248-07/lectures/…, too bad that it does not reference any sources though.Permalloy
In fact they do reference sources: graphics.stanford.edu/courses/cs248-07/schedule.php, but you need a subscription to view the articles.Permalloy
And there's this technical spec (1994) from the OpenGL site, but maybe you have seen it already. It explains in full detail what is done If MULTISAMPLE_SGIS is enabled: opengl.org/registry/specs/SGIS/multisample.txtPermalloy
finally.. that is interesting. SGIS specs are a bit old (1994) but an in-depth view of mulisampling functionality is given, and I guess OpenGL pretty much implemented multisampling this way..Infracostal
P
7

OpenGL on Silicon Graphics Systems:

http://www-f9.ijs.si/~matevz/docs/007-2392-003/sgi_html/ch09.html#LE68984-PARENT

mentions: When you use multisampling and read back color, you get the resolved color value (that is, the average of the samples). When you read back stencil or depth, you typically get back a single sample value rather than the average. This sample value is typically the one closest to the center of the pixel.

And there's this technical spec (1994) from the OpenGL site. It explains in full detail what is done If MULTISAMPLE_SGIS is enabled: http://opengl.org/registry/specs/SGIS/multisample.txt

See also this related question: How are depth values resolved in OpenGL textures when multisampling?

And the answers to this question, where GL_MULTISAMPLE_ARB is recommended: where is GL_MULTISAMPLE defined?. The specs for GL_MULTISAMPLE_ARB (2002) are here: http://www.opengl.org/registry/specs/ARB/multisample.txt

Permalloy answered 14/1, 2012 at 11:25 Comment(1)
great, and thank you for the reference to the multisampling questionInfracostal

© 2022 - 2024 — McMap. All rights reserved.