WO1994010647A1 - Polygon rasterization - Google Patents

Polygon rasterization Download PDF

Info

Publication number
WO1994010647A1
WO1994010647A1 PCT/US1993/009754 US9309754W WO9410647A1 WO 1994010647 A1 WO1994010647 A1 WO 1994010647A1 US 9309754 W US9309754 W US 9309754W WO 9410647 A1 WO9410647 A1 WO 9410647A1
Authority
WO
WIPO (PCT)
Prior art keywords
edge
pixel
pixels
span
triangle
Prior art date
Application number
PCT/US1993/009754
Other languages
French (fr)
Inventor
Derek J. Lentz
David R. Kosmal
Glenn C. Poole
Original Assignee
Seiko Epson Corporation
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Seiko Epson Corporation filed Critical Seiko Epson Corporation
Priority to EP93923379A priority Critical patent/EP0667018B1/en
Priority to DE69312505T priority patent/DE69312505T2/en
Priority to KR1019950701768A priority patent/KR950704750A/en
Priority to JP51109794A priority patent/JP3356779B2/en
Publication of WO1994010647A1 publication Critical patent/WO1994010647A1/en

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T11/002D [Two Dimensional] image generation
    • G06T11/40Filling a planar surface by adding surface attributes, e.g. colour or texture
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06TIMAGE DATA PROCESSING OR GENERATION, IN GENERAL
    • G06T1/00General purpose image data processing

Definitions

  • the present invention relates generally to computer graphics, and more specifically, to a system and method for determining which pixels to render as part of a triangle in order to rasterize polygons.
  • Raster displays are commonly used in computer graphics systems. These displays store graphics images as a matrix of picture elements or "pixels" (also referred to as PELs) with data representing each pixel being stored in a display buffer. This data specifies the display attributes for each pixel on the screen such as the intensity and color of the pixel. An entire image is read from the display buffer and painted on the screen by sequentially scanning out horizontal rows of pixel data or "scan lines,” and using this data to control one or more electron beams (of course other display technologies can be used such as LCDs). This process of scanning pixel data out o the display buffer row-by-row is repeated every refresh cycle.
  • pixels also referred to as PELs
  • Raster display systems commonly use polygons as basic building blocks or "primitives” for drawing more complex images.
  • Triangles are a common basic primitive for polygon drawing systems, since a triangle is the simplest polygon and more complex polygons can always be represented as sets of triangles.
  • the process of drawing triangles and other geometric primitives on the screen is known as "rasterization.”
  • the rasterization of polygons is a problem fundamental to both two- dimensional and three-dimensional graphics systems. Most techniques that apply to the rasterization of triangles can be generalized for a polygon with any number o sides.
  • Rasterization systems generally step from pixel to pixel and determine whether or not to "render" (i.e., draw into a frame buffer or pixel map) each pixel as part of the triangle. This, in turn, determines how to set the data in the display buffer representing each pixel.
  • Various traversal algorithms have been developed for moving from pixel to pixel in a way such that all pixels within the triangle are covered.
  • Rasterization systems sometimes represent a triangle as a set of three edge functions.
  • An edge function is a linear equation representing a straight line, whic serves to subdivide a two-dimensional plane.
  • Edge functions classify each poin within the plane as falling into one of three regions: the region to the "left” of the line the region to the "right” of the line, or the region representing the line itself.
  • the typ of edge function which will be discussed has the property that points to the "left” o the line have a value greater than zero, points to the "right” have a value less tha zero, and points exactly on the line have a value of zero (this can be seen in Fig. 1)
  • the two-dimensional plane is represented by th graphics screen
  • points are represented by individual pixels
  • the edge functio serves to subdivide the graphics screen.
  • Triangles are created by the union of three edges, each of which are specified by edg functions. It is possible to define more complex polygons by using Boolea combinations of more than three edges. Since the rasterization of triangles involve determining which pixels to render, a tie-breaker rule is generally applied to pixel that lie exactly on any of the edges to determine whether the pixels are to b considered interior or exterior to the triangle.
  • Each pixel has associated with it a set of edge variables, (eO, el, e2), which represen the signed distance between the pixel and the three respective edges, as shown in Fi 2.
  • the value of each edge variable is determined for a given triangle by evaluatin the three edge functions, / ⁇ (x,y), /l(x,y) and /2(x,y) for the pixel location.
  • Edg variables can have fractional values, since an edge may fall between two adjacen pixels. It is convenient, therefore, to represent edge variables in fixed point 2' complement integer format.
  • typical rasterization system compute the values of the edge variables, (eo, ei, e2), for a given set of three edg functions and a given pixel position, and then use a set of increment value ( ⁇ e left, ⁇ eri t, etc.) to determine the edge variable values for adjacent pixels.
  • Th rasterization system traverses the triangle, adding the increment values to th current values as a traversal algorithm steps from pixel to pixel.
  • a pixel that i within the triangle bounds according to the pixel's three edge variable values (and an tie-breaker rules) will be rendered.
  • this vector and lin can be used to divide the two dimensional space into three regions: all points to th "left" of, to the "right” of, and exactly on the line.
  • the edge /(x,y) can be defined as:
  • This function has the useful property that its value is related to the position of th point (x,y) relative to the edge defined by the points (X,Y) and (X+dX, Y+dY):
  • th formula given for f(x,y) is the same as the formula for the magnitude of the cros product between the vector from (X,Y) to (X+dX, Y+dY), and the vector from (X,Y) t (x,y).
  • the magnitude is zero if th vectors are collinear, and changes sign as the vectors cross from one side to th other.
  • the edge function is related to the error value or "draw control variable" (DCV) i Bresenham line drawing algorithms described in "Algorithm for Computer Control o a Digital Plotter," Bresenham, J., IBM Systems Journal 4( l):25-30 (1965). Th difference is that Bresenham line drawing algorithms maintain the DCV value onl for pixels within 1/2 pixel of the line, while . (x,y) is defined for all pixels on the plane In addition, the value of the DCV at a given point differs from / (x,y) by a constan offset. In any case, the reason that both algorithms work is fundamentally th same.
  • Fig. 4 shows two simpl implementations of traversal algorithms. Traversing the bounding box is perhap the simplest strategy, as shown in Fig. 4(a), but generally not the most efficient.
  • smarter algorithm shown in Fig. 4(b) would advance to the next traversal line whe it "walks" off the edge of a triangle.
  • One complication of the smarter algorithm is tha when it advances to the next line, it may advance to a point inside the triangle. I that case, the algorithm must search for the outside of the edge before it begins th next scan line. An example of this problem is shown on the top right hand edge of th triangle in Fig. 5.
  • FIG. 6 An implementation of an even smarter algorithm is shown in Fig. 6. It proceeds dow from the starting point, working its way outward from a center line. The advantag of this algorithm over the simpler algorithm is that it never has to search for an edge then double back. The tradeoff is that the interpolator state for the center line mus be saved while traversing the outer points, since the interpolators must be restarte back at the center line. Notice that at the bottom, the "center" line shifts over if i ends up exterior to the triangle.
  • the present invention provides a system and method for the rasterization o polygons.
  • Each edge of the polygon e.g., a triangle
  • a linear edge function which classifies each pixel within the plane of the polygon.
  • pixels having a value greater than zero' are on one side of an edge and less than zero on the opposite side of an edge.
  • Each pixel within the plane of the polygon has associated with it a set of edge variables which represent the signed, horizontal distance between the pixel and the respective edges of the polygon.
  • a pixel is rendered based on the value of its edge variables which are generated with reference to the edge functions.
  • the present invention allows the edge functions to be applied to a linear span o pixels. Initially, the value of a set of edge variables for a given pixel within a triangle is determined by evaluating the three edge functions associated with that triangle. In order to determine which pixels to render, the present invention generates a W-bit render mask based upon the values of these edge variables. The present invention allows these values to be applied to the span of pixels without the need to perform additional calculations for the remainder of the pixels within the span.
  • Fig. 1 illustrates the division of each point within a plane as falling into one o three regions.
  • Fig. 2 illustrates the association of a set of edge variables with a particula pixel.
  • Fig. 3 graphically illustrates a vector and line which represents an edge function which can be used to divide two dimensional space into three regions.
  • Fig. 4(a) and Fig. 4(b) show two simple algorithms for traversing the pixels within a given triangle.
  • Fig. 5 illustrates a solution to the problem shown in Figure 4(b).
  • Fig. 6 illustrates a sophisticated algorithm (relative to that shown in Figure 4) for traversing the pixels within a given triangle.
  • Fig. 7 is a block diagram of the scanning hardware used by the present invention.
  • Fig. 8 illustrates an edge variable broken into three fields of bits.
  • Fig. 9 illustrates an example of a triangle to be rendered.
  • Fig. 10 illustrates an example of a mask generation for a left edge.
  • Fig. 11a and Fig. lib show a flowchart of the polygon rasterization method.
  • Fig. 12 illustrates an example of a triangle that falls outside of a window.
  • the present invention provides a system and method for the rasterization o polygons.
  • the present invention requires less calculations to render pixels within a polygon than the conventional pixel-by-pixel method.
  • Each edge of a polygon e.g., a triangle
  • Each edge of a polygon is represented by a linear edge function that has a value greater than zero on one side of the edge and less than zero on the opposite side of the edge.
  • the present invention allows edge functions to be applied to a linear span of pixels while only requiring the edge function addition operations to be performed for one of the pixels within the span.
  • the initial computation values used for rasterization under the present invention i.e., rasterization using a single linear span
  • the current scan position (i.e., a predetermined pixel) in the traversal algorithm is represented by coordinates (x, y).
  • a set of edge variables eO, el, e2, represented in fixed-point 2's complement integer format, corresponding to three respective edge functions fO, fl, f2 (e.g. e0 fO(y) - x).
  • Each edge variable consists of an integer field (which includes a sign bit) and a fractional field.
  • a one-bit edge flag for each edge which specifies whether the edge is to be treated as a "right edge” or a "left edge” of the triangle.
  • a set flag specifies a right edge, indicating that pixels falling to the right side of th edge, and thus having a corresponding edge variable value greater than zero, are not within the triangle. Pixels having a negative value for a right edge may fall within the triangle.
  • a cleared flag indicates a left edge, and that only pixels with positive values may fall within the triangle.
  • the flag therefore, specifies how the values should be interpreted for a given edge.
  • an edge variable has a value of zero it is arbitrary whether it is considered inside the triangle or outside the triangle (provided that the decision is performed consistently).
  • a set flag indicates that the triangle is right-oriented, meaning that ei is a left edge and eo, e2 are right edges.
  • the flag is not set, the triangle is left-oriented and the edges are reversed. All triangles fit into one of these two cases.
  • a set of "step-values" for each edge variable (Deleft, Deright, etc.): The step-values are added to or subtracted from the values of the edge variables to determine the values at adjacent pixels.
  • Each edge variable has an increment value for any direction that the traversal wil scan. These are also fixed-point 2's complement integer values.
  • the present invention works with a span of pixels that are W pixels wide.
  • W can b any power of 2.
  • the dimensions of the span do not necessarily need to correspond t the blocks of data accessed by the memory system, although this will generall decrease memory bandwidth usage.
  • the scanning hardware used by the present invention is divide into three parts: (1) a simple integer datapath 710; (2) a pixel mask generation uni 720; and (3) a rendering unit 730.
  • Integer datapath 710 is a simple straightforwar unit that contains registers for the computation values, one or more adder/subtracte units, and appropriate control logic.
  • the integer datapath 710 contain hardware for generating the edge variables for each edge in the triangle bein rendered.
  • Pixel mask generation unit 720 determines which pixels within a span of pixels are to be rendered by generating a pixel mask based upon the value of the edg variables provided by integer datapath 710.
  • This unit generates a separate mask referred to as a rendering mask, for each edge variable and produces the logical AN of the three masks as a final output (i.e. rendering mask 725).
  • rendering mask 725 a separate mask referred to as a rendering mask
  • Only two masks are used to produce the renderin mask 725.
  • Each bit in the rendering mask represents an individual pixel on the screen.
  • Rendering unit 730 takes the rendering mask 725 from the mask generatio unit 720 and issues commands 735 to the memory system for each pixel to be eithe rendered or not.
  • the system In order to determine which pixels to render, the system generates a W-bit render- mask 725 based upon the values of the edge variables for a single pixel (i.e., the firs pixel in the span of pixels). Bits that are set in the render-mask indicate which pixels are to be rendered as part of the triangle. To determine the respective render-mas bit for a given pixel, three edge-mask bits are generated (as described in the Background section), each indicating whether the pixel falls on the triangle side of one of the three respective edges. The render-mask bit is then generated by logicall ANDing the three edge-mask bits.
  • Each render-mask which consists of a string of W bits, consists of the render-mask bit for the pixel a position (x, y), and the render-mask bits for the next W-l pixels in the horizontal row. It should be noted that the present invention could readily be applied using vertical distances between the pixels and the edges of the triangle instead of horizontal distances.
  • the third field consists of the span-position bits, whic are the remaining bits in the integer part of the edge variable.
  • Fig. 8 shows these fields for a span of 4 bits.
  • the fractional portion is not used in for mas generation. Rather it is used to maintain accuracy when incrementing the edge variables.
  • the three bit fields of the edge variable value are used to determine whether or no the corresponding pixel falls on the triangle side of the edge. Additionally, these sam three fields are used to determine whether each of the other W-l pixels of the horizontal span falls on the triangle side of the edge.
  • the values of the edg variables are interpreted differently for left and right edges, but the general idea is the same for both.
  • Tables 1 and 2 show the masks generated for left and right edges.
  • Fig. shows an example of a pixel grid with a triangle to be rendered contained therein. Th three vertices are the points (5, 2), (2, 15), and (14, 11). These vertices form thre edges, indicated in the diagram as eo ei, and e2- This particular example is a righ oriented triangle, since two edges, eo and e2, form the boundaries of the right side o the triangle and only one edge forms the boundary of the left side. A left oriente triangle has two left and one right edge.
  • the pixel grid is divided into spans that are pixels wide. However, once again, any span that is a power of 2 is acceptable for th pixel-span mechanism described later.
  • Tables 1 and 2 are based upon the definition of edge variables as the horizonta distance between a pixel and the edge.
  • Fig.10 shows different values of the edg variable for a left edge at various pixel positions.
  • a negative valu indicates that the current pixel and all pixels to the right are within the bounds of th edge (span a).
  • the edge variable associated with span a equals -2.1 (binar 1...1110).
  • the mask for all left edge variables with a negative value is 1111. In othe words, this mask indicates that all the pixels in the span should be rendered. If the left edge is non-negative, there are two cases to consider. The first is when the value of the edge variable is less than w (span b).
  • the span bits will be all zeros and the sub-span bits are used to determine which bits in the mask are set.
  • the sub-span bits can be equal to either 00, 01, 10, or 11.
  • the edge variable for b equals 1.4 (binary 0...0001).
  • the sub-span position bits are 01, and thus the mask is 0011. In other words, this mask represents the fact that the two right most pixels in the mask should be rendered.
  • the second case of a non-negative value of an edge variable is when the value is greater than or equal to w (span c).
  • the span position bits will be nonzero.
  • the resulting mask should thus indicate that all the pixels represented in the mask should not be rendered since all the pixels in the span are to the left of the edge.
  • the edge variable for span c equals 5.1 (binary 0...0101). Consequently, all the bits in the mask will be zero (i.e., 0000).
  • the mask generation table for right edges is determined in a similar fashion.
  • Fig. 11 illustrates a flowchart of the operation of the pixel-span technique. Given a triangle to be rendered, a starting pixel is selected, as shown in step 1110. Three edge variables are generated corresponding to the selected pixel, as shown in step 1115.
  • the edge that is used as the right boundary will depend upon the value of y. l ⁇ y is above the vertex joining the two right edges, then the upper right edge is used. Otherwise the bottom right edge is used.
  • the two edges required to generate the rendering mask are selected.
  • Steps 1125 through 1170 represent the use of Tables 1 and 2. Note that these steps would be different depending on the size of the span used.
  • step 1125 the sign of the edge variable for the right edge is checked. If it is negative (symbolizing that the span is outside the triangle) then the Mask is set to 0000, as shown in step 1130.
  • step 1135 the span position bits are checked, as shown in step 1135. If the span position bits are non-zero (symbolizing that the span is inside the triangle) then the Mask is set to 1111, as shown in step 1140. Otherwise, the sub-span bits are checked, as shown in step 1145, and the appropriate mask is selected based on the value of these bits.
  • Steps 1150 through 1170 represent the generation of the mask for the left edge.
  • the steps are analogous to those described above for the right edge.
  • the resulting mask that determines which pixels to render is simply the logical AND of the mask created for the two edges (i.e., right edge and left edge), as shown in step 1175.
  • the rendering pixel mask is passed to the rendering unit 730 where the appropriate control signals are sent to the memory system for each pixel to be rendered, as shown in step 1185.
  • step 1185 an incremental value is added to the edge variable and the procedure can begin at step 1120 for the next pixel, where the next pixel is the first pixel after the span which falls within the path of the particular traversal algorithm being used.
  • Traversing the triangle can be done in a number of ways similar to conventional rasterization techniques described above.
  • a triangle to be rendered has a horizontal edge.
  • the present invention uses the remaining two edges (and not the horizontal edge), along with the procedure outlined above, to determine which pixels within a span of pixels are to be rendered.
  • the vertex will be either at the first span (e.g., when the horizontal edge is the top edge of the triangle) or the last span (e.g., when the horizontal edge is the bottom edge of the triangle). Consequently, only the two remaining edges are required to generate the pixel masks.
  • the present invention offers several advantages over conventional triangle rasterization techniques.
  • the number of arithmetic operations required for maintaining the edge variables during traversal is one set for every span of pixels. This is accomplished without using extra adder/subtracter hardware for each pixel.
  • Second, the present invention has a pipelined operation.
  • the integer datapath 710, the mask generation unit 720, and the rendering unit 730 can operate independently in a pipelined configuration. This allows parallel computation without extra hardware.
  • Third, the present invention is consistent with efficient memory architectures. Rendering pixels in horizontal spans allows easy implementation of traversal algorithms that are compatible with bloc organized pixel memories.
  • the first mechanism referred to as the single-pixel mechanism is a version of a conventionally used technique. It is described at this point in th document so that is may be clearly contrasted with the improved operation of th present invention, which is described immediately thereafter.
  • the present inventio is described second, and is referred to as the pixel-span method.
  • the pixel-spa technique can render triangles using fewer operations per pixel.
  • Triangle rendering utilizes a routine that traverses a superset of the pixels within th triangle and performs a test at each pixel to determine if it should be rendered
  • Methods for determining the order of traversal are not discussed here, but instea simple assumptions are made regarding the traversal algorithm as the example i described.
  • the decision to render a pixel is usually based on the set of edge variable that are updated at each pixel.
  • the edge variables will be denoted by eo ei, and e2
  • an edge variable is defined as the horizontal distance from th current pixel position in the scan and the line formed by the triangle edge. There ar many variations on how the edge variables can be defined, but all are generall derivatives of this general concept.
  • f(y) is a function that returns the x position of an edge for a given y
  • f(y) is called the edge function for the given edge, and is easily determined from the triangle coordinate using basic algebra.
  • the edge functions for the three edges are a follows:
  • edge variables the following interpretation of the value applies: If the edge variable is positive, the pixel (x, y) is to the left of the edge, if it i negative it is to the right of the edge, and if it is zero it is on the edge.
  • two of the edg variables are used; one defining the left boundary and one defining the right.
  • a pixel i within the bounds of a triangle if the edge variable associated with the pixel is non negative.
  • the edge variable is zero for a given pixel, it is arbitrary whether o not it is considered within the boundaries on the edge. It is useful for renderin adjacent triangles, however, if the case of a zero valued edge variable is treate differently for left and right edges (e.g., inside for right-edges and outside for lef edges).
  • the traversal algorithm begins the scan at some pixel and determines the value o the edge variables based upon the functions above. For the example, we will assum that the single-pixel traversal algorithm chooses the pixels (5, 2), the top vertex, a the start point. Therefore, the initial values of the edge variable are as follows:
  • e 0 is the right edge variable of interest for the initial pixel since the vertical position o the scan is above (14, 11) - the point where the two right edges meet.
  • Variable e l i the only left edge variable and thus will be used to test every pixel. For the initia pixel, the left edge variable is not negative, so this pixel is not rendered.
  • the traversal algorithm moves to another pixel, compute the values of the edge variables at this pixel, and perform the test to check if it i within the triangle boundaries. Movement from pixel to pixel during traversal i referred to as "stepping.”
  • the next. pixel in the traversal is usually adjacent to th previous pixel, which simplifies evaluation of the edge variables. Determining th value of the edge variables at an adjacent pixel is a matter of adding a constant t the current values since the edge functions are linear. These constants are referre to as increment values or step values.
  • the increment values for a step in th horizontal direction is always ⁇ 1, since the edge variable is defined as the horizonta distance between the pixel and the edge.
  • the increment values for a step in th vertical direction will be ⁇ m, when the edge function is in the form used above: f(y) my + c.
  • the increment values for each edge variable will b as follows:
  • the left edge variable, e l is negative and the right variable, e 0 is non- negative. This means that the pixel is within the triangle bounds and will be rendered.
  • the traversal continues stepping from pixel to pixel, adding the appropriate increment values to the edge variables and testing the values of the left and right boundaries. This must be done for at least every pixel in the triangle. The total number of pixels traversed will depend upon the efficiency of the particular traversal algorithm being used.
  • the pixel-span method is similar to the single-pixel method, except that it allows the rendering test to be performed for multiple pixels based upon one evaluation of the edge variables.
  • the mask generation unit 720 is used to indicate which pixels within a span to render. This information is represented by a mask of w bits; a one indicating the pixel should be rendered, a zero indicating it should not.
  • the mask represents pixels (w, y) through (x+w-ly).
  • computation of the rendering mask is the result of the logical AND of masks generated for the left and right edge that applies to the current pixel.
  • Mask generation uses the binary representation of the edge variables as shown by Tables 1 and 2, above.
  • the span position bits are the remaining bits excluding the sign bit The sign is the most significant bit as defined in 2's complement format.
  • a traversal algorithm for the pixel-span method behaves in basically the same wa as it would when using the single-pixel method. Two differences are that the pixel span traversal algorithm will move horizontally in steps of w pixels, and the startin x position must be a multiple of w. With this in mind, consider again the exampl triangle shown in Fig. 9. Now the traversal algorithm will start at pixel (4, 2) (a indicated by an X in Fig. 9), since 4 is a multiple of w . The value of the edge variable will be the following:
  • the traversal algorithm now steps down one span to pixel (4, 3).
  • the logical AND of these is 0110 s pixels (4,3) and (7,3) are not rendered since the values for these pixels in the mask i zero. However, pixels (5, 3) and (6,3) will be rendered since the values in the mask fo these pixels equal one.
  • the pixel-span method has advantages over the single-pixel technique because ther are fewer arithmetic operations per pixel rendered.
  • the single-pixel techniqu described above requires three addition operations per pixel as the traversa algorithm steps. (It is possible to reduce this for some pixels if the traversa algorithm is such that it renders all pixels that use eo as the right edge befor rendering any pixels that use e2 as the right edge (the "bottom half of the triangle) When rendering the bottom half, eo, would no longer need to be updated, thu requiring only two operations per pixel. However, the increase in efficiency is no always worth this added complexity in an actual implementation of graphic hardware.) Using the pixel-span method, the edge variables are only updated once fo every w pixels.
  • Fig. 12 illustrates an example of a windo 1210 and triangle 1220 in which a window bound mask generation routine is applied
  • part of the triangle 1220 falls outside of window 1210, an only those potions of the triangle that fall within the window need to be rendered.
  • I order to determine whether pixel span 1230 is within window 1210 a separate mas is generated for the edges of the window 1210.
  • mask is generated for edges 1240 and 1250. These masks are then ANDed with th rendering mask generated for triangle 1220.
  • the resulting window bound mask woul represent which pixels within span 1230 would be rendered.
  • the comple polygons can be broken into simpler polygons or triangles. Multiple sets of edges ca be used to rasterize the polygons. Specifically, additional masks would be generate for each edge of the polygon and the resulting masks would be ANDed together Alternatively, the complex polygons can be broken into multiple triangles and passes through the polygon rasterization hardware.

Abstract

The present invention provides a system and method for the rasterization of polygons. Each edge of the polygon (e.g., a triangle) is represented by a linear edge function which classifies each pixel within the plane of the polygon. In particular, pixels having a value greater than zero are on one side of an edge and less than zero on the opposite side of an edge. Each pixel within the plane of the polygon has associated with it a set of edge variables which represent the signed, horizontal distance between the pixel and the respective edges of the polygon. A pixel is rendered based on the value of a pixels edge variable which is generated with reference to the edge functions. The present invention allows the edge functions to be applied to a linear span of pixels. Initially, the value of a set of edge variables for a given pixel within a triangle is determined by evaluating the three edge functions associated with that triangle. In order to determine which pixels to render, the present invention generates a W-bit render mask based upon the values of these edge variables. The present invention allows these values to be applied to the span of pixels without the need to perform additional calculations for the remainder of the pixels within the span.

Description

POLYGON RASTERIZATION
BACKGROUND OF THE INVENTION
1. Field of Use
The present invention relates generally to computer graphics, and more specifically, to a system and method for determining which pixels to render as part of a triangle in order to rasterize polygons. 2. Related Art
Raster displays are commonly used in computer graphics systems. These displays store graphics images as a matrix of picture elements or "pixels" (also referred to as PELs) with data representing each pixel being stored in a display buffer. This data specifies the display attributes for each pixel on the screen such as the intensity and color of the pixel. An entire image is read from the display buffer and painted on the screen by sequentially scanning out horizontal rows of pixel data or "scan lines," and using this data to control one or more electron beams (of course other display technologies can be used such as LCDs). This process of scanning pixel data out o the display buffer row-by-row is repeated every refresh cycle.
Raster display systems commonly use polygons as basic building blocks or "primitives" for drawing more complex images. Triangles are a common basic primitive for polygon drawing systems, since a triangle is the simplest polygon and more complex polygons can always be represented as sets of triangles. The process of drawing triangles and other geometric primitives on the screen is known as "rasterization." The rasterization of polygons is a problem fundamental to both two- dimensional and three-dimensional graphics systems. Most techniques that apply to the rasterization of triangles can be generalized for a polygon with any number o sides.
An important part of rasterization involves determining which pixels fall within a given triangle. Rasterization systems generally step from pixel to pixel and determine whether or not to "render" (i.e., draw into a frame buffer or pixel map) each pixel as part of the triangle. This, in turn, determines how to set the data in the display buffer representing each pixel. Various traversal algorithms have been developed for moving from pixel to pixel in a way such that all pixels within the triangle are covered. Rasterization systems sometimes represent a triangle as a set of three edge functions. An edge function is a linear equation representing a straight line, whic serves to subdivide a two-dimensional plane. Edge functions classify each poin within the plane as falling into one of three regions: the region to the "left" of the line the region to the "right" of the line, or the region representing the line itself. The typ of edge function which will be discussed has the property that points to the "left" o the line have a value greater than zero, points to the "right" have a value less tha zero, and points exactly on the line have a value of zero (this can be seen in Fig. 1) Applied to rasterization systems, the two-dimensional plane is represented by th graphics screen, points are represented by individual pixels, and the edge functio serves to subdivide the graphics screen.
Triangles are created by the union of three edges, each of which are specified by edg functions. It is possible to define more complex polygons by using Boolea combinations of more than three edges. Since the rasterization of triangles involve determining which pixels to render, a tie-breaker rule is generally applied to pixel that lie exactly on any of the edges to determine whether the pixels are to b considered interior or exterior to the triangle.
Each pixel has associated with it a set of edge variables, (eO, el, e2), which represen the signed distance between the pixel and the three respective edges, as shown in Fi 2. The value of each edge variable is determined for a given triangle by evaluatin the three edge functions, /θ(x,y), /l(x,y) and /2(x,y) for the pixel location. Edg variables can have fractional values, since an edge may fall between two adjacen pixels. It is convenient, therefore, to represent edge variables in fixed point 2' complement integer format. Note that it can be determined whether or not a pixe falls within a triangle by looking at the signs of eo, ei and e2, if it is known whethe each edge is a "right" edge or a "left" edge of the triangle. Note that the signs of th edges can be reversed if desired.
In determining which pixels to render within a triangle, typical rasterization system compute the values of the edge variables, (eo, ei, e2), for a given set of three edg functions and a given pixel position, and then use a set of increment value (Δeleft,Δeri t, etc.) to determine the edge variable values for adjacent pixels. Th rasterization system traverses the triangle, adding the increment values to th current values as a traversal algorithm steps from pixel to pixel. A pixel that i within the triangle bounds according to the pixel's three edge variable values (and an tie-breaker rules) will be rendered. Systems having simple hardware generally perform these computations separatel for each pixel while more complex systems having more arithmetic units ma compute the values for multiple pixels simultaneously. Although parallel evaluatio of the edge variables for multiple pixels results in faster rasterization, the proces remains limited by the need to separately determine the edge variables for ever traversed pixel. An examination of an edge function which can be used to rasteriz triangles, and of various algorithms for traversing the triangle, will provide a bette understanding of the process described above. A detailed description of the use o edge functions and traversal algorithms can be found in "A Parallel Algorithm fo Polygon Rasterization," Pineda, J., Computer Graphics 22(4):17-20 (1988), which i incorporated by reference herein. Portions of the Pineda reference have bee substantially reproduced below for the convenience of the reader.
Consider, as shown in Fig. 3, a vector defined by two points: (X,Y) and (X+dX,Y+dY) and the line that passes through both points. As noted above, this vector and lin can be used to divide the two dimensional space into three regions: all points to th "left" of, to the "right" of, and exactly on the line.
The edge /(x,y) can be defined as:
/(x,y) = (x-X) dY - (y-Y) dX
This function has the useful property that its value is related to the position of th point (x,y) relative to the edge defined by the points (X,Y) and (X+dX, Y+dY):
/(x,y) > 0 if (x,y) is to the "right" side /(x,y) = 0 if (x,y) is exactly on the line /(x,y) < 0 if (x,y) is to the "left" side
To convince oneself that this is true, those skilled in the art will recognize that th formula given for f(x,y) is the same as the formula for the magnitude of the cros product between the vector from (X,Y) to (X+dX, Y+dY), and the vector from (X,Y) t (x,y). By the well known property of cross products, the magnitude is zero if th vectors are collinear, and changes sign as the vectors cross from one side to th other.
This function is commonly used by existing rasterization systems, since it can b computed incrementally by simple addition:
/(x+l,y) = flx,y) + dY
/(x,y+l) = flx.y) + dX The edge function is related to the error value or "draw control variable" (DCV) i Bresenham line drawing algorithms described in "Algorithm for Computer Control o a Digital Plotter," Bresenham, J., IBM Systems Journal 4( l):25-30 (1965). Th difference is that Bresenham line drawing algorithms maintain the DCV value onl for pixels within 1/2 pixel of the line, while . (x,y) is defined for all pixels on the plane In addition, the value of the DCV at a given point differs from / (x,y) by a constan offset. In any case, the reason that both algorithms work is fundamentally th same.
This same property of /(x,y) is used by the graphics system described in "PIXEL PLANES" graphics system, described in Fuchs, et al., VLSI Design (3rd Quarter):20 28 (1981), where this function is computed in parallel for all pixels in the frame buffe by a multiplier tree.
A variety of different traversal algorithms are presently used by differen rasterization systems in the rendering process. Any algorithm guaranteed to cove all of the pixels within the triangle can be used. Fig. 4 shows two simpl implementations of traversal algorithms. Traversing the bounding box is perhap the simplest strategy, as shown in Fig. 4(a), but generally not the most efficient. smarter algorithm, shown in Fig. 4(b), would advance to the next traversal line whe it "walks" off the edge of a triangle. One complication of the smarter algorithm is tha when it advances to the next line, it may advance to a point inside the triangle. I that case, the algorithm must search for the outside of the edge before it begins th next scan line. An example of this problem is shown on the top right hand edge of th triangle in Fig. 5.
An implementation of an even smarter algorithm is shown in Fig. 6. It proceeds dow from the starting point, working its way outward from a center line. The advantag of this algorithm over the simpler algorithm is that it never has to search for an edge then double back. The tradeoff is that the interpolator state for the center line mus be saved while traversing the outer points, since the interpolators must be restarte back at the center line. Notice that at the bottom, the "center" line shifts over if i ends up exterior to the triangle.
There are a number of different ways to traverse the pixels in the triangle. Th efficiency of each method depends upon the particular triangle being rendered. Man systems organize pixels in the memory in rectangular blocks. Some of thes systems then cache these blocks in a fast memory, similar to the way a CPU cache data and instructions. When used in conjunction with an appropriate traversa algorithm, this organization can improve performance by keeping memory accesse to a minimum. Regardless of the amount of hardware available or the method of traversing the pixels within the triangle, at least three addition operations must be performed per pixel when using the pixel-by-pixel method described above. These three additions correspond to the three increment values which must be added to the values of the edge variables, eo, ei and e2, to determine the respective values for an adjacent pixel, as discussed above. Thus, under present rasterization techniques, efficiency is limited by the number of calculations per pixel required to determine whether or no the pixel falls within the triangle. This limited efficiency translates into slower graphics display systems. A method for rendering triangles which reduces the number of calculations required per pixel is therefore required.
SUMMARY OF THE INVENTION
The present invention provides a system and method for the rasterization o polygons. Each edge of the polygon (e.g., a triangle) is represented by a linear edge function which classifies each pixel within the plane of the polygon. In particular, pixels having a value greater than zero' are on one side of an edge and less than zero on the opposite side of an edge. Each pixel within the plane of the polygon has associated with it a set of edge variables which represent the signed, horizontal distance between the pixel and the respective edges of the polygon. A pixel is rendered based on the value of its edge variables which are generated with reference to the edge functions.
The present invention allows the edge functions to be applied to a linear span o pixels. Initially, the value of a set of edge variables for a given pixel within a triangle is determined by evaluating the three edge functions associated with that triangle. In order to determine which pixels to render, the present invention generates a W-bit render mask based upon the values of these edge variables. The present invention allows these values to be applied to the span of pixels without the need to perform additional calculations for the remainder of the pixels within the span.
BRIEF DESCRIPTION OF THE DRAWINGS
The above and further advantages of this invention may be better understood by referring to the following description taken in conjunction with the accompanyin drawings, in which:
Fig. 1 illustrates the division of each point within a plane as falling into one o three regions. Fig. 2 illustrates the association of a set of edge variables with a particula pixel. Fig. 3 graphically illustrates a vector and line which represents an edge function which can be used to divide two dimensional space into three regions.
Fig. 4(a) and Fig. 4(b) show two simple algorithms for traversing the pixels within a given triangle. Fig. 5 illustrates a solution to the problem shown in Figure 4(b).
Fig. 6 illustrates a sophisticated algorithm (relative to that shown in Figure 4) for traversing the pixels within a given triangle.
Fig. 7 is a block diagram of the scanning hardware used by the present invention. Fig. 8 illustrates an edge variable broken into three fields of bits.
Fig. 9 illustrates an example of a triangle to be rendered.
Fig. 10 illustrates an example of a mask generation for a left edge.
Fig. 11a and Fig. lib show a flowchart of the polygon rasterization method.
Fig. 12 illustrates an example of a triangle that falls outside of a window.
In the drawings, like reference numbers indicate identical or functionally similar elements. Additionally, the left-most digit of the reference number identifies the drawing in which the reference number first appears.
DETAILED DESCRIPTION OF THE PRESENT INVENTION
The present invention provides a system and method for the rasterization o polygons. The present invention requires less calculations to render pixels within a polygon than the conventional pixel-by-pixel method. Each edge of a polygon (e.g., a triangle) is represented by a linear edge function that has a value greater than zero on one side of the edge and less than zero on the opposite side of the edge. The present invention allows edge functions to be applied to a linear span of pixels while only requiring the edge function addition operations to be performed for one of the pixels within the span. The initial computation values used for rasterization under the present invention (i.e., rasterization using a single linear span) are similar to those required for pixel-by-pixel rasterization. These are as follows:
• The current scan position (i.e., a predetermined pixel) in the traversal algorithm is represented by coordinates (x, y).
• A set of edge variables eO, el, e2, represented in fixed-point 2's complement integer format, corresponding to three respective edge functions fO, fl, f2 (e.g. e0=fO(y) - x). Each edge variable consists of an integer field (which includes a sign bit) and a fractional field. • A one-bit edge flag for each edge which specifies whether the edge is to be treated as a "right edge" or a "left edge" of the triangle. A set flag specifies a right edge, indicating that pixels falling to the right side of th edge, and thus having a corresponding edge variable value greater than zero, are not within the triangle. Pixels having a negative value for a right edge may fall within the triangle. A cleared flag indicates a left edge, and that only pixels with positive values may fall within the triangle. The flag, therefore, specifies how the values should be interpreted for a given edge. When an edge variable has a value of zero it is arbitrary whether it is considered inside the triangle or outside the triangle (provided that the decision is performed consistently).
It is possible to organize the edge variables so that only one flag is needed to interpret the edge variables. In this case, a set flag indicates that the triangle is right-oriented, meaning that ei is a left edge and eo, e2 are right edges. When the flag is not set, the triangle is left-oriented and the edges are reversed. All triangles fit into one of these two cases.
• A set of "step-values" for each edge variable (Deleft, Deright, etc.): The step-values are added to or subtracted from the values of the edge variables to determine the values at adjacent pixels. Each edge variable has an increment value for any direction that the traversal wil scan. These are also fixed-point 2's complement integer values.
The present invention works with a span of pixels that are W pixels wide. W can b any power of 2. The dimensions of the span do not necessarily need to correspond t the blocks of data accessed by the memory system, although this will generall decrease memory bandwidth usage.
Referring to Fig. 7, the scanning hardware used by the present invention is divide into three parts: (1) a simple integer datapath 710; (2) a pixel mask generation uni 720; and (3) a rendering unit 730. Integer datapath 710 is a simple straightforwar unit that contains registers for the computation values, one or more adder/subtracte units, and appropriate control logic. In particular, the integer datapath 710 contain hardware for generating the edge variables for each edge in the triangle bein rendered. Pixel mask generation unit 720 determines which pixels within a span of pixels are to be rendered by generating a pixel mask based upon the value of the edg variables provided by integer datapath 710. This unit generates a separate mask referred to as a rendering mask, for each edge variable and produces the logical AN of the three masks as a final output (i.e. rendering mask 725). As will be describe below, in a preferred embodiment only two masks are used to produce the renderin mask 725. Each bit in the rendering mask represents an individual pixel on the screen. Rendering unit 730 takes the rendering mask 725 from the mask generatio unit 720 and issues commands 735 to the memory system for each pixel to be eithe rendered or not.
In order to determine which pixels to render, the system generates a W-bit render- mask 725 based upon the values of the edge variables for a single pixel (i.e., the firs pixel in the span of pixels). Bits that are set in the render-mask indicate which pixels are to be rendered as part of the triangle. To determine the respective render-mas bit for a given pixel, three edge-mask bits are generated (as described in the Background section), each indicating whether the pixel falls on the triangle side of one of the three respective edges. The render-mask bit is then generated by logicall ANDing the three edge-mask bits. The resulting render-mask bit will be "1" if the pixel is to be rendered as part of the triangle, and "0" if it is not. Each render-mask, which consists of a string of W bits, consists of the render-mask bit for the pixel a position (x, y), and the render-mask bits for the next W-l pixels in the horizontal row. It should be noted that the present invention could readily be applied using vertical distances between the pixels and the edges of the triangle instead of horizontal distances. For each edge variable, there are three bit fields of interest in edge-mas generation. The first field is the sign bit. The second field consists of the sub-span position bits which are the N least-significant bits of the integer portion of the edge variable bits, where W=2^. The third field consists of the span-position bits, whic are the remaining bits in the integer part of the edge variable. Fig. 8 shows these fields for a span of 4 bits. The resulting edge variable is 16-bits having an intege portion of 8 bits and a fractional portion of 8 bits. Note that for W=4, the size of the sub-span field is N = W/2 = 2. The fractional portion is not used in for mas generation. Rather it is used to maintain accuracy when incrementing the edge variables.
The three bit fields of the edge variable value are used to determine whether or no the corresponding pixel falls on the triangle side of the edge. Additionally, these sam three fields are used to determine whether each of the other W-l pixels of the horizontal span falls on the triangle side of the edge. Of course, the values of the edg variables are interpreted differently for left and right edges, but the general idea is the same for both. Tables 1 and 2 show the masks generated for left and right edges. A span size of four (w=4) is used in this example, although this table is easil generalized for any span size that has a power of 2. In the tables it is assumed tha pixels on the triangle edge are inside the triangle for left edges and outside the triangl for right edges.
Figure imgf000011_0001
The generation of these tables is described with reference to Fig. 9 and Fig. 10. Fig. shows an example of a pixel grid with a triangle to be rendered contained therein. Th three vertices are the points (5, 2), (2, 15), and (14, 11). These vertices form thre edges, indicated in the diagram as eo ei, and e2- This particular example is a righ oriented triangle, since two edges, eo and e2, form the boundaries of the right side o the triangle and only one edge forms the boundary of the left side. A left oriente triangle has two left and one right edge. The pixel grid is divided into spans that are pixels wide. However, once again, any span that is a power of 2 is acceptable for th pixel-span mechanism described later.
Tables 1 and 2 are based upon the definition of edge variables as the horizonta distance between a pixel and the edge. Fig.10 shows different values of the edg variable for a left edge at various pixel positions. For a left edge, a negative valu indicates that the current pixel and all pixels to the right are within the bounds of th edge (span a). The edge variable associated with span a equals -2.1 (binar 1...1110). The mask for all left edge variables with a negative value is 1111. In othe words, this mask indicates that all the pixels in the span should be rendered. If the left edge is non-negative, there are two cases to consider. The first is when the value of the edge variable is less than w (span b). In this case, the span bits will be all zeros and the sub-span bits are used to determine which bits in the mask are set. The sub-span bits can be equal to either 00, 01, 10, or 11. There are four possibilities since there are four pixels represented in the mask. Each possibility represents a different set of pixels which need to be rendered. In the example shown, the edge variable for b equals 1.4 (binary 0...0001). The sub-span position bits are 01, and thus the mask is 0011. In other words, this mask represents the fact that the two right most pixels in the mask should be rendered.
The second case of a non-negative value of an edge variable is when the value is greater than or equal to w (span c). Here the span position bits will be nonzero. The resulting mask should thus indicate that all the pixels represented in the mask should not be rendered since all the pixels in the span are to the left of the edge. In the example, the edge variable for span c equals 5.1 (binary 0...0101). Consequently, all the bits in the mask will be zero (i.e., 0000). The mask generation table for right edges is determined in a similar fashion.
Fig. 11 illustrates a flowchart of the operation of the pixel-span technique. Given a triangle to be rendered, a starting pixel is selected, as shown in step 1110. Three edge variables are generated corresponding to the selected pixel, as shown in step 1115.
In order to determine whether a pixel should be rendered, only two of the three edges must be utilized. Namely, one right edge and one left edge. If, for example, the triangle under consideration has two right edges (i.e., a right oriented triangle), the edge that is used as the right boundary will depend upon the value of y. lϊy is above the vertex joining the two right edges, then the upper right edge is used. Otherwise the bottom right edge is used. As shown in step 1120, the two edges required to generate the rendering mask are selected.
Steps 1125 through 1170 represent the use of Tables 1 and 2. Note that these steps would be different depending on the size of the span used. As shown in step 1125, the sign of the edge variable for the right edge is checked. If it is negative (symbolizing that the span is outside the triangle) then the Mask is set to 0000, as shown in step 1130. Next, the span position bits are checked, as shown in step 1135. If the span position bits are non-zero (symbolizing that the span is inside the triangle) then the Mask is set to 1111, as shown in step 1140. Otherwise, the sub-span bits are checked, as shown in step 1145, and the appropriate mask is selected based on the value of these bits. Steps 1150 through 1170 represent the generation of the mask for the left edge. The steps are analogous to those described above for the right edge. The resulting mask that determines which pixels to render is simply the logical AND of the mask created for the two edges (i.e., right edge and left edge), as shown in step 1175. The rendering pixel mask is passed to the rendering unit 730 where the appropriate control signals are sent to the memory system for each pixel to be rendered, as shown in step 1185.
In parallel with step 1185, an incremental value is added to the edge variable and the procedure can begin at step 1120 for the next pixel, where the next pixel is the first pixel after the span which falls within the path of the particular traversal algorithm being used.
Traversing the triangle can be done in a number of ways similar to conventional rasterization techniques described above. When traversing in a horizontal direction the datapath must compute the edge values for the pixel at position (x±w, y). This can be done using the horizontal step values for a single pixel shifted left by n bits, where w=2n. This does not require shifter hardware, but simply a multiplexer that selects either the shifted or unshifted value.
Occasionally, a triangle to be rendered has a horizontal edge. In these cases, the present invention uses the remaining two edges (and not the horizontal edge), along with the procedure outlined above, to determine which pixels within a span of pixels are to be rendered. In other words, since only two edges are used to determine whether a pixel should be rendered and there is only one right edge and one left edge, there is no need to check the value of y to determine whether it is above or below the vertex joining two right or left edges. In the case of a triangle with a horizontal edge, the vertex will be either at the first span (e.g., when the horizontal edge is the top edge of the triangle) or the last span (e.g., when the horizontal edge is the bottom edge of the triangle). Consequently, only the two remaining edges are required to generate the pixel masks.
The present invention offers several advantages over conventional triangle rasterization techniques. First, fewer computations per pixel are required. The number of arithmetic operations required for maintaining the edge variables during traversal is one set for every span of pixels. This is accomplished without using extra adder/subtracter hardware for each pixel. Second, the present invention has a pipelined operation. The integer datapath 710, the mask generation unit 720, and the rendering unit 730 can operate independently in a pipelined configuration. This allows parallel computation without extra hardware. Third, the present invention is consistent with efficient memory architectures. Rendering pixels in horizontal spans allows easy implementation of traversal algorithms that are compatible with bloc organized pixel memories.
Below is a description of two mechanisms for rasterization of triangles in graphic hardware systems. The first mechanism, referred to as the single-pixel mechanism is a version of a conventionally used technique. It is described at this point in th document so that is may be clearly contrasted with the improved operation of th present invention, which is described immediately thereafter. The present inventio is described second, and is referred to as the pixel-span method. The pixel-spa technique can render triangles using fewer operations per pixel.
Single-Pixel Method
Triangle rendering utilizes a routine that traverses a superset of the pixels within th triangle and performs a test at each pixel to determine if it should be rendered Methods for determining the order of traversal are not discussed here, but instea simple assumptions are made regarding the traversal algorithm as the example i described. The decision to render a pixel is usually based on the set of edge variable that are updated at each pixel. The edge variables will be denoted by eo ei, and e2 In this discussion, an edge variable is defined as the horizontal distance from th current pixel position in the scan and the line formed by the triangle edge. There ar many variations on how the edge variables can be defined, but all are generall derivatives of this general concept.
If f(y) is a function that returns the x position of an edge for a given y, then the valu of the edge variable e, at pixel (x, y) is defined as e = f(y) - x. f(y) is called the edge function for the given edge, and is easily determined from the triangle coordinate using basic algebra. In the example, the edge functions for the three edges are a follows:
Figure imgf000014_0001
fliy) = 3y + 47
Using our definition for the edge variables, the following interpretation of the value applies: If the edge variable is positive, the pixel (x, y) is to the left of the edge, if it i negative it is to the right of the edge, and if it is zero it is on the edge. In order t determine whether the pixel is within the bounds of the triangle, two of the edg variables are used; one defining the left boundary and one defining the right. A pixel i within the bounds of a triangle if the edge variable associated with the pixel is non negative. When the edge variable is zero for a given pixel, it is arbitrary whether o not it is considered within the boundaries on the edge. It is useful for renderin adjacent triangles, however, if the case of a zero valued edge variable is treate differently for left and right edges (e.g., inside for right-edges and outside for lef edges).
In the example, there are two edges defining right boundaries since it is a righ oriented triangle. The triangle under consideration is a right oriented triangle an thus has two right edges. Since y is above the vertex joining the two right edges, th upper right edge is used.
The traversal algorithm begins the scan at some pixel and determines the value o the edge variables based upon the functions above. For the example, we will assum that the single-pixel traversal algorithm chooses the pixels (5, 2), the top vertex, a the start point. Therefore, the initial values of the edge variable are as follows:
eo = 0 ei = 0 e2 = 36
e0 is the right edge variable of interest for the initial pixel since the vertical position o the scan is above (14, 11) - the point where the two right edges meet. Variable el i the only left edge variable and thus will be used to test every pixel. For the initia pixel, the left edge variable is not negative, so this pixel is not rendered.
In a single-pixel method, the traversal algorithm moves to another pixel, compute the values of the edge variables at this pixel, and perform the test to check if it i within the triangle boundaries. Movement from pixel to pixel during traversal i referred to as "stepping." The next. pixel in the traversal is usually adjacent to th previous pixel, which simplifies evaluation of the edge variables. Determining th value of the edge variables at an adjacent pixel is a matter of adding a constant t the current values since the edge functions are linear. These constants are referre to as increment values or step values. The increment values for a step in th horizontal direction is always ± 1, since the edge variable is defined as the horizonta distance between the pixel and the edge. The increment values for a step in th vertical direction will be ± m, when the edge function is in the form used above: f(y) my + c. For the example triangle the increment values for each edge variable will b as follows:
Figure imgf000016_0001
In our example, we will assume the traversal algorithm steps (5, 3), the pixel below the current one. The new value of the edge variables will be as follows: eo = eo + Qdown = 1 e1 = e1 + eldown = -0.231 e2 = e2 + ^2down = 66
For pixel (5, 3), the left edge variable, el,is negative and the right variable, e0 is non- negative. This means that the pixel is within the triangle bounds and will be rendered.
The traversal continues stepping from pixel to pixel, adding the appropriate increment values to the edge variables and testing the values of the left and right boundaries. This must be done for at least every pixel in the triangle. The total number of pixels traversed will depend upon the efficiency of the particular traversal algorithm being used.
Pixel-Span Method
The pixel-span method is similar to the single-pixel method, except that it allows the rendering test to be performed for multiple pixels based upon one evaluation of the edge variables. The method operates on pixels that are grouped into horizontal spans w bits wide (the example uses w = 4). This technique interprets edge variables and increment values in the same way as the single-pixel method except the traversal algorithm will step horizontally in units of w, so the left/right increment values will be ± w instead of ± 1.
When determining which pixels should be rendered, the mask generation unit 720 is used to indicate which pixels within a span to render. This information is represented by a mask of w bits; a one indicating the pixel should be rendered, a zero indicating it should not. The mask represents pixels (w, y) through (x+w-ly). As discussed above, computation of the rendering mask is the result of the logical AND of masks generated for the left and right edge that applies to the current pixel.
Mask generation uses the binary representation of the edge variables as shown by Tables 1 and 2, above. In the tables, the sub-span position bits are the n least significant bits of the binary representation of the integer part of the edge variable where w = 2n. The span position bits are the remaining bits excluding the sign bit The sign is the most significant bit as defined in 2's complement format.
A traversal algorithm for the pixel-span method behaves in basically the same wa as it would when using the single-pixel method. Two differences are that the pixel span traversal algorithm will move horizontally in steps of w pixels, and the startin x position must be a multiple of w. With this in mind, consider again the exampl triangle shown in Fig. 9. Now the traversal algorithm will start at pixel (4, 2) (a indicated by an X in Fig. 9), since 4 is a multiple of w . The value of the edge variable will be the following:
eθ = l n = ι
62 = 37
Using Tables 1 and 2, we determine the mask for the left edge variable, eo, to be 001 and the right edge, ei, to be 1100. The logical AND of these two masks is 0000 an therefore no pixels are to be rendered.
The traversal algorithm now steps down one span to pixel (4, 3). The new values fo the edge variables of interest will be e0 = 2 and ei = 0.769. This produces th respective left and right masks 1110 and 0111. The logical AND of these is 0110 s pixels (4,3) and (7,3) are not rendered since the values for these pixels in the mask i zero. However, pixels (5, 3) and (6,3) will be rendered since the values in the mask fo these pixels equal one.
The pixel-span method has advantages over the single-pixel technique because ther are fewer arithmetic operations per pixel rendered. The single-pixel techniqu described above requires three addition operations per pixel as the traversa algorithm steps. (It is possible to reduce this for some pixels if the traversa algorithm is such that it renders all pixels that use eo as the right edge befor rendering any pixels that use e2 as the right edge (the "bottom half of the triangle) When rendering the bottom half, eo, would no longer need to be updated, thu requiring only two operations per pixel. However, the increase in efficiency is no always worth this added complexity in an actual implementation of graphic hardware.) Using the pixel-span method, the edge variables are only updated once fo every w pixels. This is accomplished with the aid of mask generation unit 720 whic produces the mask values representing a pixel span. This function unit can be easil implemented using simple combinatorial logic as should be readily apparent to thos skilled in the art. The present invention can also integrate a window clipping routine with the polygo rasterization techniques described above. Fig. 12 illustrates an example of a windo 1210 and triangle 1220 in which a window bound mask generation routine is applied In the example shown, part of the triangle 1220 falls outside of window 1210, an only those potions of the triangle that fall within the window need to be rendered. I order to determine whether pixel span 1230 is within window 1210 a separate mas is generated for the edges of the window 1210. In the example shown in Fig. 12 mask is generated for edges 1240 and 1250. These masks are then ANDed with th rendering mask generated for triangle 1220. The resulting window bound mask woul represent which pixels within span 1230 would be rendered.
Finally, hardware can be generalized for more complex polygons. The comple polygons can be broken into simpler polygons or triangles. Multiple sets of edges ca be used to rasterize the polygons. Specifically, additional masks would be generate for each edge of the polygon and the resulting masks would be ANDed together Alternatively, the complex polygons can be broken into multiple triangles and passe through the polygon rasterization hardware.
While the invention has been particularly shown and described with reference t preferred embodiments thereof, it will be understood by those skilled in the art tha various changes in form and details may be made therein without departing from th spirit and scope of the invention.

Claims

CLAIMS What is claimed is:
1. A computer-based method for determining which pixels to render as part of a triangle in order to rasterize polygons, the method comprising the steps of: (1) generating, for the three edges of the triangle, three edge variables each o which indicate whether a first pixel falls inside or outside a triangle;
(2) generating three masks based upon the values of said edge variables, said masks are representative of a span of pixels, wherein the first pixel in said span o pixels is said first pixel; and (3) logically ANDing said three masks to produce a render-mask which represents which pixels within said span of pixels should be rendered.
2. The method of claim 1, further comprising the steps of: traversing the triangle to a next pixel located after said span of pixels; adding an incremental value to said edge variables; and repeating steps (2) and (3).
3. The method of claim 1, wherein said render-mask, which consists of a string of W bits, has a render-mask bit for the pixel at position (x, y), and render-mask bits for the next W-l pixels in the horizontal row.
4. The method of claim 1, wherein each of said edge variables contain a sign bit, span position bits, and sub-span position bits; and wherein said step (2) of generating comprises the step of providing a mask that indicates that all the pixels in said span should not be rendered if said sign bit is negative.
5. The method of claim 1, wherein each of said edge variables contain a sign bit, span position bits, and sub-span position bits; and wherein said step (2) of generating comprises the step of providing a mask that indicates that all the pixels in said span should be rendered if said span position bits are not all zero.
6. The method of claim 1, wherein said span of pixels is a power of two.
7. A computer-based system for determining which pixels to render as part of a triangle in order to rasterize polygons, the system comprising:
(a) an integer datapath having a plurality of registers and at least one adder/subtracter unit, wherein said integer datapath in configured to generate three edge variables each of which indicate whether a first pixel falls inside or outside a triangle;
(b) a pixel mask generation unit, adapted to accept from said integer datapath said three edge variables, said pixel mask generation unit further adapted to generate a render mask that indicates which pixels within a span of pixels are to be rendere as part of the triangle; and
(c) a rendering unit which takes said render mask from said pixel mas generation unit and issues commands to a memory system for each pixel to b rendered or not.
8. The system of claim 7, wherein said pixel mask generation unit comprises mas means for generating three masks based upon the values of said edge variables, sai masks are representative of a span of pixels; and means for logically ANDing sai three masks to produce a render-mask which represents which pixels within sai span of pixels should be rendered.
9. The system of claim 8, wherein said mask means comprises a lookup table whic provides different masks depending upon the value of said edge variable.
10. The system of claim 7, wherein said span of pixels correspond to blocks of dat accessed by said memory system.
11. The system of claim 7, wherein said edge variables represent the signed horizontal distance between a given pixel and one of the edges of the triangle.
PCT/US1993/009754 1992-10-30 1993-10-12 Polygon rasterization WO1994010647A1 (en)

Priority Applications (4)

Application Number Priority Date Filing Date Title
EP93923379A EP0667018B1 (en) 1992-10-30 1993-10-12 Polygon rasterization
DE69312505T DE69312505T2 (en) 1992-10-30 1993-10-12 POLYGON RASTERING
KR1019950701768A KR950704750A (en) 1992-10-30 1993-10-12 Polygon rasterization
JP51109794A JP3356779B2 (en) 1992-10-30 1993-10-12 Rasterize polygons

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
US07/968,901 1992-10-30
US07/968,901 US5446836A (en) 1992-10-30 1992-10-30 Polygon rasterization

Publications (1)

Publication Number Publication Date
WO1994010647A1 true WO1994010647A1 (en) 1994-05-11

Family

ID=25514914

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/US1993/009754 WO1994010647A1 (en) 1992-10-30 1993-10-12 Polygon rasterization

Country Status (6)

Country Link
US (1) US5446836A (en)
EP (1) EP0667018B1 (en)
JP (1) JP3356779B2 (en)
KR (1) KR950704750A (en)
DE (1) DE69312505T2 (en)
WO (1) WO1994010647A1 (en)

Cited By (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2714504A1 (en) * 1993-12-28 1995-06-30 Samsung Electronics Co Ltd A method of producing a sub-pixel mask for an infographic system and apparatus for its implementation.
US5789727A (en) * 1994-10-18 1998-08-04 Seiko Epson Corporation Integrated method and apparatus for reading mier code and printing
EP1840839A2 (en) * 2006-03-28 2007-10-03 Kabushiki Kaisha Toshiba Graphics-rendering apparatus
EP1881456A1 (en) * 2006-07-20 2008-01-23 Samsung Electronics Co., Ltd. Method and system for tile binning using half-plane edge function
EP2560365A4 (en) * 2010-04-14 2017-07-26 JVC KENWOOD Corporation Video image processing device and video image processing method
EP1918878B1 (en) * 2006-11-03 2018-12-12 Vivante Corporation Hierarchical tile-based rasterization algorithm

Families Citing this family (66)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
TW304254B (en) * 1994-07-08 1997-05-01 Hitachi Ltd
FR2735267B1 (en) * 1995-06-08 1999-04-30 Hewlett Packard Co SYSTEM AND METHOD OF TWO-DIMENSIONAL INTERLACED WEFT-BUFFER TRIANGLE SWEEPING CONVERTER
US5758128A (en) * 1996-06-27 1998-05-26 Cirrus Logic, Inc. Object referenced memory mapping
US6034699A (en) * 1997-05-01 2000-03-07 Ati Technologies, Inc. Rendering polygons
US6141463A (en) * 1997-10-10 2000-10-31 Electric Planet Interactive Method and system for estimating jointed-figure configurations
US6611272B1 (en) * 1998-07-02 2003-08-26 Microsoft Corporation Method and apparatus for rasterizing in a hierarchical tile order
US7224364B1 (en) * 1999-02-03 2007-05-29 Ati International Srl Optimal initial rasterization starting point
US6421053B1 (en) * 1999-05-24 2002-07-16 International Business Machines Corporation Block rendering method for a graphics subsystem
US6407736B1 (en) 1999-06-18 2002-06-18 Interval Research Corporation Deferred scanline conversion architecture
US6795072B1 (en) * 1999-08-12 2004-09-21 Broadcom Corporation Method and system for rendering macropixels in a graphical image
US6504542B1 (en) * 1999-12-06 2003-01-07 Nvidia Corporation Method, apparatus and article of manufacture for area rasterization using sense points
US7027650B2 (en) * 1999-12-10 2006-04-11 Christian Williame Dynamic computing imagery, especially for visceral osteopathy and for articular kinetics
AU1845501A (en) * 1999-12-10 2001-06-18 Georges Finet Dynamic computing imagery for visceral osteopathy and for articular kinetics
US20050052459A1 (en) * 2000-06-07 2005-03-10 Lewis Michael C. Method and system for rendering macropixels in a graphical image
US6556203B1 (en) * 2000-06-30 2003-04-29 Intel Corporation Tile-based digital differential analyzer rasterization
US6636218B1 (en) * 2000-06-30 2003-10-21 Intel Corporation Title-based digital differential analyzer rasterization
US7126600B1 (en) * 2000-08-01 2006-10-24 Ati International Srl Method and apparatus for high speed block mode triangle rendering
US6784894B2 (en) * 2000-08-24 2004-08-31 Sun Microsystems, Inc. Mapping time-sorted to direction-sorted triangle vertices
US7061507B1 (en) 2000-11-12 2006-06-13 Bitboys, Inc. Antialiasing method and apparatus for video applications
US6900800B2 (en) * 2001-02-27 2005-05-31 David Robert Baldwin Tile relative origin for plane equations
US7081903B2 (en) * 2001-12-12 2006-07-25 Hewlett-Packard Development Company, L.P. Efficient movement of fragment stamp
KR100487461B1 (en) * 2002-07-31 2005-05-03 학교법인연세대학교 scan conversion unit in tiling-traveresal algorithm
US7800631B2 (en) * 2003-03-18 2010-09-21 Qualcomm Incorporated Triangle rendering using direct evaluation
DE602004002859T2 (en) * 2003-04-15 2007-05-16 Novozymes A/S PROCESS FOR THE PRODUCTION OF TEA
US8732644B1 (en) 2003-09-15 2014-05-20 Nvidia Corporation Micro electro mechanical switch system and method for testing and configuring semiconductor functional circuits
US8788996B2 (en) * 2003-09-15 2014-07-22 Nvidia Corporation System and method for configuring semiconductor functional circuits
US8775997B2 (en) 2003-09-15 2014-07-08 Nvidia Corporation System and method for testing and configuring semiconductor functional circuits
US8711161B1 (en) 2003-12-18 2014-04-29 Nvidia Corporation Functional component compensation reconfiguration system and method
US7551174B2 (en) * 2003-12-23 2009-06-23 Via Technologies, Inc. Method and apparatus for triangle rasterization with clipping and wire-frame mode support
US7139997B1 (en) * 2004-05-11 2006-11-21 Altera Corporation Method and system for checking operation of a mask generation algorithm
FR2865563B1 (en) * 2004-06-17 2006-03-17 Raphael Lemoine METHOD AND DEVICE FOR FILLING A GEOMETRIC FORM
US8723231B1 (en) 2004-09-15 2014-05-13 Nvidia Corporation Semiconductor die micro electro-mechanical switch management system and method
US8711156B1 (en) 2004-09-30 2014-04-29 Nvidia Corporation Method and system for remapping processing elements in a pipeline of a graphics processing unit
US7555163B2 (en) * 2004-12-16 2009-06-30 Sony Corporation Systems and methods for representing signed distance functions
US7362325B2 (en) * 2004-12-21 2008-04-22 Qualcomm Incorporated 2D/3D line rendering using 3D rasterization algorithms
US20060235610A1 (en) * 2005-04-14 2006-10-19 Honeywell International Inc. Map-based trajectory generation
US8427496B1 (en) 2005-05-13 2013-04-23 Nvidia Corporation Method and system for implementing compression across a graphics bus interconnect
US8698811B1 (en) 2005-12-15 2014-04-15 Nvidia Corporation Nested boustrophedonic patterns for rasterization
US8390645B1 (en) 2005-12-19 2013-03-05 Nvidia Corporation Method and system for rendering connecting antialiased line segments
US9117309B1 (en) 2005-12-19 2015-08-25 Nvidia Corporation Method and system for rendering polygons with a bounding box in a graphics processor unit
US8928676B2 (en) * 2006-06-23 2015-01-06 Nvidia Corporation Method for parallel fine rasterization in a raster stage of a graphics pipeline
US8237738B1 (en) 2006-11-02 2012-08-07 Nvidia Corporation Smooth rasterization of polygonal graphics primitives
US8427487B1 (en) 2006-11-02 2013-04-23 Nvidia Corporation Multiple tile output using interface compression in a raster stage
US8482567B1 (en) * 2006-11-03 2013-07-09 Nvidia Corporation Line rasterization techniques
US8724483B2 (en) * 2007-10-22 2014-05-13 Nvidia Corporation Loopback configuration for bi-directional interfaces
US9064333B2 (en) * 2007-12-17 2015-06-23 Nvidia Corporation Interrupt handling techniques in the rasterizer of a GPU
US8780123B2 (en) * 2007-12-17 2014-07-15 Nvidia Corporation Interrupt handling techniques in the rasterizer of a GPU
KR100954638B1 (en) * 2008-04-03 2010-04-27 재단법인서울대학교산학협력재단 Method For Vector Graphics Rasterization
US8923385B2 (en) * 2008-05-01 2014-12-30 Nvidia Corporation Rewind-enabled hardware encoder
US8681861B2 (en) * 2008-05-01 2014-03-25 Nvidia Corporation Multistandard hardware video encoder
JP5151946B2 (en) * 2008-12-09 2013-02-27 富士通株式会社 Drawing device
US20110063309A1 (en) * 2009-09-16 2011-03-17 Nvidia Corporation User interface for co-processing techniques on heterogeneous graphics processing units
US9530189B2 (en) 2009-12-31 2016-12-27 Nvidia Corporation Alternate reduction ratios and threshold mechanisms for framebuffer compression
US9331869B2 (en) 2010-03-04 2016-05-03 Nvidia Corporation Input/output request packet handling techniques by a device specific kernel mode driver
US8378319B2 (en) * 2010-03-22 2013-02-19 Taiwan Semiconductor Manufacturing Company, Ltd. System and method for generating direct-write pattern
US9171350B2 (en) 2010-10-28 2015-10-27 Nvidia Corporation Adaptive resolution DGPU rendering to provide constant framerate with free IGPU scale up
CN102486870B (en) * 2010-12-01 2014-02-12 财团法人资讯工业策进会 Drawing system and pixel updating method thereof
US8860742B2 (en) 2011-05-02 2014-10-14 Nvidia Corporation Coverage caching
US9591309B2 (en) 2012-12-31 2017-03-07 Nvidia Corporation Progressive lossy memory compression
US9607407B2 (en) 2012-12-31 2017-03-28 Nvidia Corporation Variable-width differential memory compression
US9710894B2 (en) 2013-06-04 2017-07-18 Nvidia Corporation System and method for enhanced multi-sample anti-aliasing
US9501859B2 (en) 2013-07-19 2016-11-22 Adobe Systems Incorporated Triangle rasterization
US9832388B2 (en) 2014-08-04 2017-11-28 Nvidia Corporation Deinterleaving interleaved high dynamic range image by using YUV interpolation
US10410081B2 (en) * 2014-12-23 2019-09-10 Intel Corporation Method and apparatus for a high throughput rasterizer
CN109346028B (en) * 2018-11-14 2021-03-23 西安翔腾微电子科技有限公司 TLM-based triangular raster scanning structure
US10692271B1 (en) 2018-12-13 2020-06-23 Advanced Micro Devices, Inc. Robust ray-triangle intersection

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0425189A2 (en) * 1989-10-23 1991-05-02 International Business Machines Corporation Concave polygon drawing for a computer graphics display system

Family Cites Families (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US4962468A (en) * 1987-12-09 1990-10-09 International Business Machines Corporation System and method for utilizing fast polygon fill routines in a graphics display system
US5187658A (en) * 1990-01-17 1993-02-16 General Electric Company System and method for segmenting internal structures contained within the interior region of a solid object

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
EP0425189A2 (en) * 1989-10-23 1991-05-02 International Business Machines Corporation Concave polygon drawing for a computer graphics display system

Cited By (8)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
FR2714504A1 (en) * 1993-12-28 1995-06-30 Samsung Electronics Co Ltd A method of producing a sub-pixel mask for an infographic system and apparatus for its implementation.
US5789727A (en) * 1994-10-18 1998-08-04 Seiko Epson Corporation Integrated method and apparatus for reading mier code and printing
EP1840839A2 (en) * 2006-03-28 2007-10-03 Kabushiki Kaisha Toshiba Graphics-rendering apparatus
EP1840839A3 (en) * 2006-03-28 2013-11-06 Kabushiki Kaisha Toshiba Graphics-rendering apparatus
EP1881456A1 (en) * 2006-07-20 2008-01-23 Samsung Electronics Co., Ltd. Method and system for tile binning using half-plane edge function
US8345064B2 (en) 2006-07-20 2013-01-01 Samsung Electronics Co., Ltd. Method and system for tile binning using half-plane edge function
EP1918878B1 (en) * 2006-11-03 2018-12-12 Vivante Corporation Hierarchical tile-based rasterization algorithm
EP2560365A4 (en) * 2010-04-14 2017-07-26 JVC KENWOOD Corporation Video image processing device and video image processing method

Also Published As

Publication number Publication date
KR950704750A (en) 1995-11-20
EP0667018A1 (en) 1995-08-16
EP0667018B1 (en) 1997-07-23
DE69312505D1 (en) 1997-09-04
JP3356779B2 (en) 2002-12-16
JPH08502845A (en) 1996-03-26
DE69312505T2 (en) 1997-11-06
US5446836A (en) 1995-08-29

Similar Documents

Publication Publication Date Title
US5446836A (en) Polygon rasterization
US7425955B2 (en) Method for tracking depths in a scanline based raster image processor
US7872648B2 (en) Random-access vector graphics
US5301267A (en) Intelligent font rendering co-processor
Guthe et al. GPU-based trimming and tessellation of NURBS and T-Spline surfaces
US5307451A (en) Method and apparatus for generating and manipulating graphical data for display on a computer output device
US7280120B2 (en) Compositing with a sub-pixel mask in graphic object rendering
US6693637B2 (en) Method and apparatus for determining bins to be updated for polygons, including lines
US7292255B2 (en) Image data acquisition optimisation
US7148897B2 (en) Rendering successive frames in a graphic object system
US7292256B2 (en) Optimising compositing calculations for a run of pixels
US8928667B2 (en) Rendering stroked curves in graphics processing systems
US9501811B2 (en) Resizing an image
JPH0322188A (en) Method of changing graphic image into raster and expressing said image
US7034830B2 (en) Method for generating a two-dimensional distance field within a cell associated with a corner of a two-dimensional object
US20030122829A1 (en) Efficient movement of fragment stamp
JP3029878B2 (en) Apparatus and method for processing a plurality of polygons representing an image
Boyer et al. Fast lines: A span by span method
US6384745B1 (en) System, method and computer program product for a highly compressed outline font engine
EP1437688B1 (en) Raycasting system and method
JP3266905B2 (en) Graphic processing unit
US20050116951A1 (en) Using runs of cells to traverse a ray through a volume
JPH07120427B2 (en) Graphic processing system
Lehn et al. Rasterisation
AU2004250268B2 (en) A method for tracking depths in a scanline based raster image processor

Legal Events

Date Code Title Description
AK Designated states

Kind code of ref document: A1

Designated state(s): JP KR

AL Designated countries for regional patents

Kind code of ref document: A1

Designated state(s): AT BE CH DE DK ES FR GB GR IE IT LU MC NL PT SE

121 Ep: the epo has been informed by wipo that ep was designated in this application
DFPE Request for preliminary examination filed prior to expiration of 19th month from priority date (pct application filed before 20040101)
WWE Wipo information: entry into national phase

Ref document number: 1993923379

Country of ref document: EP

WWP Wipo information: published in national office

Ref document number: 1993923379

Country of ref document: EP

WWG Wipo information: grant in national office

Ref document number: 1993923379

Country of ref document: EP