rasterizing polygons
Download
Skip this Video
Download Presentation
Rasterizing Polygons

Loading in 2 Seconds...

play fullscreen
1 / 48

Rasterizing Polygons - PowerPoint PPT Presentation


  • 77 Views
  • Uploaded on

Rasterizing Polygons. Lecture 29 Wed, Dec 7, 2005. Rasterizing Polygons. Given a the vertices of a polygon, in viewport coordinates, which pixels should be shaded? How do we determine them efficiently?. Rasterizing Polygons. Rasterizing Polygons.

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about ' Rasterizing Polygons' - byron


An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
rasterizing polygons

Rasterizing Polygons

Lecture 29

Wed, Dec 7, 2005

rasterizing polygons1
Rasterizing Polygons
  • Given a the vertices of a polygon, in viewport coordinates, which pixels should be shaded?
  • How do we determine them efficiently?
rasterizing polygons3
Rasterizing Polygons
  • Obviously, any pixel lying entirely within the polygon should be shaded.
  • What about the pixels that are partially within the polygon?
    • Rule: Shade them if their center is within the polygon.
  • What about the pixels whose center is exactly on the edge?
neighboring polygons
Neighboring Polygons
  • When two polygons share an edge, which one “owns” the pixels on the edge?
  • Rule
    • A polygon owns all pixels whose centers are within its interior.
    • A polygon owns all pixels whose centers lie on one of its left edges.
neighboring polygons1
Neighboring Polygons
  • Fill in all pixels whose centers are within the polygon.
neighboring polygons2
Neighboring Polygons
  • Fill in all pixels whose centers are on a left edge of the polygon.
a rasterization algorithm
A Rasterization Algorithm
  • To rasterize a polygon, first determine its bounding box.
a rasterization algorithm1
A Rasterization Algorithm
  • To rasterize a polygon, first determine its bounding rectangle.
a rasterization algorithm2
A Rasterization Algorithm
  • Then scan each row of pixels in the bounding rectangle, left to right, bottom to top.
a rasterization algorithm3
A Rasterization Algorithm
  • When an edge is encountered,
    • If we were on the outside, we move to the inside.
    • If we were on the inside, we move to the outside.
  • Thus, we stop or resume shading accordingly.
a rasterization algorithm4
A Rasterization Algorithm
  • Then scan each row of pixels in the bounding rectangle, left to right, bottom to top.

row 0

a rasterization algorithm5
A Rasterization Algorithm
  • Then scan each row of pixels in the bounding rectangle, left to right, bottom to top.

row 1

a rasterization algorithm6
A Rasterization Algorithm
  • Then scan each row of pixels in the bounding rectangle, left to right, bottom to top.

row 2

a rasterization algorithm7
A Rasterization Algorithm
  • Then scan each row of pixels in the bounding rectangle, left to right, bottom to top.

row 3

a rasterization algorithm8
A Rasterization Algorithm
  • Then scan each row of pixels in the bounding rectangle, left to right, bottom to top.

row 4

a rasterization algorithm9
A Rasterization Algorithm
  • Then scan each row of pixels in the bounding rectangle, left to right, bottom to top.

row 5

a rasterization algorithm10
A Rasterization Algorithm
  • Then scan each row of pixels in the bounding rectangle, left to right, bottom to top.

row 6

a rasterization algorithm11
A Rasterization Algorithm
  • Then scan each row of pixels in the bounding rectangle, left to right, bottom to top.

row 7

a rasterization algorithm12
A Rasterization Algorithm
  • The following algorithm is designed to allow rapid shading of the pixels.
    • As the vertices are given, create a list of the vertices. (The order matters!)
      • {(1, 0), (4, 3), (6, 1), (12, 1), (11, 8), (7, 8), (6, 5), (4, 8), (0, 7), (1, 0)}.
    • From the list of vertices, form an edge table.
      • {{(1, 0), (4, 3)}, {(4, 3), (6, 1)}, …, {(0, 7), (1, 0)}}.
a rasterization algorithm13
A Rasterization Algorithm
  • Organization of the edge table.
    • Eliminate any horizontal edges.
    • Sort the edges in the edge table by the y-coordinate of the lower endpoint.
  • Begin scanning with the bottom scan line.
the active edge table
The Active Edge Table
  • Create the active edge table (AET).
    • For each edge in the edge table whose lower endpoint is on the scan line,
      • Create an active-edge-table entry.
      • Add it to the active edge table.
      • Delete the edge from the edge table.
the active edge table1
The Active Edge Table
  • Organization of an active-edge-table entry:
    • y-coordinate of upper endpoint.
    • Reciprocal of the slope.
    • x-intercept with the horizontal line ½ unit above the current scan line.
the active edge table2
The Active Edge Table

Active

edges

Scan

line

the active edge table3
The Active Edge Table

(7, -1/7, 13/14)

Scan

line

(3, 1, 1-1/2)

the active edge table4
The Active Edge Table
  • Sort the AET entries by their x-intercepts.
  • The AET must contain an even number of entries.
    • Why?
  • Shade pixels from the 1st to the 2ndx-intercepts, 3rd to 4thx-intercepts, etc., in the AET.
the active edge table5
The Active Edge Table

(7, -1/7, 13/14)

(no shading on

this scan line)

Scan

line

(3, 1, 1-1/2)

the active edge table6
The Active Edge Table
  • Update the AET.
    • Increment the scan line number.
    • Delete from the AET any entries for which the upper endpoint is on the scan line.
    • Update the x-intercepts of all AET entries.
      • Add the reciprocal slope to the x-intercept.
    • Create and add entries from the edge table for edges whose lower endpoint is on the scan line.
a rasterization algorithm14
A Rasterization Algorithm

(7, -1/7, 13/14)

Scan

line

(3, 1, 1-1/2)

a rasterization algorithm15
A Rasterization Algorithm

(7, -1/7, 11/14)

Scan

line

(8, -1/7, 11-13/14)

(3, -1, 5-1/2)

(3, 1, 2-1/2)

a rasterization algorithm16
A Rasterization Algorithm

(7, -1/7, 11/14)

Scan

line

(8, -1/7, 11-13/14)

(3, -1, 5-1/2)

(3, 1, 2-1/2)

a rasterization algorithm17
A Rasterization Algorithm

(7, -1/7, 9/14)

Scan

line

(8, -1/7, 11-11/14)

(3, -1, 4-1/2)

(3, 1, 3-1/2)

a rasterization algorithm18
A Rasterization Algorithm

(7, -1/7, 9/14)

Scan

line

(8, -1/7, 11-11/14)

(3, -1, 4-1/2)

(3, 1, 3-1/2)

a rasterization algorithm19
A Rasterization Algorithm

(7, -1/7, 1/2)

Scan

line

(8, -1/7, 11-9/14)

a rasterization algorithm20
A Rasterization Algorithm

(7, -1/7, 1/2)

Scan

line

(8, -1/7, 11-9/14)

a rasterization algorithm21
A Rasterization Algorithm

(7, -1/7, 5/14)

Scan

line

(8, -1/7, 11-1/2)

a rasterization algorithm22
A Rasterization Algorithm

(7, -1/7, 5/14)

Scan

line

(8, -1/7, 11-1/2)

a rasterization algorithm23
A Rasterization Algorithm

(8, -2/3, 5-5/6)

(8, 1/3, 6-1/6)

(7, -1/7, 3/14)

Scan

line

(8, -1/7, 11-5/14)

a rasterization algorithm24
A Rasterization Algorithm

(8, -2/3, 5-2/3)

(8, 1/3, 6-1/6)

(7, -1/7, 3/14)

Scan

line

(8, -1/7, 11-5/14)

a rasterization algorithm25
A Rasterization Algorithm

(8, -2/3, 5)

(8, 1/3, 6-1/2)

(7, -1/7, 1/14)

Scan

line

(8, -1/7, 11-3/14)

a rasterization algorithm26
A Rasterization Algorithm

(8, -2/3, 5)

(8, 1/3, 6-1/2)

(7, -1/7, 1/14)

Scan

line

(8, -1/7, 11-3/14)

a rasterization algorithm27
A Rasterization Algorithm

(8, -2/3, 5)

(8, 1/3, 6-1/2)

(8, 4, 2)

Scan

line

(8, -1/7, 11-3/14)

a rasterization algorithm28
A Rasterization Algorithm

(8, -2/3, 5)

(8, 1/3, 6-1/2)

(8, 4, 2)

Scan

line

(8, -1/7, 11-3/14)

ad