ibl sfzrn
play

ibl ) Sfzrn size (32 point, 1 point = 1/72 inch) serif ( better - PDF document

Einfhrung in Visual Computing Triangles and Polygon Filling Werner Purgathofer Institut fr Computergraphik und Algorithmen 2. Vorlesungseinheit Computergraphik Attributes of Graphics Output Primitives Points and Line Attributes in


  1. Einführung in Visual Computing Triangles and Polygon Filling Werner Purgathofer Institut für Computergraphik und Algorithmen 2. Vorlesungseinheit “Computergraphik” Attributes of Graphics Output Primitives Points and Line Attributes in 2D color points, lines characters type: solid, dashed, dotted,… in 2D and 3D triangles triangles width, line caps, corners other polygons ((filled) ellipses and other curves) pen and brush options … Werner Purgathofer / Einf. in Visual Computing 2 Werner Purgathofer / Einf. in Visual Computing 3 Character Attributes Character Primitives text attributes font (typeface) font (e.g. Courier , Arial, Times , Roman , …) design style for (family of) characters styles (regular, bold , italic , underline,…) Courier, Times, Arial, … ibl ) Sfzrn size (32 point, 1 point = 1/72 inch) serif ( better readable ), Sfzrn Sf rn proportionally sized vs. fixed space fonts p p y p sans serif (better legible) if (b tt l v string attributes e definition model r horizontal t orientation i bitmap font (simple to define and display), c alignment (left, center, right, justify) a needs more space (font cache) l Displayed primitives Displayed primitives Displayed primitives Displayed primitives outline font (more costly, less space, generated by the generated by the generated by the generated by the raster algorithms raster algorithms raster algorithms raster algorithms geometric transformations) discussed in Chapter 3 discussed in Chapter 3 discussed in Chapter 3 discussed in Chapter 3 have a jagged, or have a jagged, or have a jagged, or have a jagged, or stairstep, appearance. stairstep, appearance. stairstep, appearance. stairstep, appearance. Werner Purgathofer / Einf. in Visual Computing 4 Werner Purgathofer 5 1

  2. Example: Newspaper Character Generation Examples the letter B represented with an 8x8 bilevel bitmap pattern and with an outline shape defined with straight line and curve segments Werner Purgathofer 6 Werner Purgathofer 7 Area-Fill Attributes (1) Area-Fill Attributes (2) fill styles combination of and hollow, solid fill, pattern fill fill pattern with fill options background colors pattern back- or edge type, width, color ground soft fill pattern specification 4 0 4 0 4 0 4 0 4 0 4 0 4 0 4 0 combination of colors combination of colors through pattern tables through pattern tables 4 0 4 0 xor xor 0 4 0 4 0 4 0 4 0 4 tiling (reference point) antialiasing at object borders 4 0 4 0 4 0 4 0 0 4 0 4 0 4 0 4 semitransparent brush simulation replace 4 0 4 0 4 0 4 0 example: linear soft-fill 0 4 0 4 0 4 0 4 F...foreground color P = tF + (1  t)B B...background color Werner Purgathofer / Einf. in Visual Computing 8 Werner Purgathofer / Einf. in Visual Computing 9 Triangle and Polygon Attributes General Polygon Fill Algorithms color triangle rasterization material other polygons: what is inside? transparency scan-line fill method texture flood fill method surface details f d t il clean borders between reflexion properties, … (α, β ,γ) adjacent triangles → defined illumination produces effects barycentric coordinates Werner Purgathofer / Einf. in Visual Computing 10 Werner Purgathofer / Einf. in Visual Computing 11 2

  3. General Polygon Fill Algorithms General Polygon Fill Algorithms triangle rasterization triangle rasterization other polygons: what is inside? other polygons: what is inside? scan-line fill method scan-line fill method flood fill method flood fill method interior pixels along a scan line passing through a polygon area “interior”, “exterior” for self-intersecting polygons? Werner Purgathofer / Einf. in Visual Computing 12 Werner Purgathofer / Einf. in Visual Computing 13 General Polygon Fill Algorithms Triangles: Barycentric Coordinates P 2 (x 2 , y 2 ) triangle rasterization ( α , β , γ ) (0, 0, 1) other polygons: what is inside? scan-line fill method P 0 (x 0 , y 0 ) flood fill method (0 60 0 13 0 27) (0.60, 0.13, 0.27) (1, 0 ,0) P 1 (x 1 , y 1 ) (0, 1, 0) starting from a seed point fill until P = αP 0 + βP 1 + γP 2 you reach a border triangle = {P| α+β+γ=1, 0<α<1, 0<β<1, 0<γ<1} Werner Purgathofer / Einf. in Visual Computing 14 Werner Purgathofer / Einf. in Visual Computing 15 Barycentric Coordinates Triangle Rasterization Algorithm P 2 (x 2 ,y 2 ,z 2 ) ( α , β , γ ) for all x (0, 0, 1) for all y /* use a bounding box!*/ {compute ( α , β , γ ) for (x,y) ; P 0 (x 0 ,y 0 ,z 0 ) if (0< α <1) and (0< β <1) and (0< γ <1) <1 <1 <1 (0 60 0 13 0 27) (0.60, 0.13, 0.27) (1, 0 ,0) {c = α c 0 + β c 1 + γ c 2 ; c = α c 0 + β c 1 + γ c 2 ; draw pixel (x,y) with color c with color c P 1 (x 1 ,y 1 ,z 1 ) }} (0, 1, 0) P = αP 0 + βP 1 + γP 2 P = αA + βB + γC interpolates values at the corners (vertices) linearly inside the triangle (and along edges) triangle = {P| α+β+γ=1, 0<α<1, 0<β<1, 0<γ<1} triangle = {P| α+β+γ=1, 0<α<1, 0<β<1, 0<γ<1} Werner Purgathofer / Einf. in Visual Computing 16 Werner Purgathofer / Einf. in Visual Computing 17 3

  4. Computing ( α , β , γ ) for P(x,y) Barycentric Coordinates Example 1.2 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -1.4 -1.2 -1.0 -0.8 -0.6 -0.4 -0.2 0.0 line through P 1 , P 2 : l 12 (x,y) = a 12 x+b 12 y+c 12 =0 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.2 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -1.2 -1.0 -0.8 -0.6 -0.4 -0.2 0.0 0.2 then α = l 12 (x,y) / l 12 (x 0 ,y 0 ) 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.2 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 P 2 (x 2 , y 2 ) -1.0 -0.8 -0.6 -0.4 -0.2 0.0 0.2 0.4 0.8 0.8 0.8 0.8 0.8 0.8 0.8 0.8 β , γ analogous 1.2 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.8 -0.6 -0.4 -0.2 0.0 0.2 0.4 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 0.6 P(x, y) 0.6 1.2 0 6 1.0 0 4 0.8 0.4 0.2 0.0 -0.2 l ( l 12 (x,y)=0 ) 0 -0.6 -0.4 -0.2 0 2 0.0 0 0 0.2 0 2 0.4 0 4 0.6 0 6 0.8 0 8 P 0 (x 0 , y 0 ) ( α , β , γ ) 0.4 0.4 0.4 0.4 0.4 0.4 0.4 0.4 1.2 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.4 -0.2 0.0 0.2 0.4 0.6 0.8 1.0 0.2 0.2 0.2 0.2 0.2 0.2 0.2 0.2 1.2 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 -0.2 0.0 0.2 0.4 0.6 0.8 1.0 1.2 P 1 (x 1 , y 1 ) 0.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0 1.2 1.0 0.8 0.6 0.4 0.2 0.0 -0.2 0.0 0.2 0.4 0.6 0.8 1.0 1.2 1.4 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 -0.2 P = αP 0 + βP 1 + γP 2 P = αP 0 + βP 1 + γP 2 triangle = {P| α+β+γ=1, 0<α<1, 0<β<1, 0<γ<1} triangle = {P| α+β+γ=1, 0<α<1, 0<β<1, 0<γ<1} Werner Purgathofer / Einf. in Visual Computing 18 Werner Purgathofer / Einf. in Visual Computing 19 Avoiding to Draw Borders twice Pixels exactly on a Border don‘t draw the outline of the triangle! holes if both triangles leave pixels away result would depend on rendering order simplest solution: draw both pixels draw only pixels that are inside exact triangle better: arbitrary choice based on some test i.e. pixels with α , β , γ = 0, 1 are not drawn e.g. only right boundaries clean borders clean borders between between adjacent triangles adjacent triangles Werner Purgathofer / Einf. in Visual Computing 20 Werner Purgathofer / Einf. in Visual Computing 21 What is Inside a Polygon? Inside-Outside Tests area-filling algorithms “interior”, “exterior” for self-intersecting polygons? odd-even rule nonzero-winding-number rule nonzero winding number rule same result for simple polygons odd-even rule nonzero-winding- ??? number rule Werner Purgathofer / Einf. in Visual Computing 22 Werner Purgathofer / Einf. in Visual Computing 23 4

  5. What is Inside?: Odd-Even Rule What is Inside?: Nonzero Winding Number inside/outside switches at every edge point is inside if polygon surrounds it straight line to the outside: straight line to the outside: even # edge intersections = outside same # edges up and down = outside odd # edge intersections = inside different # edges up and down = inside Werner Purgathofer / Einf. in Visual Computing 24 Werner Purgathofer / Einf. in Visual Computing 25 Polygon Fill Areas Fill-Area Primitives polygon classifications for polygon area (solid-color, patterned) convex: no interior angle > 180° scan-line polygon fill algorithm intersection points located and sorted concave: not convex consecutive pairs define interior span concavity test attention with vertex intersections vector method vector method exploit coherence (incremental calculations) all vector cross products have the same sign flood fill algorithm  convex rotational method rotate polygon-edges onto x-axis, always same direction  convex Werner Purgathofer / Einf. in Visual Computing 26 Werner Purgathofer / Einf. in Visual Computing 27 Scan-Line Fill: Sorted Edge Table Scan-Line Fill: Sorted Edge Table E sort all edges by smallest y-value y E x D 1/m DE D edge entry: [max y-value, x-intercept, inverse slope] B y B x C 1/m CB y D x C 1/m CD C y B x C 1/m CB y D x C 1/m CD F y E x F 1/m FE active-edge list y F x A 1/m AF y B x A 1/m AB for each scan line A contains all edges crossed by that scan line The sorted edge table contains all incremental update polygon edges sorted by lowest y-value consecutive intersection pairs (spans) filled y max x start 1/m Werner Purgathofer / Einf. in Visual Computing 28 Werner Purgathofer / Einf. in Visual Computing 29 5

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend