CS 325 Computer Graphics

Similar documents
Computer Graphics. Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Computer Graphics. Chapter 4 Attributes of Graphics Primitives. Somsak Walairacht, Computer Engineering, KMITL 1

Polygon Filling. Can write frame buffer one word at time rather than one bit. 2/3/2000 CS 4/57101 Lecture 6 1

2D Graphics Primitives II. Additional issues in scan converting lines. 1)Endpoint order. Want algorithms to draw the same pixels for each line

Rendering. Basic Math Review. Rasterizing Lines and Polygons Hidden Surface Remove Multi-pass Rendering with Accumulation Buffers.

Einführung in Visual Computing

Scan Conversion. Drawing Lines Drawing Circles

Attributes of Graphics Primitives

COMP371 COMPUTER GRAPHICS

Incremental Form. Idea. More efficient if we look at d k, the value of the decision variable at x = k

Intro to Modeling Modeling in 3D

Lesson 1. Unit 2 Practice Problems. Problem 2. Problem 1. Solution 1, 4, 5. Solution. Problem 3

Graphics (Output) Primitives. Chapters 3 & 4

Computer Graphics. The Two-Dimensional Viewing. Somsak Walairacht, Computer Engineering, KMITL

2D rendering takes a photo of the 2D scene with a virtual camera that selects an axis aligned rectangle from the scene. The photograph is placed into

SE Mock Online Test 1-CG

Chapter 3. Sukhwinder Singh

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

UNIT 2 GRAPHIC PRIMITIVES

Computer Graphics. - Rasterization - Philipp Slusallek

Scan line algorithm. Jacobs University Visualization and Computer Graphics Lab : Graphics and Visualization 272

Computational Geometry. Geometry Cross Product Convex Hull Problem Sweep Line Algorithm

Computer Graphics (CS 543) Lecture 10: Rasterization and Antialiasing

CS 4731/543: Computer Graphics Lecture 7 (Part I): Raster Graphics: Polygons & Antialiasing. Emmanuel Agu

1 Introduction to Graphics

For this assignment, you are to implement three line drawers and a polygon drawer.

Lecture 2 October 31, 2005

CS 543: Computer Graphics. Rasterization

Pipeline implementation II

(Refer Slide Time: 00:02:00)

Announcements. Midterms graded back at the end of class Help session on Assignment 3 for last ~20 minutes of class. Computer Graphics

Line Drawing. Introduction to Computer Graphics Torsten Möller / Mike Phillips. Machiraju/Zhang/Möller

Course Guide (/8/teachers/teacher_course_guide.html) Print (/8/teachers/print_materials.html) LMS (/8

Graphics Hardware and Display Devices

Surface shading: lights and rasterization. Computer Graphics CSE 167 Lecture 6

? Which intermediate. Recall: Line drawing algorithm. Programmer specifies (x,y) of end pixels Need algorithm to determine pixels on line path

Implementation III. Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico

Rasterization: Geometric Primitives

OpenGL Graphics System. 2D Graphics Primitives. Drawing 2D Graphics Primitives. 2D Graphics Primitives. Mathematical 2D Primitives.

Chapter 8: Implementation- Clipping and Rasterization

Graphics Output Primitives

CSCI 4620/8626. Computer Graphics Clipping Algorithms (Chapter 8-5 )

CS 325 Computer Graphics

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Computer Graphics CS 543 Lecture 11 (Part 1) Polygon Filling & Antialiasing

Graphics Programming Principles and Algorithms

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination (Total: 100 marks)

CSCI 4620/8626. Coordinate Reference Frames

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

1. (10 pts) Order the following three images by how much memory they occupy:

Course Number: Course Title: Geometry

pine cone Ratio = 13:8 or 8:5

UNIT -8 IMPLEMENTATION

Glossary of dictionary terms in the AP geometry units

Line Drawing. Foundations of Computer Graphics Torsten Möller

Fall CSCI 420: Computer Graphics. 7.1 Rasterization. Hao Li.

Practical Linear Algebra: A Geometry Toolbox

Unit 2 Output Primitives and their Attributes

Topics. From vertices to fragments

PLC Papers Created For:

CHAPTER 2 REVIEW COORDINATE GEOMETRY MATH Warm-Up: See Solved Homework questions. 2.2 Cartesian coordinate system

3D graphics, raster and colors CS312 Fall 2010

High School Geometry. Correlation of the ALEKS course High School Geometry to the ACT College Readiness Standards for Mathematics

Agenda. Polygon Terminology Types of polygons Inside Test Polygon Filling Algorithms. Scan-Line Polygon Fill Algorithm Flood-Fill Algorithm

CS 325 Computer Graphics

Prof. Feng Liu. Fall /25/2018

In today s lecture we ll have a look at: A simple technique The mid-point circle algorithm

Hidden-Surface Removal.

Rasterization, or What is glbegin(gl_lines) really doing?

Computer Science 474 Spring 2010 Viewing Transformation

CS 248 Assignment 2 Polygon Scan Converter. CS248 Presented by Abe Davis Stanford University October 17, 2008

CS602 MCQ,s for midterm paper with reference solved by Shahid

Scan Conversion of Polygons. Dr. Scott Schaefer

CS-321 Thursday 12 September 2002 Quiz (3 pts.) What is the purpose of a control grid in a cathode ray tube (CRT)?

CSCI 4620/8626. Primitives and Attributes

Texture Mapping. Texture (images) lecture 16. Texture mapping Aliasing (and anti-aliasing) Adding texture improves realism.

lecture 16 Texture mapping Aliasing (and anti-aliasing)

Filled Area Primitives. CEng 477 Introduction to Computer Graphics METU, 2007

Polygons. Discuss with a partner what a POLYGON is. Write down the key qualities a POLYGON has. Share with the class what a polygon is?

Elementary Planar Geometry

Investigating Properties of Kites

CSCI 420 Computer Graphics Lecture 14. Rasterization. Scan Conversion Antialiasing [Angel Ch. 6] Jernej Barbic University of Southern California

CS 130 Final. Fall 2015

How do we draw a picture?

Objective: Construct perpendicular line segments on a rectangular grid.

Chapter - 2: Geometry and Line Generations

Computer Science 426 Midterm 3/11/04, 1:30PM-2:50PM

Intersection of an Oriented Box and a Cone

Rasterization. Rasterization (scan conversion) Digital Differential Analyzer (DDA) Rasterizing a line. Digital Differential Analyzer (DDA)

heptagon; not regular; hexagon; not regular; quadrilateral; convex concave regular; convex

CS488 2D Graphics. Luc RENAMBOT

CS452/552; EE465/505. Clipping & Scan Conversion

Introduction to Geometry

CS559: Computer Graphics. Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008

An angle that has a measure less than a right angle.

From Vertices To Fragments-1

NEW YORK GEOMETRY TABLE OF CONTENTS

M2 GEOMETRY REVIEW FOR MIDTERM EXAM

Polygons. Discuss with a partner what a POLYGON is. Write down the key qualities a POLYGON has. Share with the class what a polygon is?

Transcription:

CS 325 Computer Graphics 02 / 06 / 2012 Instructor: Michael Eckmann

Today s Topics Questions? Comments? Antialiasing Polygons Interior points Fill areas tiling halftoning dithering

Antialiasing Aliasing is the distortion we see when we undersample. The jaggedness stairstep quality of lines is an example of aliasing. Good example of undersampling figure 6-58 Solutions: Higher addressability e.g. Move from a 800x600 grid to a 1280x1024 grid and your lines will look smoother. When keeping fixed addressability --- then we can change the intensity of the pixels being turned on. And instead of turning on one pixel at full intensity, we appropriately weight the intensities of two pixels at each step to cause the illusion of a point at some intermediate location between the two pixel centers.

Antialiasing Supersampling is a technique to treat the screen as a finer grid than is actually addressable and plot the points by turning on multiple points in the finer grid. Then when ready to display --- use the finer grid points to determine the intensities of the pixels of the actual screen. Example --- divide each actual addressable pixel into 9 (3x3) finer subpixels. Draw a Bresenham line on the subpixels. Then base the intensity of actual pixel on how many of the 9 subpixels would be on. 3 subpixels is max, so that's full intensity 2 subpixels could cause the pixel to be at 2/3 intensity 1 subpixel on could cause the pixel to be at 1/3 intensity 0 would be off

Antialiasing Alternately, we could use a weighting mask that would give more weight to the center subpixel of the 3x3 grid 1 2 1 2 4 2 1 2 1 Another alternative is to treat the line as a rectangle of width 1 pixel & draw it on the finer grid (w/ 9 subpixels per pixel). Then how many of the 9 subpixels are on (on = bottom left corner of subpixel is inside the rectangle) determines the intensity of pixel (9 = full intensity, 8 = 8/9 intensity, etc.) This is better than the three intensity levels of the other supersampling method.

Antialiasing Area sampling is a technique that computes areas of overlap of each pixel with the object (e.g. line or polygon) to be displayed. This is similar to the supersampling method described last (treating the line as a rectangle), but instead of just 9 different intensities, let the intensity of a pixel be the area of the rectangle that overlaps the pixel / the area of the whole pixel.

Antialiasing There are other techniques to do antialiasing --- filtering techniques. These are similar to the discrete mask two slides ago, except they work with a continuous function to determine the weightings of the pixels. Examples on the next slide show a box, a cone and a Gaussian. The volumes of these are normalized to 1 and to determine the weighting of a pixel we integrate the function over the pixel surface. Since integrating is expensive (in time) lookup tables can be used.

Antialiasing

Antialiasing also helps with... Notice: without antialiasing, compare a line with slope = 1 made up of n pixels and a line with slope = 0 made up of n pixels. The slope = 1 line is SQRT(2) longer but is made up of the same number of pixels. What do you think is the visual effect of this?

Antialiasing helps total intensity See figures 6-63 & 6-64 in text. In addition to lines looking straighter, when using the antialiasing technique that treats lines as having some finite width, lines of different angles will not have different total intensities.

Polygons 3 or more vertices describe a polygon. The vertices are connected with line segments (called an edge, or a side). Each edge can only have endpoints in common with any other edge. Definition of convex polygon Def 1: All interior angles are < 180 degrees Def 2: The interior lies completely on 1 side of the infinite extension of any edge. Def 3: If we select any two interior points, the line segment joining them is also fully in the interior of the polygon Definition of concave polygon Not convex.

Polygons Degenerate polygons are Those with 3 or more collinear vertices Those with repeated vertices Etc.

Polygon interior points A common operation is to determine if a point is in the interior of a polygon or not. One way to do it is, for some point, draw a horizontal line from that point to a distant point outside the possible area of the polygon and count how many times the horizontal line crosses edges of the polygon. If the line crosses an odd number of edges, then it is an interior point. If it crosses an even number of edges, then it is exterior. Example on board.

Polygon interior points What happens when the horizontal line crosses a vertex. Should it be counted as 1 or 2? Example on board.

Polygon interior points What happens when the horizontal line crosses a vertex. Should it be counted as 1 or 2? If the vertex is a local maximum or a local minimum then count it as 2. Otherwise count it as 1.

Polygon fill areas Polygons in OpenGL are specified by vertices. It is good to get into the habit now that you specify the vertices in counterclockwise order. The reason for this is, when we do some things later this semester like displaying 3D objects, we're going to care about which side (face) of the polygon is visible. The front face of a polygon is visible when its vertices are in counterclockwise order. We'll know if we're seeing the back face of a polygon if they are in clockwise order.

Polygon fill areas To do a scanline fill of a polygon (see figure 6-49). Determine the intersections (crossings) of the horizontal line (y=c) with the edges (y=mx + b) of the polygon. Sort the crossings (x coordinates) from low to high (left to right). There will be an even number of crossings, so draw horizontal lines between the first two crossings, then the next 2 and so on. If the scanline goes through a vertex Add the crossing to the list twice if it's a local max or min. Add the crossing only once otherwise. Horizontal edges of a polygon can be ignored (not turned on.) Example on board.

Polygon fill areas Another way to determine how many to count if the scanline goes through a vertex If the two edges are on the same side of the scanline, then add it twice. If the two edges are on different sides of the scanline, then add it once. To check for this, we can compare the y coordinates of the 3 vertices in question (draw on board) in either clockwise or counterclockwise fashion If all 3 are monotonically increasing or all 3 are monotonically decreasing then the two edges are on different sides.

Polygon fill areas Edge coherence properties can be used to speed up the calculation of the crossings of the scanline and edges. The crossing x-coordinate of one scanline with an edge differs from the crossing of the x-coordinate of the next scanline only by 1/m as seen below. Assuming we're processing the fill from bottom to top and the y's increase as we go up, Assume scan line y k crosses an edge at (x k, y k ) and y k+1 crosses at (x k+1, y k+1 ) m = (y k+1 y k ) / (x k+1 x k ) (y k+1 y k ) = 1, so, m = 1 / (x k+1 x k ) and solve for x k+1 So, scan line y k+1 crosses that edge at (x k + 1/m, y k+1 ) This is less processing than doing the intersection of y = y k+1 with y = mx + b which is x = (y k+1 +b)/m.

Polygon fill areas Efficient polygon filling 1) proceed around edges in a clockwise or counterclockwise fashion 2) store each edge in an edge table 3) sort the edges based on the minimum y in the edge 4) process the scanlines in a bottom to top order 5) when the current scanline reaches the lower endpoint (with the min y) of the edge, that edge becomes active 6) active edges are sorted by their x coordinates (left to right) During any given scanline non-active edges can be marked as either finished, or not yet active. Horizontal edges are ignored. Example on board.

Polygon fill areas Masks Besides being filled with a solid color, polygons are sometimes filled with patterns. The process of filling an area with a pattern is called tiling. Fill patterns can be stored as rectangular arrays. The arrays are called masks and they are applied to the fill area and are usually smaller than the area to be filled. The mask needs a starting position within the area to be filled. Starting at this position the mask is replicated both vertically and horizontally. If the mask is an m n array, and starting position is (0,0) a pixel at (x, y) will be drawn with the color in mask((x mod n), (y mod m)). Example on board.

Polygon fill areas Section 17.9 Halftoning and dithering When there are very few intensity levels available (e.g. 2, black & white) to be displayed, halftoning is a technique that can provide more intensities with a tradeoff in addressability (less). Newspapers show grey level photos by displaying black circles. The black circles vary in size according to how dark that part of the photo should be. In graphics systems this halftoning technique is approximated with halftone patterns. Halftone patterns are typically n n squares of pixels where the number of pixels turned on in that pattern corresponds to the intensity desired.

Polygon fill areas How is halftoning a tradeoff between intensities and addressability (resolution)?

Polygon fill areas Guidelines to creating halftoning patterns With halftoning, one thing to be careful about is that the patterns can become apparent. That is undesirable. The intent is to have the viewer see the increase in intensities without noticing unintentional patterns. Avoid only horizontal or vertical or diagonal pixels on in the patterns to reduce the possibility of streaks. Further it is good to approximate the way that newspapers do it --- that is, concentrate on turning on pixels in the center of the pattern at each successive intensity. To minimize unintentional patterns to be displayed, we can evolve each successive grid pattern by copying it and turning on an additional pixel. See next slide figure 17-28.

Polygon fill areas

Polygon fill areas - Dithering Dithering Dithering refers to techniques for approximating halftones but without reducing addressability (resolution). An n n dither matrix D n is used to determine if a pixel should be on or off. The matrix is filled with the numbers from 0 to n 2 1 on page 534 (equation 17-49) there's a mistake, it should be the dither matrix D 4 15 7 13 5 3 11 1 9 12 4 14 6 0 8 2 10

Polygon fill areas - Dithering Example of dither matrix D 4 15 7 13 5 3 11 1 9 12 4 14 6 0 8 2 10 First, we scale the input intensities to the range 0 to n 2. So, for some pixel at (x, y) we compute i = x mod n and j = y mod n to find which element (i,j) of the matrix D n to compare to the desired intensity. If I(x,y) > D n (i,j) then the pixel is turned on, otherwise it is not. This has the effect of different intensities, without reducing resolution. But what gets lost?

Antialiasing Polygons Edges of polygons are lines. Lines (and therefore edges) have aliasing problems when made discrete. Antialiasing edges of polygons can be done using similar techniques as were used with lines. One way described below is the way I described antialiasing Bresenham lines. During scanline fill of a polygon, if the edge falls between two pixels on the scanline, then the intensities of the pixels depend on how close to the centers of the two pixels the line falls. The pixel at (x j, y k ): could be set to have x j+1 x and The pixel at (x j+1, y k ) would then be set to have x x j Pixels that fall fully within the interior of a polygon are set to full intensity.

2D transformations Points are usually specified as vectors Matrices represent transformations Examples on the board.