0
101 Aug 06, 2005 at 05:56

I’m trying to understand what multisampling breaks down into. What exactly is a single sample?

Supersampling basically renders the image at a greater resolution, then shrinks the image down to the selected resolution.

From what I’ve read, multisampling doesn’t appear to work like that.

Basically, from what I’ve been able to determine, a single AA sample is the average color of a 1-pixel block consisting of 4 sub-pixels (a 2-by-2 block). The act of downfiltering determines the average and returns the actual color that will be applied to the 1-pixel block.

Now, take a look at nVidia’s multisampling here: http://www.hothardware.com/image_popup.cfm…ticleid=707&t=a

4x AA is the building block for all the other AA modes, which is actually composed of 4 individual AA samples.

Mathematically speaking, this doesn’t make much sense to have 4 1-pixel blocks crammed into a single pixel. Something doesn’t jive here. :huh:

What pieces of information am I missing, and/or what have I interpreted incorrectly? I’m throughly confused.

Also, what exactly is a “texture sample”?

#### 11 Replies

0
167 Aug 06, 2005 at 06:25

The main difference is that in multisampling, there is only one texture value for the whole pixel no matter how many depth/stencil samples there are. So you have effectively the depth and stencil buffers at a higher resolution than the color buffer, resulting in automatic antialiasing into the color buffer.

Also, multisampling is very careful to specify that there are multiple samples per pixel, but their relative locations are not queriable by the application. Thus, hardware vendors are free to implement multisampling using whichever supersampling pattern seems best to them. For instance, 2X multisampling could use a sample in the center of each pixel and a sample in one of its corners, resulting in a staggered grid pattern, while 4X multisampling can use the rotated grid pattern shown in that diagram.

0
101 Aug 06, 2005 at 06:48

So the texture sample determines bump mapping?

Ok, but that didn’t really fully answer my question, though. What is the definintion of a single sample for multisampling?

I’m trying to figure out what the building blocks of this technique are.

Now, the link I provided doesn’t make much sense to me because it is a 4-by-4 block, rather than a 2-by-2 block. From what I read, there are 4 subpixels to a single pixel (a 2-by-2 block), and this image shows that there are 16…and I am confused. :huh:

Also…I thought pixels could only contain a single solid color. With these subpixels, is there oversampling going on?

0
167 Aug 07, 2005 at 03:58

A sample is a depth value, stencil value, and color value that has a specific screen-space location. Normally there is just one sample for each pixel, but in multisampling there are (obviously) multiple samples in each pixel. When you display this on the screen, the color values of the samples are averaged to get the color to display on the screen pixel.

So it is basically like supersampling, but there is a caveat: the pixel shader is only executed once for each pixel, not for each sample. So you have the same output color being assigned to all the samples in the pixel that are covered up by the triangle being drawn. E.g. if you draw a triangle that only covers 2 of 4 samples, then those 2 sample colors are set to the color output from the pixel shader, and the other 2 are unchanged. The 2 samples also get the same stencil value. The only thing that is different between them is the depth value.

The diagram you posted shows multisampling with 4 samples in a pixel. The 4x4 grid is irrelevant, it is only drawn to show the locations of the 4 samples within the pixel (as mentioned earlier, they are in a rotated grid pattern). There are only 4 samples, not 16.

0
101 Aug 07, 2005 at 05:32

ok, so it’s supersampling in what way? Is the image rendered at an increased resolution, sampled, then reduced?

now, are these subpixels actually pieces of a pixel, or are they actually pixels at the higher resolution before reduction?

0
167 Aug 08, 2005 at 05:31

@Force Flow

Is the image rendered at an increased resolution, sampled, then reduced? [snapback]19732[/snapback]

Just a note, but rendering IS sampling. You’re taking a continuous function (the color of the image in screen space) and picking discrete points (samples) out of it. Normally you pick one sample in the center of each pixel. Supersampling would increase the number of pixels and then average adjacent pixels to go back down to the original size. Multisampling is not supersampling: in multisampling, you put multiple samples in each pixel, but it is not the same thing as rendering at a higher resolution. The samples can be arbitrarily located within the pixel and indeed, their locations can differ between one pixel and another.
@Force Flow

now, are these subpixels actually pieces of a pixel, or are they actually pixels at the higher resolution before reduction?

There’s no difference.

However, samples are just points, they do not represent an area.

0
101 Aug 08, 2005 at 13:14

Ok, one thing that doesn’t make sense to me…aren’t pixels one solid color? What would be the point of sampling a pixel multiple times if it is one solid color?

0
167 Aug 08, 2005 at 18:22

A pixel represents a small area on the screen. That area might have two or more colors within it - for example if a gray triangle is drawn and only crosses the left half of the pixel, and a blue triangle is drawn that only crosses the pixel’s right half.

However, our screens can only display one color per pixel, so we want to pick a color that averages out all the colors that should be in the pixel. But how do we know what color to use? Ordinary (non-multisample) rendering picks the color at the center point of the pixel. But that is just one point - it would be either gray or blue, depending on which triangle covered that point. This single sampling leads to jaggies where one pixel is gray and the one next to it is blue. Multisampling tries to get a better estimate for the color that the pixel should be, by placing several samples within it. Each of those samples is just one point, but because they are distributed over the area of the pixel, some of them will be gray and some will be blue. Then the colors of the samples can be averaged to arrive at one single gray-blue color to be displayed for the whole pixel.

So to sum up, pixels are areas, while samples are points. We want to find the average color of the whole pixel, but we are only able to find the color at discrete points. Multisampling allows us to find colors of several points within the pixel, and then average them to estimate the color of the whole pixel.

0
101 Aug 09, 2005 at 23:28

oh wow! That is such a great explaination!

Now the theory behind sampling doesn’t look complicated at all :)

One more question, though. What is the purpose of a texture sample?

0
167 Aug 10, 2005 at 01:53

I guess that the purpose of a texture sample is to speed things up a little bit. If it were true supersampling, then when you draw a triangle that covers all four of the samples within a pixel, it would have to execute the pixel shader four times, doing four different texture fetches. But with multisampling it only does the pixel shader/texture fetch once and uses that value for all the samples in the pixel. In other words the pixel shader isn’t aware of the multisampling, it just pretends that there is one sample at the center of the pixel (the texture sample) and goes about its business.

0
101 Aug 10, 2005 at 04:03

ok, that makes sense.

Especially when comparing nVidia’s 4xAA to 8xS AA

Thanks for all your help! I really appreciate it! :)

0
167 Aug 11, 2005 at 18:47

No problem :)