i
i
i
i
i
i
i
i
156 7. The Rendering Pipeline
screen coordinates. For example, in the real world, when we use a camera,
we create a 2D picture of the 3D world. Likewise, in the virtual world, we
now need to create a 2D image of what our virtual camera can see based on
its viewpoint within the 3D environment. 3D coordinate geometry allows us
to do this by using a projective transformation, where a ll the 3D coordinates
are transformed to their respective 2D locations within the image array. The
intricacies of this are detailed in Section 6.6.7. This process only affects the
3D y- and z-coordinates (again assuming the viewing direction is along the
x-axis). The new 2D (X , Y )-coordinates, along with the 3D x-coordinate, are
then passed on to the next stage of the pipeline.
7.4 Scan Conversion or Rasterization
At the next stage, the visible primitives (points, lines, or polygons) are de-
composed into smaller units corresponding to pixels in the destination frame
buffer. Each of these smaller units generated by rasterization is referred to
as a fragment. For instance, a line might cover five pixels on the screen, and
the process of rasterization converts the line (defined by two vertices) into five
fragments. A fragment is comprised of a frame buffer coordinate, depth infor-
mation and other associated attributes such as color, texture coordinates and
so on. The values for each of these attributes are determined by interpolating
between the values specified (or computed) at the vertices of the primitive.
Remember that in the first stage of the graphics pipeline, attributes are only
assigned on a per-vertex basis.
So essentially, this stage of the pipeline is used to determine which frag-
ments in the frame buffer are covered by the projected 2D polygons. Once it
is decided that a given fragment is covered by a polygon, that fragment needs
to be assigned its attributes. This is done by linearly interpolating the at-
tributes assigned to each of the corresponding 3D vertex coordinates for that
polygoninthegeometry and vertex operations stage of the graphics pipeline.
Now, if w e simply worked through the list of polygons sequentially and
filled in the appropriate fragments with the attributes assigned to them, the
resulting image would look very strange. This is because if the second sequen-
tial polygon covers the same fragment as the first then all stored information
about the first polygon would be overwritten for that fragment. Therefore,
as the second polygon is considered, we need to know the 3D x-coordinate
of the relevant vertex and determine if it is in front or behind the previous
x-coordinate assigned to that fragment. If it is in front of it, a new attribute