Discussion:
Multisampling Vs Supersampling
(too old to reply)
Thomas
2012-02-13 00:17:14 UTC
Permalink
Raw Message
Hello

I'm struggling to understand the essential difference between multisampling
and supersampling but I'm getting the impression that multisampling makes
more compromises in order to maintain frame-rates. Will supersampling at 2x2
(for example) give superior image quality than 4x multisampling, or is it
harware dependent.

I'd really welcome any comments on the difference between the two
approaches.

Thanks
Thomas
Nobody
2012-02-15 05:06:01 UTC
Permalink
Raw Message
Post by Thomas
I'm struggling to understand the essential difference between multisampling
and supersampling but I'm getting the impression that multisampling makes
more compromises in order to maintain frame-rates. Will supersampling at 2x2
(for example) give superior image quality than 4x multisampling, or is it
harware dependent.
Multisampling (multisample antialiasing, MSAA) is an approximated form of
supersampling. Specifically, the fragment colour is only calculated for a
single location within each fragment, while the depth test, stencil test
and insideness test are performed for multiple locations.

This means that, unlike supersampling, multisampling doesn't increase the
number of times the fragment shader is executed (unless the fragment
shader calculates gl_FragDepth), and doesn't increase the number of
texture lookups.

OTOH, it doesn't do anything to solve aliasing within the interior of the
primitive. It only antialiases at edges; either the actual edges of
primitives or when fragments are clipped by depth or stencil tests. Note
that it doesn't antialias "edges" resulting from the alpha channel.

MSAA correctly handles polygons which share an edge, whereas traditional
polygon antialiasing (GL_POLYGON_SMOOTH) tends to let the background bleed
through. MSAA doesn't require the primitives to be depth-sorted.

Supersampling may give better results (it should never be worse), but the
performance cost is likely to be far greater.
Thomas
2012-02-15 09:54:39 UTC
Permalink
Raw Message
Post by Nobody
Post by Thomas
I'm struggling to understand the essential difference between
multisampling
and supersampling but I'm getting the impression that multisampling makes
more compromises in order to maintain frame-rates. Will supersampling at 2x2
(for example) give superior image quality than 4x multisampling, or is it
harware dependent.
Multisampling (multisample antialiasing, MSAA) is an approximated form of
supersampling. Specifically, the fragment colour is only calculated for a
single location within each fragment, while the depth test, stencil test
and insideness test are performed for multiple locations.
This means that, unlike supersampling, multisampling doesn't increase the
number of times the fragment shader is executed (unless the fragment
shader calculates gl_FragDepth), and doesn't increase the number of
texture lookups.
OTOH, it doesn't do anything to solve aliasing within the interior of the
primitive. It only antialiases at edges; either the actual edges of
primitives or when fragments are clipped by depth or stencil tests. Note
that it doesn't antialias "edges" resulting from the alpha channel.
MSAA correctly handles polygons which share an edge, whereas traditional
polygon antialiasing (GL_POLYGON_SMOOTH) tends to let the background bleed
through. MSAA doesn't require the primitives to be depth-sorted.
Supersampling may give better results (it should never be worse), but the
performance cost is likely to be far greater.
Thanks a million for taking the trouble to reply - it's really appreciated.

I'm still a little confused about how this works in the context of a custom
shader and in particular a deferred shader.

Say I attach a set of multisampled texture targets to a frame buffer and
then render to that buffer with say 4 samples, capturing the depth,
material, normal etc into each target. Now, in my deferred shader I iterate
over all 4 samples and caluclate an average colour and output that to the
screen. Will I still not get overall antialiasing comparable to 2x2
supersampling?

I did this and I can't see the difference - even though the multisampling is
significantly faster. Also, I see the same level of interior antialiasing.

Thanks again
Thomas
Nobody
2012-02-16 10:13:46 UTC
Permalink
Raw Message
Post by Thomas
Say I attach a set of multisampled texture targets to a frame buffer and
then render to that buffer with say 4 samples, capturing the depth,
material, normal etc into each target. Now, in my deferred shader I iterate
over all 4 samples and caluclate an average colour and output that to the
screen. Will I still not get overall antialiasing comparable to 2x2
supersampling?
It depends upon how the deferred shader uses the data. If all four samples
for a given fragment were generated by the same primitive, the values in
the colour buffers will be identical. If the output from the deferred
shader depends solely on the sample values (and not e.g. the sample
positions), then you shouldn't see any gain from MSAA except at the edges
(fragments whose samples were generated by different primitives).
Post by Thomas
I did this and I can't see the difference - even though the multisampling is
significantly faster. Also, I see the same level of interior antialiasing.
But do you see any difference between supersampling and normal rendering?
If not, you won't see any difference with MSAA either.
Thomas
2012-02-16 21:00:05 UTC
Permalink
Raw Message
Post by Nobody
Post by Thomas
Say I attach a set of multisampled texture targets to a frame buffer and
then render to that buffer with say 4 samples, capturing the depth,
material, normal etc into each target. Now, in my deferred shader I iterate
over all 4 samples and caluclate an average colour and output that to the
screen. Will I still not get overall antialiasing comparable to 2x2
supersampling?
It depends upon how the deferred shader uses the data. If all four samples
for a given fragment were generated by the same primitive, the values in
the colour buffers will be identical. If the output from the deferred
shader depends solely on the sample values (and not e.g. the sample
positions), then you shouldn't see any gain from MSAA except at the edges
(fragments whose samples were generated by different primitives).
Post by Thomas
I did this and I can't see the difference - even though the multisampling is
significantly faster. Also, I see the same level of interior
antialiasing.
But do you see any difference between supersampling and normal rendering?
If not, you won't see any difference with MSAA either.
Brilliant - I finally get it!

So, you get multiple samples but all the samples corresponding to a specific
primitive are identical - unlike supersampling where the samples are truly
independent. This gives edge antialiasing but not interior.

The model I was looking at had millions of faces so just about every
fragment had samples from different faces - hence I get reasonable interior
anti-aliasing.

Thank you very much you have been *really* helpful!!!

Thomas
Nobody
2012-02-17 05:57:26 UTC
Permalink
Raw Message
Post by Thomas
So, you get multiple samples but all the samples corresponding to a specific
primitive are identical - unlike supersampling where the samples are truly
independent. This gives edge antialiasing but not interior.
Yes; depth values (and the stencil values derived from them) are
per-sample, but the "colour" values are per-fragment. Meaning
that you essentially get "shaped fragments". E.g. if you draw two
triangles over the background with 16x MSAA, you might get:

1 . . 2
1 1 2 2
1 2 2 2
2 2 2 2

where . is the background, 1 is the first triangle and 2 is the second.
All of the 1s have the same colour as do all of the 2s, but the resulting
blend is based upon actual coverage. If the triangles shared an edge, you
might get e.g.:

1 1 1 2
1 1 2 2
1 1 2 2
1 2 2 2

resulting in a 50-50 blend, rather than the 25-25-50 (i.e. with the
background bleeding through) which GL_POLYGON_SMOOTH would give.

Typical rendering results in little aliasing within a single primitive
(assuming that you're using mipmaps with correct LoD calculations) but
significant aliasing at the boundary between one primitive and another.
MSAA takes advantage of the fact that eliminating the latter requires
significantly less computation than full supersampling (although it still
requires the same amount of memory).
Post by Thomas
The model I was looking at had millions of faces so just about every
fragment had samples from different faces - hence I get reasonable interior
anti-aliasing.
Right; by "interior", I'm referring to the primitive (triangle).
Thomas
2012-02-17 10:34:15 UTC
Permalink
Raw Message
Post by Nobody
Post by Thomas
So, you get multiple samples but all the samples corresponding to a specific
primitive are identical - unlike supersampling where the samples are truly
independent. This gives edge antialiasing but not interior.
Yes; depth values (and the stencil values derived from them) are
per-sample, but the "colour" values are per-fragment. Meaning
that you essentially get "shaped fragments". E.g. if you draw two
1 . . 2
1 1 2 2
1 2 2 2
2 2 2 2
where . is the background, 1 is the first triangle and 2 is the second.
All of the 1s have the same colour as do all of the 2s, but the resulting
blend is based upon actual coverage. If the triangles shared an edge, you
1 1 1 2
1 1 2 2
1 1 2 2
1 2 2 2
resulting in a 50-50 blend, rather than the 25-25-50 (i.e. with the
background bleeding through) which GL_POLYGON_SMOOTH would give.
Typical rendering results in little aliasing within a single primitive
(assuming that you're using mipmaps with correct LoD calculations) but
significant aliasing at the boundary between one primitive and another.
MSAA takes advantage of the fact that eliminating the latter requires
significantly less computation than full supersampling (although it still
requires the same amount of memory).
Post by Thomas
The model I was looking at had millions of faces so just about every
fragment had samples from different faces - hence I get reasonable interior
anti-aliasing.
Right; by "interior", I'm referring to the primitive (triangle).
Thank you once again for your helpful response.

The major source of interior aliasing effects is likely to arise from
high-frequency textures and these can best be handled using standard
mip-mapping techniques. MSAA would therefore seem to be preferred over
supersampling given its much superior performance.

One question I do have (and I can probably work this out myself if you're
busy) is about the graphics memory requirements of multisampling over
supersampling. I would have assumed that a render target specified as 4x
multisampled would consume the same memory as a regular render target at
twice the width and height - is that the case, or is there some trickery
going on here too :-)

Thanks again
Thomas
Nobody
2012-02-20 04:41:05 UTC
Permalink
Raw Message
Post by Thomas
One question I do have (and I can probably work this out myself if you're
busy) is about the graphics memory requirements of multisampling over
supersampling. I would have assumed that a render target specified as 4x
multisampled would consume the same memory as a regular render target at
twice the width and height - is that the case, or is there some trickery
going on here too :-)
Yes, MSAA has the same memory requirements as conventional supersampling;
it's just the computations (and texture lookups) which are reduced.
g***@gmail.com
2017-11-17 07:06:09 UTC
Permalink
Raw Message
Post by Thomas
Hello
I'm struggling to understand the essential difference between multisampling
and supersampling but I'm getting the impression that multisampling makes
more compromises in order to maintain frame-rates. Will supersampling at 2x2
(for example) give superior image quality than 4x multisampling, or is it
harware dependent.
I'd really welcome any comments on the difference between the two
approaches.
Thanks
Thomas
Loading...