Computer Graphics Geometry and Transform

Similar documents
Computer Graphics Geometry and Transform

3D Rendering Pipeline (for direct illumination)

Clipping and Scan Conversion

Computer Graphics Geometric Transformations

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

COMP371 COMPUTER GRAPHICS

CS123 INTRODUCTION TO COMPUTER GRAPHICS. Clipping. Concepts, Algorithms for line clipping. 1 of 16. Andries van Dam. Clipping - 10/12/17

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

Computer Graphics (CS 543) Lecture 9 (Part 2): Clipping. Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

The Traditional Graphics Pipeline

CS 543: Computer Graphics. Rasterization

From Vertices To Fragments-1

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

The Traditional Graphics Pipeline

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

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

Graphics (Output) Primitives. Chapters 3 & 4

Unit 3 Transformations and Clipping

Clipping & Culling. Lecture 11 Spring Trivial Rejection Outcode Clipping Plane-at-a-time Clipping Backface Culling

The Traditional Graphics Pipeline

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

Cs602-computer graphics MCQS MIDTERM EXAMINATION SOLVED BY ~ LIBRIANSMINE ~

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

Last class. A vertex (w x, w y, w z, w) - clipping is in the - windowing and viewport normalized view volume if: - scan conversion/ rasterization

Einführung in Visual Computing

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

2D Image Synthesis. 2D image synthesis. Raster graphics systems. Modeling transformation. Vectorization. u x u y 0. o x o y 1

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

CS602 Midterm Subjective Solved with Reference By WELL WISHER (Aqua Leo)

Chapter 8: Implementation- Clipping and Rasterization

Examples. Clipping. The Rendering Pipeline. View Frustum. Normalization. How it is done. Types of operations. Removing what is not seen on the screen

Computer Graphics: 7-Polygon Rasterization, Clipping

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

Realtime 3D Computer Graphics Virtual Reality

Clipping. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

CHAPTER 1 Graphics Systems and Models 3

CS602- Computer Graphics Solved MCQS From Midterm Papers. MIDTERM EXAMINATION Spring 2013 CS602- Computer Graphics

Computer Graphics. - Clipping - Philipp Slusallek & Stefan Lemme

Topics. From vertices to fragments

CS 130 Final. Fall 2015

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

Computer Graphics. Rasterization. Teacher: A.prof. Chengying Gao( 高成英 ) School of Data and Computer Science

CS4620/5620: Lecture 14 Pipeline

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

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

Introduction Rasterization Z-buffering Shading. Graphics 2012/2013, 4th quarter. Lecture 09: graphics pipeline (rasterization and shading)

COMP30019 Graphics and Interaction Scan Converting Polygons and Lines

Pipeline and Rasterization. COMP770 Fall 2011

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Write C++/Java program to draw line using DDA and Bresenham s algorithm. Inherit pixel class and Use function overloading.

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

Two-Dimensional Viewing. Chapter 6

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

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

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

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

Computer Graphics Primitive Attributes

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

Rasterization. MIT EECS Frédo Durand and Barb Cutler. MIT EECS 6.837, Cutler and Durand 1

Hidden Surfaces II. Week 9, Mon Mar 15

CSE328 Fundamentals of Computer Graphics

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

CS488 2D Graphics. Luc RENAMBOT

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

(a) rotating 45 0 about the origin and then translating in the direction of vector I by 4 units and (b) translating and then rotation.

3D Polygon Rendering. Many applications use rendering of 3D polygons with direct illumination

2D Viewing. Viewing Pipeline: Window-Viewport Transf.

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

(Refer Slide Time: 00:02:00)

UNIT -8 IMPLEMENTATION

Identifying those parts of a scene that are visible from a chosen viewing position, and only process (scan convert) those parts

Aliasing. Can t draw smooth lines on discrete raster device get staircased lines ( jaggies ):

Computer Graphics D Graphics Algorithms

8. Hidden Surface Elimination

CS184 : Foundations of Computer Graphics Professor David Forsyth Final Examination

Computer Graphics 7 - Rasterisation

Polygon Triangulation

The graphics pipeline. Pipeline and Rasterization. Primitives. Pipeline

Computational Geometry [csci 3250]

CMT315 - Computer Graphics & Visual Computing

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

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

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

CS130 : Computer Graphics Lecture 2: Graphics Pipeline. Tamar Shinar Computer Science & Engineering UC Riverside

UNIT 2. Translation/ Scaling/ Rotation. Unit-02/Lecture-01

Werner Purgathofer

Pipeline implementation II

From Vertices to Fragments: Rasterization. Reading Assignment: Chapter 7. Special memory where pixel colors are stored.

CS 4731: Computer Graphics Lecture 21: Raster Graphics: Drawing Lines. Emmanuel Agu

Rasterization Computer Graphics I Lecture 14. Scan Conversion Antialiasing Compositing [Angel, Ch , ]

COMPUTER GRAPHICS COURSE. Rendering Pipelines

What is Clipping? Why do we Clip? Lecture 9 Comp 236 Spring Clipping is an important optimization

Chapter 3. Sukhwinder Singh

Graphics and Interaction Transformation geometry and homogeneous coordinates

COMP30019 Graphics and Interaction Transformation geometry and homogeneous coordinates

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

Rasterization. CS 4620 Lecture Kavita Bala w/ prior instructor Steve Marschner. Cornell CS4620 Fall 2015 Lecture 16

Institutionen för systemteknik

Transcription:

Computer Graphics 2012 5. Geometry and Transform Hongxin Zhang State Key Lab of CAD&CG, Zhejiang University 2012-09-26

上机实践 地址 :ftp://give.zju.edu.cn 用户 :cgzhang 密码 :cgzhang 请大家把上机作业结果和报告内容, 上传至 学号 _ 姓名 子目录 Computer Graphics 2012, ZJU

Today outline Triangle rasterization Basic vector algebra ~ geometry Antialiasing revisit Clipping Transforms (I) Computer Graphics 2012, ZJU

Previous lesson Primitive attributes Rasterization and scan line algorithm line, general polygon Computer Graphics 2012, ZJU

Polygon filling Polygon representation By vertex By lattice Polygon filling: vertex representation vs lattice representation Computer Graphics 2012, ZJU

Scan Line Method Proceeding from left to right the intersections are paired and intervening pixels are set to the specified intensity From top to down Algorithm Find the intersections of the scan line with all the edges in the polygon Sort the intersections by increasing X- coordinates Fill the pixels between pair of intersections Computer Graphics 2012, ZJU

Efficiency Issues in Scan Line Method Intersections could be found using edge coherence the X-intersection value x i+1 of the lower scan line can be computed from the X-intersection value x i of the proceeding scan line as List of active edges could be maintained to increase efficiency

Advantages of Scan Line method The algorithm is efficient Each pixel is visited only once Shading algorithms could be easily integrated with this method to obtain shaded area Efficiency could be further improved if polygons are convex, much better if they are only triangles Computer Graphics 2012, ZJU

Seed Fill Algorithms Assumes that at least one pixel interior to the polygon is known It is a recursive algorithm Useful in interactive paint packages Seed 4-connected 8 - connected Computer Graphics 2012, ZJU

Triangle Rasterization

Triangle Rasterization? Computer Graphics 2012, ZJU

Triangle Rasterization Computer Graphics 2012, ZJU

Compute Bounding Box Computer Graphics 2012, ZJU

Point Inside Triangle Test Computer Graphics 2012, ZJU

Line equation Computer Graphics 2012, ZJU

The Parallelogram Rule Computer Graphics 2012, ZJU

Dot Product Computer Graphics 2012, ZJU

Orthonormal Vectors Computer Graphics 2012, ZJU

Coordinates and Vectors Computer Graphics 2012, ZJU

Dot product between two vectors Computer Graphics 2012, ZJU

Cross Product Computer Graphics 2012, ZJU

Cross Product Computer Graphics 2012, ZJU

2~3D Computer Graphics 2012, ZJU

Vector operations Computer Graphics 2012, ZJU

Point operations Computer Graphics 2012, ZJU

illegal operations Computer Graphics 2012, ZJU

Directed line Computer Graphics 2012, ZJU

Perpendicular vector in 2D Computer Graphics 2012, ZJU

Line equation Computer Graphics 2012, ZJU

Normal to the line Computer Graphics 2012, ZJU

Line equation Computer Graphics 2012, ZJU

Line equation Computer Graphics 2012, ZJU

Singularities Computer Graphics 2012, ZJU

Handling singularity Computer Graphics 2012, ZJU

Antialiasing

Aliasing Aliasing is caused due to the discrete nature of the display device Rasterizing primitives is like sampling a continuous signal by a finite set of values (point sampling) Information is lost if the rate of sampling is not sufficient. This sampling error is called aliasing. Effects of aliasing are Jagged edges Incorrectly rendered fine details Small objects might miss Computer Graphics 2012, ZJU

Aliasing(examples) Computer Graphics 2012, ZJU

Aliasing(examples) Computer Graphics 2012, ZJU

Aliasing(examples) Computer Graphics 2012, ZJU

Antialiasing Application of techniques to reduce/eliminate aliasing artifacts Some of the methods are increasing sampling rate by increasing the resolution. Display memory requirements increases four times if the resolution is doubled averaging methods (post processing). Intensity of a pixel is set as the weighted average of its own intensity and the intensity of the surrounding pixels Area sampling, more popular Computer Graphics 2012, ZJU

Antialiasing (postfiltering) How should one supersample?

Area Sampling A scan converted primitive occupies finite area on the screen Intensity of the boundary pixels is adjusted depending on the percent of the pixel area covered by the primitive. This is called weighted area sampling 36

Area Sampling Methods to estimate percent of pixel covered by the primitive subdivide pixel into sub-pixels and determine how many sub-pixels are inside the boundary Incremental line algorithm can be extended, with area calculated as y+0.5 y filled area x-0.5 x y-0.5 x+0.5

Clipping Clipping of primitives is done usually before scan converting the primitives Reasons being scan conversion needs to deal only with the clipped version of the primitive, which might be much smaller than its unclipped version Primitives are usually defined in the real world, and their mapping from the real to the integer domain of the display might result in the overflowing of the integer values resulting in unnecessary artifacts

Clipping Why Clipping? How Clipping? Lines Polygons Note: Content from chapter 4. Lots of stuff about rendering systems and mathematics in that chapter.

Definition Clipping Removal of content that is not going to be displayed Behind camera Too close Too far Off sides of the screen

How would we clip? Points? Lines? Polygons? Other objects?

We ll start in 2D Assume a 2D upright rectangle we are clipping against Common in windowing systems Points are trivial >= minx and <= maxx and >= miny and <= maxy a b c

Line Segments What can happen when a line segment is clipped?

Cohen-Sutherland Line Clipping We ll assign the ends of a line outcodes, 4 bit values that indicate if they are inside or outside the clip area. y < ymin y > ymax x > xmax x < xmin 1001 1000 1010 0001 0000 0010 0101 0100 0110 xmin xmax ymax ymin

Outcode cases We ll call the two endpoint outcodes o 1 and o 2. If o 1 = o 2 = 0, both endpoints are inside. else if (o 1 & o 2 )!= 0, both ends points are on the same side, the edge is discarded. 1001 1000 1010 0001 0000 0010 0101 0100 0110

More cases else if (o 1!= 0) and (o 2 = 0), (or vice versa), one end is inside, other is outside. Clip and recompute one that s outside until inside. Clip edges with bits set May require two 1001 1000 1010 clip computations 0001 0000 0010 0101 0100 0110

Last case else if (o1 & o2) = 0, end points are on different sides. Clip and recompute. May have some inside part or may not May require up to 4 clips! 1001 1000 1010 0001 0000 0010 0101 0100 0110

Cohen-Sutherland Line-Clipping Algorithm To do the clipping find the end point that lies outside Test the outcode to find the edge that is crossed and determine the corresponding intersection point Replace the outside endpoint by intersection-point Repeat the above steps for the new line d 1001 c b 0000 f e 0100 a 1010 h g 0010 i 48

Sutherland-Hodgeman Polygon-Clipping Algorithm Polygons can be clipped against each edge of the window one edge at a time. Window/edge intersections, if any, are easy to find since the X or Y coordinates are already known. Vertices which are kept after clipping against one window edge are saved for clipping against the remaining edges. 49

Pipelined Polygon Clipping Clip Right Clip Top Clip Left Clip Bottom Because polygon clipping does not depend on any other polygons, it is possible to arrange the clipping stages in a pipeline. the input polygon is clipped against one edge and any points that are kept are passed on as input to the next stage of the pipeline. This way four polygons can be at different stages of the clipping process simultaneously. This is often implemented in hardware. Computer Graphics 2012, ZJU

Sutherland-Hodgeman Polygon Clipping Algorithm Polygon clipping is similar to line clipping except we have to keep track of inside/outside relationships Consider a polygon as a list of vertices Note that clipping v can increase the 5 v number of vertices! 4 Typically clip one v 1 edge at a time v 3 v 2 51

Sutherland-Hodgeman algorithm Present the vertices in pairs (v n,v 1 ), (v 1, v 2 ), (v 2,v 3 ),, (v n-1,v n ) For each pair, what are the possibilities? Consider v 1, v 2 Inside Outside Inside Outside Inside Outside Inside Outside v 2 v 1 v 1 v 2 v 1 v 2 output v 2 no output v 1 output i v 2 output i and v 2 52

Example v 5, v 1 s v 5 Inside Outside Inside Outside v 4 p v 1 v 1 v 2 v 3 Inside, Inside Output v 1 Current Output 53

v 1,v 2 v 5 Inside Outside Inside Outside v 4 s v 1 v 1 v 3 v 2 p v 2 Inside, Inside Output v 2 Current Output 54

v 2, v 3 v 5 Inside Outside Inside Outside v 4 v 1 v 1 v 3 p i 1 v 2 i 1 v 2 s Inside, Outside Output i 1 Current Output 55

v 3, v 4 v 5 Inside Outside v 4 p Inside Outside v 1 v 1 v 2 v 3 s v 2 i 1 Outside, Outside No output Current Output 56

v 4, v 5 last edge p v 5 Inside Outside Inside Outside v 5 i 2 v 4 s i 2 v 1 v 1 v 2 v 3 v 2 i 1 Outside, Inside Output i 2, v 5 Current Output 57

Transform

Transformations Procedures to compute new positions of objects Used to modify objects or to transform (map) from one co-ordinate system to another co-ordinate system As all objects are eventually represented using points, it is enough to know how to transform points. 3

Translation Is a Rigid Body Transformation Translation vector (T x,t y,t z ) or shift vector 4

Translating an Object y (T x, T y ) x 5

Scaling Changing the size of an object Scale factor (S x, S y, S z ) S y = 1 S x = 1 S x = S y 6

Scaling (contd.) Scaling is always with respect to the origin. The origin does not move. Scaling wrt a reference point can be achieved as a composite transformation 7

Scaling an Object y (x, y ) (x, y) x 8

Scaling an Object (x0,y0) Question8 : How?

Rotation Is a Rigid Body Transformation X= r cos(α+θ) =r cos α cos θ-rsin α sin θ =xcos θ-ysin θ 10

Rotation y (x, y ) θ (x, y) φ x 11

Rotation (contd.) Rotation also is wrt to a reference - A Reference Line in 3D A Reference Point in 2D Define 2D rotation about arbitrary point 12

y (x, y ) Rotate around (x r,y r ) θ (x, y) newx = x x r (x r, y r ) newy = y y r φ newxʹ = newx cosθ newy sinθ newyʹ = newy cosθ + newx sinθ x xʹ = newxʹ + x r yʹ = newyʹ + y r xʹ = x r +(x x r )cosθ (y y r )sinθ yʹ = y r +(y y r )cosθ +(x x r )sinθ

Shearing Produces shape distortions Shearing in x-direction 14

General Linear Transformation or Which of the following can be represented in this form? Translation Scaling Rotation 15