Presentation is loading. Please wait.

Presentation is loading. Please wait.

Scan Conversion of Polygons

Similar presentations


Presentation on theme: "Scan Conversion of Polygons"— Presentation transcript:

1 Scan Conversion of Polygons
Dr. Scott Schaefer

2 Which pixels should be filled?
Drawing Rectangles Which pixels should be filled?

3 Drawing Rectangles Is this correct?

4 What if two rectangles overlap?
Drawing Rectangles What if two rectangles overlap?

5 Drawing Rectangles Is this correct?

6 Drawing Rectangles Overlap!!! Is this correct?

7 Solution: Exclude pixels on top and right
Drawing Rectangles Solution: Exclude pixels on top and right

8 Artifacts are possible
Drawing Rectangles Artifacts are possible

9 General Polygons – Basic Idea
Intersect scan lines with edges Find ranges along x Fill interior of those ranges Don’t fill top/right Edges may NOT match with line drawing algo

10 General Polygons – Basic Idea
Use coherence to speed up Intersect scan lines with edges Find ranges along x Fill interior of those ranges Don’t fill top/right Edges may NOT match with line drawing algo

11 General Polygons – Basic Idea
Use coherence to speed up Intersect scan lines with edges Find ranges along x Fill interior of those ranges Edges intersection one scan line are mostly same as those intersecting previous scan line

12 General Polygons – Basic Idea
Use coherence to speed up Intersect scan lines with edges Find ranges along x Fill interior of those ranges The x-value of an intersection with one scan line is close to the intersection with the previous one

13 General Polygons – Data Structures
Edge: maxY: currentX: xIncr: Edge maxY currentX xIncr

14 General Polygons – Data Structures
Edge: maxY: currentX: xIncr: Edge maxY currentX xIncr Horizontal edges will not be used!!!

15 General Polygons – Data Structures
Active Edge Table: Store a linked-list per scan-line. Insert edges into table at scan-line associated with lowest end-point. Scan Lines Edges

16 General Polygons – Data Structures
Active Edge List: List of all edges intersecting current scan-line sorted by their x-values Edges

17 General Polygons – Algorithm
line = 0 While (line < height ) Add edges to Active Edge List from Active Edge Table starting at line Remove edges that end at line Fill pixels Increment x-values on edges in Active Edge List Increment line

18 General Polygons – Example
C Active Edge Table B D G Active Edge List F E A

19 General Polygons – Example
C Active Edge Table B D G AB Active Edge List F E A

20 General Polygons – Example
C Active Edge Table B BC D G AB Active Edge List F E A

21 General Polygons – Example
C Active Edge Table B BC D CD G AB Active Edge List F E A

22 General Polygons – Example
C Active Edge Table B BC D CD G ED AB Active Edge List F E A

23 General Polygons – Example
C Active Edge Table B BC D CD G ED AB Active Edge List F E A

24 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB Active Edge List F E A

25 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E A

26 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG A maxY currentX xIncr

27 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

28 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

29 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

30 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

31 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB AG FG ED A maxY currentX xIncr

32 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

33 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

34 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

35 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED A maxY currentX xIncr

36 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED CD A maxY currentX xIncr

37 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB ED CD A maxY currentX xIncr

38 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB CD A maxY currentX xIncr

39 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB CD A maxY currentX xIncr

40 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB BC CD A maxY currentX xIncr

41 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E AB BC CD A maxY currentX xIncr

42 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

43 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

44 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

45 General Polygons – Example
C Active Edge Table B BC D CD G FG ED AB AG Active Edge List F E BC CD A maxY currentX xIncr

46 General Polygons – Problems
Sliver polygons may not be drawn correctly No simple solution Long, thin triangles cause problems Want triangles with good aspect ratio (close to equilateral)

47 Boundary Fill Start with drawn outline of a polygon and an interior point Recursively recolor outward from that point If neighbor different, then recolor and recur Everything within the boundary is changed to that color

48 Boundary Fill How to define a neighbor? 8-connected 4-connected

49 Boundary Fill – Example

50 Boundary Fill – Example

51 Boundary Fill – Example

52 Boundary Fill – Example

53 Boundary Fill – Example

54 Boundary Fill – Example

55 Flood Fill Start with a point
Define color under that point as the interior color Recursively recolor outward from that point If neighbor is interior color, then recolor and recur Contiguous regions of the same color are recolored

56 Flood Fill – Example

57 Flood Fill – Example

58 Flood Fill – Example

59 Flood Fill – Example

60 Flood Fill – Example

61 Flood Fill – Example

62 Flood Fill – Example

63 Flood Fill – Example

64 Flood Fill – Example

65 Flood Fill – Example

66 Flood Fill – Example

67 Flood Fill – Example

68 Flood Fill – Example

69 OpenGL: Drawing Polygons
Lots of different primitives supported GPU only draws triangles OpenGL triangulates all polygons Problems with concave polygons! How data is passed to GPU makes a significant difference in speed GL_QUADS GL_POLYGON GL_TRIANGLES GL_TRIANGLE_FAN GL_TRIANGLE_STRIP GL_QUAD_STRIP

70 Performance Nvidia 7300 GT1 Nvidia 8800 GTX1 ATI Radeon HD 48502
New Drivers Immediate Mode 15.5 21.0 33.0 Display Lists 28.3 22.0 463.5 497.5 Vertex Arrays 33.5 35.5 75.0 335.0 Vertex Buffer Objects 50.0 200.0 476.3 506.0 Frames per second displaying a 413,236 triangle model. CPU was an Intel Core or Core i

71 Tile-Based Rasterization
Screen

72 Tile-Based Rasterization

73 Tile-Based Rasterization

74 Tile-Based Rasterization

75 Tile-Based Rasterization
Each thread draws polygon into local frame buffer Copies local frame buffer into global frame buffer when complete

76 Even More Parallelization

77 Even More Parallelization

78 Even More Parallelization

79 Point in Triangle

80 Even More Parallelization

81 Even More Parallelization
Only need to check until first polygon hit


Download ppt "Scan Conversion of Polygons"

Similar presentations


Ads by Google