0
\$\begingroup\$

I am currently trying to understand Supersampling.

Wikipedia says (or at least Wikipedia tells me) that multiple color samples are taken from one pixel to calculate the final result. But to my mind one pixel has exactly one color and logically, the average of an infinite amount of equal colors remains the same.

So, how can the resulting color differ from the original pixel's color?

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

You are thinking of pixels as if they are some atomic structure, indivisible; they are not.

Take a look at the following diagram from the Direct3D documentation on multisample rasterization:

  Pixel coverage

Various triangulated objects are drawn here and the diagram shows a pixel structure with 4 samples (at fixed locations) per-pixel. Take a close look at the pixel in the second row of the first column; the triangle only partially covers this pixel.

If this diagram were rasterized using a single sample, then the color would be determined at the center of that pixel where the diamond shape is based on the triangle that covers it. However, this is 4x multisampling - the final (resolved) pixel color is the average of all 4 samples (one of which is not even covered by the triangle).

The key concept you seem to be missing is the final resolve. You cannot display all 4 samples on screen per-pixel and not every one of the samples is covered by the same geometry. You can get very different results when resolving from n-many samples to 1 or even simply changing the positions of the samples.

\$\endgroup\$
4
  • \$\begingroup\$ @Corluk: I tried to avoid that because if you use single-sample rasterization rules, that pixel's not technically covered (it doesn't satisfy the top-left rule for triangles). \$\endgroup\$ Dec 22, 2014 at 23:45
  • \$\begingroup\$ Yeah, that was my point. I wanted to ask if the triangle was red and the pixels outside blue, that one would have the color (red + red +blue + blue) / 4. Am I right? \$\endgroup\$
    – cadaniluk
    Dec 22, 2014 at 23:50
  • \$\begingroup\$ Only FYI, I confused the Post button with a newline, so my now deleted comment was a bit shortened. \$\endgroup\$
    – cadaniluk
    Dec 22, 2014 at 23:52
  • \$\begingroup\$ @Corluk: Oh, okay. Yeah that is basically how it would work. Though the entire structure here is a pixel, and those circles are samples (I assume you mean that 2 samples are red and 2 are blue?). To get a final color for the pixel you take the average of all the samples that belong to it. \$\endgroup\$ Dec 22, 2014 at 23:59
0
\$\begingroup\$

Color is computed for a zero-dimensional point. A zero-dimensional point is nice because you can say it is definitely either inside or outside a particular polygon.

A pixel occupies some small square (usually) area. Typically, a single point is sampled for each screen pixel, such as from the (0.5, 0.5) position within that pixel, and that value is used for the whole pixel.

Supersampling means to do that computation for more than one such point within each pixel's area, and then averaging the results appropriately. This has the effect of smoothing edges, since the pixel won't have to be "all or nothing" for the edge of a polygon that passes through it.

...hopefully the WP article will make more sense now!

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .