Multisample anti-aliasing

Multisample anti-aliasing (MSAA) is a type of spatial anti-aliasing, a technique used in computer graphics to improve image quality.

Definition

The term generally refers to a special case of supersampling. Initial implementations of full-scene anti-aliasing (FSAA) worked conceptually by simply rendering a scene at a higher resolution, and then downsampling to a lower-resolution output. Most modern GPUs are capable of this form of anti-aliasing, but it greatly taxes resources such as texture, bandwidth, and fillrate. (If a program is highly TCL-bound or CPU-bound, supersampling can be used without much performance hit.)

According to the OpenGL GL_ARB_multisample specification,[1] "multisampling" refers to a specific optimization of supersampling. The specification dictates that the renderer evaluate the fragment program once per pixel, and only "truly" supersample the depth and stencil values. (This is not the same as supersampling but, by the OpenGL 1.5 specification,[2] the definition had been updated to include fully supersampling implementations as well.)

In graphics literature in general, "multisampling" refers to any special case of supersampling where some components of the final image are not fully supersampled. The lists below refer specifically to the ARB_multisample definition.

Description

In supersample anti-aliasing, multiple locations are sampled within every pixel, and each of those samples is fully rendered and combined with the others to produce the pixel that is ultimately displayed. This is computationally expensive, because the entire rendering process must be repeated for each sample location. It is also inefficient, as aliasing is typically only noticed in some parts of the image, such as the edges, whereas supersampling is performed for every single pixel.

In multisample anti-aliasing, if any of the multi sample locations in a pixel is covered by the triangle being rendered, a shading computation must be performed for that triangle. However this calculation only needs to be performed once for the whole pixel regardless of how many sample positions are covered; the result of the shading calculation is simply applied to all of the relevant multi sample locations.

In the extreme case where only one triangle covers every multi sample location within the pixel, only one shading computation is performed, and these pixels are little more expensive (and the result is no different) than in the non-anti-aliased image. This is true of the middle of triangles, where aliasing is not considered to be an issue. (Edge detection can reduce this further by explicitly limiting the MSAA calculation to pixels whose samples involve multiple triangles, or triangles at multiple depths.) In the extreme case where each of the multi sample locations is covered by a different triangle, a different shading computation will be performed for each location and the results then combined to give the final pixel, and the result and computational expense are the same as in the equivalent supersampled image.

The shading calculation is not the only operation that must be performed on a given pixel; multisampling implementations may variously sample other operations such as visibility at different sampling levels.

Advantages

Disadvantages

Alpha testing

Alpha testing is a technique common to older video games used to render translucent objects by rejecting pixels from being written to the framebuffer.[3] If the alpha value of a translucent fragment is not within a specified range, it will be discarded after alpha testing. Because this is performed on a pixel by pixel basis, the image does not receive the benefits of multi-sampling (all of the multisamples in a pixel are discarded based on the alpha test) for these pixels. The resulting image may contain aliasing along the edges of transparent objects or edges within textures, although the image quality will be no worse than it would be without any anti-aliasing.[4] Translucent objects that are modelled using alpha-test textures will also be aliased due to alpha testing. This effect can be minimized by rendering objects with transparent textures multiple times, although this would result in a high performance reduction for scenes containing many transparent objects.[5]

Aliasing

Because multi-sampling calculates textures only once per pixel, aliasing and other artifacts will still be visible inside rendered polygons where fragment shader output contains high frequency components.

Sampling methods

Point sampling

In a point-sampled mask, the coverage bit for each multisample is only set if the multisample is located inside the rendered primitive. Samples are never taken from outside a rendered primitive, so images produced using point-sampling will be geometrically correct, but filtering quality may be low because the proportion of bits set in the pixel’s coverage mask may not be equal to the proportion of the pixel that is actually covered by the fragment in question.

Area sampling

Filtering quality can be improved by using area sampled masks. In this method, the number of bits set in a coverage mask for a pixel should be proportionate to the actual area coverage of the fragment. This will result in some coverage bits being set for multisamples that are not actually located within the rendered primitive, and can cause aliasing and other artifacts.

Sample patterns

Regular grid

A regular grid sample pattern, where multisample locations form an evenly spaced grid throughout the pixel, is easy to implement and simplifies attribute evaluation (i.e. setting subpixel masks, sampling color and depth). This method is computationally expensive due to the large number of samples. Edge optimization is poor for screen-aligned edges, but image quality is good when the number of multisamples is large.

Sparse regular grid

A sparse regular grid sample pattern is a subset of samples that are chosen from the regular grid sample pattern. As with the regular grid, attribute evaluation is simplified due to regular spacing. The method is less computationally expensive due to having a fewer samples. Edge optimization is good for screen aligned edges, and image quality is good for a moderate number of multisamples.

Stochastic sample patterns

A stochastic sample pattern is a random distribution of multisamples throughout the pixel. The irregular spacing of samples makes attribute evaluation complicated. The method is cost efficient due to low sample count (compared to regular grid patterns). Edge optimization with this method, although sub-optimal for screen aligned edges. Image quality is excellent for a moderate number of samples.

Quality

Compared to supersampling, multisample anti-aliasing can provide similar quality at higher performance, or better quality for the same performance. Further improved results can be achieved by using rotated grid subpixel masks. The additional bandwidth required by multi-sampling is reasonably low if Z and colour compression are available.[6]

There are 2x, 4x, 8x, and 16x MSAA. Higher results in better quality but can be slower.

See also

References

  1. ARB_multisample "Additions to Chapter 3 of the 1.2.1 specification" Check |url= value (help).
  2. "OpenGL 1.5 specification" (PDF). |section= ignored (help)
  3. "ShaderLab syntax: Alpha testing". Unity3d.com. 2008-04-27. Retrieved 2012-07-31.
  4. "Multisampling Anti-Aliasing: A Closeup View". Alt.3dcenter.org. Retrieved 2012-07-31.
  5. "Visual comparison of the various Anti-Aliasing modes". Nhancer.com. Retrieved 2012-07-31.
  6. "Multisampling Anti-Aliasing: A Closeup View". Alt.3dcenter.org. Retrieved 2012-07-31.
This article is issued from Wikipedia - version of the Monday, May 02, 2016. The text is available under the Creative Commons Attribution/Share Alike but additional terms may apply for the media files.