Previous | Next --- Slide 22 of 58
Back to Lecture Thumbnails
kayvonf

A common question is: What is the difference between a fragment and a pixel?

This is a far more complicated question that it might seem. And I'd likely to defer a full answer under after we talk about sampling in the upsampling rasterization lecture.

But here is a high-level explanation that will suffice for now:

Sending commands to the graphics pipeline architecture results in changes to the rendered output image, which is often called the "render target" or the "color buffer". As a data structure, an image is just an array of pixels. The number of pixels in the frame buffer is fixed -- it's defined by the size of the output image.

A fragment is not a pixel.

A fragment is an element in the stream flowing out of the rasterization stage. That is, fragments are generated by rasterization, processed by fragment processing stage (which computes a color for the fragment), and then used to update the output image in the "frame-buffer ops" stage.

As we will discuss in the rasterization lecture, the rules of the pipeline are very precise about how the rasterizer generates fragments from an input triangle. However, for now, assume that one fragment is generated for each pixel the triangle overlaps. Therefore, a fragment corresponds to a small piece of the surface that covers a pixel. (I'll make the proper connection to signal processing and sampling later.) That piece is represented in the pipeline by a struct that maintains the (x,y) position of the corresponding pixel, the depth of the surface at this location, and other fields that hold the values of surface properties at this location (surface normal, texture coordinate values, etc.)

Since a fragment represents a small piece of a drawn surface, the number of fragments created when rendering an image depends on how many triangles are drawn, and how big on screen those triangles are. For example, if a scene contains 100 overlapping triangles, then it's possible that 100 fragments get generated at a single pixel location. Of course only one of those fragments will ultimately be visible at the pixel (the one from the closest triangle). The logic for determining which fragment is closest is performed by the "frame-buffer ops" stage in my graphics pipeline illustrations.