Sampling Location of MSAA

Key Difference from Supersampling

With supersampling, the image color is computed per subpixel, and so each subpixel could potentially be a different color. With multisampling, the image color is computed once per pixel and that color is replicated into all visible subpixels that are covered by the polygon. Because computing the image color is one of the most expensive steps in the graphics pipeline, the savings from multisampling over supersampling is significant. On the other hand, supersampling is more accurate. For reference, here are the definitions of subsampling and supersampling.

subsampling

Subsampling

When a high resolution image is downsampled, subsampling is the way a low resolution image represents the original high resolution one. Pixels to be merged should decide what color to be painted using, for example, average downsampling.

supersampling

Supersampling

When a low resolution image is upsampled, it is required that new pixels be generated. Once the original image is subdivided, new pixels can be generated by referencing neighboring pixels and interpolating them.

Sampling Location

In case of multisampling, the sampling location can vary as follows:

one sampling per pixel

When MSAA uses nn subsamples per pixel, the number of covered subsamples among the total nn subsamples determines how much the pixel color contributes to the framebuffer. However, it does not imply that the fragment shader should run nn times per pixel for shading. In fact, MSAA computes the surface’s shade once per pixel and shares this result among the subsamples. Pixels have nn sample locations per fragment, each with their own color and z-depth, but the fragment shader is evaluated only once for each object fragment applied to the pixel.

sampling outside of the primitive

Extrapolation

With single sampling, fragments are only generated if the pixel center is covered. Sampling happens at the pixel center, and interpolation and shading only occur within the primitive. However, in multisampling, fragments are generated if any of the subsamples is in the primitive. If all MSAA positional subsamples are covered by the fragment, the shading sample is evaluated at the center of the pixel. Instead, if the fragment covers fewer positional subsamples, the sampling location could be the pixel center, one of the sample locations within the pixel, or an arbitrary location. Most importantly of all, this subsample may lie outside of the actual primitive being rendered, so that it is extrapolated, not interpolated. This may cause a problem like when using a square root function only defined for positive numbers since the extrapolation might generate a negative number.

centroid

Centroid

The centroid qualifier is used to prevent the extrapolation problem. OpenGL allows the sampling to choose the ideal centroid or any location that is inside the intersection of the pixel square and the primitive, such as a sample point or a pixel center. So, this qualifier ensures that all sampling uses interpolation, never extrapolation. The reason why this qualifier is not default, however, is that it is more expensive than evaluating at the center, and the derivatives like dFdx or dFdy are less accurate since they have irregular spacing between evaluations.

Separately, the sample qualifier forces OpenGL to interpolate to the location of the particular sample for each generated fragment. This is only useful with per-sample shading.

References

[1] 카츠라 요스케 , 요츠쿠라 타츠오 , 마크 살바티, 테크니컬 아티스트를 위한 최고의 교과서: 내공 있는 CG 아티스트로 이끌어주는 체계적인 입문서, 2014

[2] Tomas Akenine-Mller, Eric Haines, and Naty Hoffman. 2018. Real-Time Rendering, Fourth Edition (4th. ed.). A. K. Peters, Ltd., USA.

[3] Frank Luna. 2016. Introduction to 3D Game Programming with DirectX 12. Mercury Learning & Information, Dulles, VA, USA.

[4] Anti Aliasing

[5] GLSL: Center or Centroid? (Or When Shaders Attack!)


© 2025. All rights reserved.