Attributes of Graphics Primitives Hearn & Baker Chapter 4 Some slides are taken from Robert Thomsons notes.

Slides:



Advertisements
Similar presentations
Computer Graphics- SCC 342
Advertisements

CP411 polygon Lecture 6 1. Scan conversion algorithm for circle 2. Draw polygons 3. Antialiasing.
Computer Graphics Viewing, Rendering, Antialiasing گرد آوري و تاليف: دكتر احمد رضا نقش نيل چي دانشگاه اصفهان گروه مهندسي كامپيوتر.
David Luebke1/19/99 CS 551/651: Antialiasing David Luebke
CS 551 / CS 645 Antialiasing. What is a pixel? A pixel is not… –A box –A disk –A teeny tiny little light A pixel is a point –It has no dimension –It occupies.
© 2001 By Default! A Free sample background from Slide 1 Attributes of Output Primitives Definition Parameter that affects.
CS 376 Introduction to Computer Graphics 02 / 05 / 2007 Instructor: Michael Eckmann.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
Sampling, Aliasing, & Mipmaps
CMPE 466 COMPUTER GRAPHICS
CSCE 441: Computer Graphics Scan Conversion of Polygons
Implementation III Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Graphics Programming: Polygon Filling
CST 494/598 Computer Graphics Anshuman Razdan i3dea.asu.edu/razdan.
CS 4731: Computer Graphics Lecture 22: Raster Graphics Part 3 Emmanuel Agu.
Aliasing and Anti-Aliasing Copyright Zachary Wartell, University of North Carolina at Charlotte, All Rights Reserved Revision: 10/24/2007 3:38:00 AM ©Zachary.
CSC418 Computer Graphics n Aliasing n Texture mapping.
Sampling theorem In order to accurately reconstruct a signal from a periodically sampled version of it, the sampling frequency must be at least twice the.
Attributes of Graphics Primitives Sang Il Park Sejong University.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Antialiasing, Texture Mapping.
March Shape Drawing Algorithms Shmuel Wimer Bar Ilan Univ., Engineering Faculty.
CGMB 314 Intro to Computer Graphics Fill Area Primitives.
1/24/20061 Fill-Area Algorithms and Functions. 1/24/20062 Learning Objectives OpenGL state variables Color and gray scale Color functions Point attributes.
Geometric Objects Computer Graphics Lab. Sun-Jeong Kim.
CGMB214: Introduction to Computer Graphics
Image Synthesis Rabie A. Ramadan, PhD 3. 2 Our Problem.
3/4/04© University of Wisconsin, CS559 Spring 2004 Last Time Clipping Lines –Cohen-Sutherland: The use of outcodes and early reject/accept tests –Liang-Barsky:
Graphics Graphics Korea University cgvr.korea.ac.kr Raster Graphics 고려대학교 컴퓨터 그래픽스 연구실.
Triangle Scan Conversion. 2 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Rasterization Rasterization (scan conversion) –Determine which.
1Computer Graphics Implementation III Lecture 17 John Shearer Culture Lab – space 2
Introduction to Computer Graphics with WebGL
CS 480/680 Computer Graphics Implementation III Dr. Frederick C Harris, Jr. Fall 2011.
10/26/04© University of Wisconsin, CS559 Fall 2004 Last Time Drawing lines Polygon fill rules Midterm Oct 28.
1 Introduction Line attribute Color and gray scale Area filled attribute Anti-aliasing.
CS 450: COMPUTER GRAPHICS ANTIALIASING SPRING 2015 DR. MICHAEL J. REALE.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Vector Graphics Digital Multimedia Chap 이병희
Sang Il Park Sejong University
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
UniS CS297 Graphics with Java and OpenGL Blending.
2D Output Primitives Points Lines Circles Ellipses Other curves Filling areas Text Patterns Polymarkers.
1 CSCE 441: Computer Graphics Scan Conversion of Polygons Jinxiang Chai.
CS552: Computer Graphics Lecture 17: Scan Conversion (Special Cases)
COMPUTER GRAPHICS CS 482 – FALL 2015 NOVEMBER 10, 2015 VISIBILITY CULLING HIDDEN SURFACES ANTIALIASING HALFTONING.
Computer Graphics CC416 Week 14 Filling Algorithms.
Attributes of Graphics Primitives Chapter 4
Computer Graphics Lecture 08 Taqdees A. Siddiqi Computer Graphics Filled Area Primitives I Lecture 08 Taqdees A. Siddiqi
Computer Graphics CC416 Lecture 04: Bresenham Line Algorithm & Mid-point circle algorithm Dr. Manal Helal – Fall 2014.
ATTRIBUTE OF OUTPUT PRIMITIVES. Attribute of Output Primitives 30/9/2008 A.Aruna/Assistant professor/IT/SNSCE 2 Definition Line Attribute Curve Attribute.
Antialiasing. What is alias? Alias - A false signal in telecommunication links from beats between signal frequency and sampling frequency (from dictionary.com)
Computer Graphics I, Fall 2010 Scan conversion algorithms.
Pattern filling in scan-conversion Antialiasing
Attributes of Graphics Primitives Hearn & Baker Chapter 4
Introduction to Polygons
University of New Mexico
Implementation III.
Advanced Computer Graphics:
Introduction to Computer Graphics with WebGL
o عَلَّمَهُ الْبَيَانَ
Rasterization and Antialiasing
Lecture 13 Clipping & Scan Conversion
Computer Graphics Implementation III
Rasterization and Antialiasing
Primitive Drawing Algorithm
Primitive Drawing Algorithm
Implementation III Ed Angel Professor Emeritus of Computer Science
CSC418 Computer Graphics Aliasing Texture mapping.
Presentation transcript:

Attributes of Graphics Primitives Hearn & Baker Chapter 4 Some slides are taken from Robert Thomsons notes.

OVERVIEW Color Point and line attributes Curve attributes Fill-area attributes Scan-line fill Fill-area methods Character attributes Antialising

Attributes Attribute parameter is a parameter that affects the way a primitive is to be displayed. Some attribute parameters determine the fundamental characteristics of a primitive. –Color –Size For now, we consider only those attributes that control the basic display properties of primitives. –Lines can be dotted or dashed, fat or thin, and blue or orange. –Areas might be filled with one color or with a multicolor pattern.

Color Basic attribute for all primitives. RGB color components –Either store the color code into frame buffer –Or use index values to reference the color-table entries.

Color tables

Line attributes Line width –Plot a vertical span of pixels in each column (slope <=1) –Line width is equal to number of pixels in each column

Line width Problem –Width of a line depends on the slope line will be thinner by a factor of 1/sqrt(2)

Line width Another problem: line ends –Horizontal or vertical line ends regardless of slope Solution –Add line caps

Line Attributes Butt cap Round cap Projecting square cap Miter join Round Join Bevel join

Pen and Brush Options Using packages, lines can be displayed with pen or brush selections. –shape, size, and pattern. Some possible pen or brush shapes

The shapes can be stored in a pixel mask –I.e., a rectangular pen can be implemented with the following mask

Area Filling How can we generate a solid color/patterned polygon area?

Triangle fill : color Interpolation span C1C1 C3C3 C2C2 C5C5 C4C4 scan line C 1 C 2 C 3 specified by glColor or by vertex shading C 4 determined by interpolating between C 1 and C 3 C 5 determined by interpolating between C 2 and C 3 interpolate between C 4 and C 5 along span

Edge equations An edge equations is the equations of the line defining the edges –Each line defines 2 half-spaces

Edge equations A triangle can be defined as the intersection of three positive half-spaces A 1 x + B 1 y + C 1 < 0 A 2 x + B 2 y + C 2 < 0 A 3 x + B 3 y + C 3 < 0 A 1 x + B 1 y + C 1 > 0 A 3 x + B 3 y + C 3 > 0 A 2 x + B 2 y + C 2 > 0

Edge Equations So…simply turn on those pixels for which all edge equations evaluate to > 0: Lots of implementation details to consider….

(Line Walking approach) (When deciding if scan-line is inside the polygon)

Area Filling (Scan line Approach) For each scan line (increasing y order) (1) Find intersections (the extrema of spans) (2) Sort intersections (increasing x order) (3) Fill in between pair of intersections

Data Structure

8

AF' FE' ED AB CD CB

Area Filling – for irregular areas Paint the interior point by point out to the boundary. Pixel Adjacency 8-connected 4-connected

Area Filling – for irregular areas Boundary-Fill Algorithm –starting at a point inside the figure and painting the interior in a specified color or intensity. Used in interactive painting packages Like identifying connected components

the fill

Boundary Filling

Fill pattern

Hollow display of a polygon glPolygonMode (face, displayMode); Face: GL_FRONT, GL_BACK, GL_FRONT_AND_BACK displayMode : GL_LINE no fill GL_POINTS vertex points only GL_FILLfill (default) glColor3f (0.0, 1.0, 0.0); \\blue fill \\generate polygon glColor3f (1.0, 0.0, 0.0); \\red line glPolygonMode (GL_FRONT, GL_LINE); \\generate polygon

Aliasing in CG Which is the better?

Aliasing in Computer Graphics Digital technology can only approximate analogue signals through a process known as sampling The distortion of information due to low-frequency sampling (undersampling) Choosing an appropriate sampling rate depends on data size restraints, need for accuracy, the cost per sample… Errors caused by aliasing are called artifacts. Common aliasing artifacts in computer graphics include jagged profiles, disappearing or improperly rendered fine detail, and disintegrating textures.

The Nyquist Theorem The sampling rate must be at least twice the frequency of the signal or aliasing occurs ( twice the frequency of the highest frequency component)

Aliasing In order to have any hope of accurately reconstructing a function from a periodically sampled version of it, two conditions must be satisfied: –The function must be bandlimited. –The sampling frequency must be at least twice the maximum frequency of the function. Satisfying these conditions will eliminate aliasing.

Polygon Aliasing Aliasing problems can be serious for polygons –Jaggedness of edges –Small polygons neglected –Need compositing so color of one polygon does not totally determine color of pixel All three polygons should contribute to color

Antialiasing Antialiasing methods try to combat the effects of aliasing. Two major categories of antialiasing techniques –prefiltering –postfiltering.

Prefiltering Central idea is to consider the pixel as an area, not a point, and calculate the pixel colour value from a weighted sum of the colours present inside the area. –e.g. In line-drawing, think of the line as a long rectangle, not the minimal line of pixels found by Bresenham’s method.Pixels partly covered by this rectangle would be shaded grey

Anti-aliasing through area averaging How can we make the line less jagged and avoid aliasing? Bresenham's algorithm is optimal for drawing the line if you only have 2 colors. It chooses the closest set of pixels to the line. However, if you have more than 2 colors, you can color the pixels differently depending on the distance to the line. Suppose each pixel is square, 1 unit high and 1 unit wide. Suppose the line is 1 unit in width. Shade each pixel according to the percentage of that pixel covered by the line.

Antialiasing by Area Averaging Color multiple pixels for each x depending on coverage by ideal line without antialiasing antialiased magnified

Antialiasing (postfiltering) Postfiltering first supersamples the signal in its unfiltered form and then filters out the high frequency from the supersamples. Increase the sampling rate by treating the screen as if it had a finer grid resolution than is actually available

(non-adaptive) Super-Sampling Split single pixel into sub-pixels. Pixel’s final color is a mixture of sub-pixels’ colors. Simple method: Sample at the middle of each sub-pixel. Then, pixel’s color is the average of the sub-pixels’ color. Pixels Sub-divide into sub-pixels

Super-Sampling a Zero-Width Line Apply Bresenham’s algorithm at sub- pixel level Sub-divide each pixel into sub-pixels, for example 4x4 sub-pixels Each pixel can have a maximum of 4 colored sub-pixels How many sub-pixels are colored? Assign color Fraction of pixel’s color to be line’s color

Super-Sampling a Line with Non-Zero Width A line that is one-pixel wide. For every pixel: Maximum number of sub-pixels inside line = 16 A sub-pixel is considered in if its lower-left corner is inside the line Fraction of sub-pixels are in = fraction of color of the pixel should be line color 0 0 5/16 9/16 10/16 15/16 13/16 7/16 8/16 2/16 0 0