Chapter 71 Computer Graphics - Chapter 7 From Vertices to Fragments Objectives are: How your program are processed by the system that you are using, Learning.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Graphics Pipeline.
Computer Graphics Lecture 8 Arbitrary Viewing II: More Projection, Clipping and Mathematics of 3D Viewing.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
1 Clipping. 2 Transformation Sequence X Y Z X Y Z X Y Z X Y Z Object Coords. Eye Coords. Clip Coords. Normalized Device Coords. Screen Coords. Implementation:
Two-Dimensional Viewing Jehee Lee Seoul National University.
Computer Graphics Viewing.
CMPE 466 COMPUTER GRAPHICS Chapter 8 2D Viewing Instructor: D. Arifler Material based on - Computer Graphics with OpenGL ®, Fourth Edition by Donald Hearn,
School of Computer Science University of Seoul. Graphics pipeline Algorithms for the tasks in the pipeline.
Introduction to Computer Graphics Chapter 6 – 2D Viewing Pt 2 1.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Interpolation Clipping.
Informationsteknologi Thursday, November 22, 2007Computer Graphics - Class 111 Today’s class Clipping Parametric and point-normal form of lines Intersecting.
Implementation Dr. Amy Zhang. Reading 2  Hill, Chapters  Hill, Chapter 10.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Clipping.
University College Dublin1 Clipping u Clipping is the removal of all objects or part of objects in a modelled scene that are outside the real-world window.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
1 Chapter 5 Viewing. 2 Perspective Projection 3 Parallel Projection.
1 Computer Graphics Assistant Professor Dr. Sana’a Wafa Al-Sayegh 2 nd Semester ITGD3107 University of Palestine.
Clipping Apart from clipping to the view volume, clipping is a basic operation in many other algorithms –Breaking space up into chunks –2D drawing and.
Two-Dimensional Viewing
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
Objectives Introduce basic implementation strategies Clipping Scan conversion.
1 Chapter 8 Implementation of a Renderer. 2 Rendering as a Black Box.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
CSE Real Time Rendering Week 9. Post Geometry Shaders Courtesy: E. Angel and D. Shreiner – Interactive Computer Graphics 6E © Addison-Wesley 2012.
Computer Graphics Lecture 32 Fasih ur Rehman. 3D Transforms The idea of 3D transforms is the same as that of 2D – A 3D point is represented by (x, y,
Windows, Viewports, and Clipping
1Computer Graphics Implementation II Lecture 16 John Shearer Culture Lab – space 2
Implementation II Ed Angel Professor of Computer Science, Electrical and Computer Engineering, and Media Arts University of New Mexico.
Implementation II.
EEL Introduction to Computer Graphics
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Implementation of a Renderer Consider Programs are processd by the system line & polygon, outside the view volume Efficiently Understanding of the implementation.
Computer Graphics Lecture 20 Fasih ur Rehman. Last Class Clipping – What is clipping – Why we do clipping – How clipping is done.
Computer Graphics I, Fall 2010 Implementation II.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
Graphics Graphics & Graphical Programming Lecture 23 - Viewing & Clipping.
A.Aruna/Assistant Professor/SNSCE
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphics Clipping.
Computer Graphics Implementation II
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
Computer Graphics Shading in OpenGL
Clipping Aaron Bloomfield CS 445: Introduction to Graphics Fall 2006
Concepts, algorithms for clipping
3D Clipping.
The Graphics Rendering Pipeline
Models and Architectures
Implementation I Ed Angel
Graphics Pipeline Clipping
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
WINDOWING AND CLIPPING
Implementation II Ed Angel Professor Emeritus of Computer Science
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
Models and Architectures
© University of Wisconsin, CS559 Fall 2004
Models and Architectures
Introduction to Computer Graphics with WebGL
SUBJECT : COMPUTER GRAPHICS
Clipping University of British Columbia CPSC 314 Computer Graphics
Implementation I Ed Angel Professor Emeritus of Computer Science
Implementation II Ed Angel Professor Emeritus of Computer Science
COMPUTER GRAPHICS Clipping
Presentation transcript:

chapter 71 Computer Graphics - Chapter 7 From Vertices to Fragments Objectives are: How your program are processed by the system that you are using, Learning to efficiently use a graphics system by learning the implementation process, and Learn about capabilities that utilizes the frame buffer. Learning implementation requires studying algorithms. We must be careful to consider issues such as theoretical versus practical performance, hardware versus software implementations. Of course, we can test whether an OpenGL implementation is working correctly. How? By looking at the outcome. But there are many different algorithms that can be employed, are we testing all of them to find the best?

chapter 72 Major Tasks There are four major tasks that any implementation must perform to render a geometric entity. 1. Modeling Set of vertices that specifies a set of geometric objects. 2. Geometric processing View volume, hidden-surface removal (visible surface determination), also called front-end-processing. 3. Rasterization Rasterization or scan conversion. 4. Display aliasing

chapter 73 Basic Implementation Strategies There are two major approaches to implementation. They differ in the order that process the required processing steps. A program takes a set of vertices specifying a geometric object, and produces as output pixels in the frame buffer. If the program produces an image, it must assign every pixel. If it produces a correct image, it must process every geometric primitive and every light source. Thus, a program has some loops that iterate over these basic variables. The question then is; which variable controls the outer loop? 1. Image Oriented (sort first) The loop is over pixels, or rows of pixels called scan lines, that constitute the frame buffer. for(each_pixel) assign_a_color(pixel); 2. Object Oriented (sort last) The outer loop is over the objects. We can think of the program as controlled by a loop of this form: for(each_object) render(object); A pipeline renderer fits this description.

chapter 74 Implementation of Transformations In the homogenous coordinate, the affine transformations are achieved by concatenating a sequence of matrices. 1. Object (world) coordinates 2. Eye (camera) coordinates 3. Clip coordinates 4. Normalized device coordinates 5. Window (screen) coordinates. Clipping is the process of determining which primitives, and parts of primitives, fit within the clipping volume defined by the application program. When a component of a clipped vertex is not equal to 1, we have to do a perspective division to convert back from homogeneous coordinates to normal 3-D coordinates.

chapter 75 Implementation of Transformations – cont. We do this, because, all primitives that can possibly be displayed lie within the cube: This coordinate system is called normalized device coordinates, because it depends on neither the original application units nor the particulars of the display device. The final orthographic projection is: x p = x, y p = y, z p = 0. What if we had a 3-D viewports?

chapter 76 Line Segment Clipping A clipper decides which primitives, or parts of primitives, appear on the display. Primitives that fit within the specified view volume pass through the clipper, or are accepted. Primitives that cannot appear on the display are eliminated, or rejected or culled. Primitives that are only partially within the view volume must be clipped such that any part lying outside the volume is removed. Primitives may be clipped after they have been projected from three to two dimensional objects.

chapter 77 Cohen-Sutherland Clipping The sides of the window is extended to infinity, thus the space is broken to 9 regions. Can you write the b 1, b 2 and b 3 ? remember these: Consider a line segment whose outcodes are given by o 1 = outcode(x 1, y 1 ) and o 2 = outcode(x 2, y 2 ). What are the four cases ?

chapter 78 Cohen-Sutherland Clipping – cont. Case (1) : o 1. = o 2 = 0 Case (2): Or vise versa Case (3): Case (4):

chapter 79 Cohen-Sutherland Clipping – cont. This algorithm works best when there are many line segments, but few are actually displayed. In this case, most of the line segments lie fully outside one or two of the extended sides of the clipping rectangle, and thus can be eliminated on the basis of their outcodes. What are the possible problems you may face, when you use this method? Let’s solve this example:

chapter 710 Liang-Barsky Clipping If we use the parametric form for lines, we can approach the clipping of line segments in a different and more difficult manner. Suppose the two endpoints are given as p 1 =[x 1, y 1 ] T and p 2 =[x 2, y 2 ] T the unique line that crosses these two points is: Or as two scalar equations: Advantages? Possible values for ? How do we distinguish between (a) and (b)?

chapter 711 Polygon Clipping So are we going to clip polygons against rectangular windows for display? We can generate polygon-clipping algorithms directly from line-clipping algorithms by clipping the edges of the polygon successively. However, there is a problem with this algorithm. A polygon is an object, and, Depending on the form of the polygon, we can generate more than one polygon object by clipping. A Solution?

chapter 712 Polygon Clipping - cont So are we going to clip polygons against rectangular windows for display? There is no problem with convex polygons, so the options for treating concave polygons are: 1) forbid it 2) divide (tessellate) a given polygon into a set of convex polygons. A line-segment clipper can be viewed as a black box whose input is the pair of vertices from the segment to be tested and clipped, and whose output is either either a pair of vertices corresponding to the clipped line segment, or nothing if the line lies outside.

chapter 713 Polygon Clipping - cont We can clip only against one of the sides. Suppose, we clip against the top. We can think of this operation as a black box in which both the input and output are pairs of vertices, with the value of y max as a parameter known to the clipper.

chapter 714 Polygon Clipping - cont Thus, the clipper returns one of the three pairs: 1){(x 1, y 1 ), (x 2, y 2 )}, 2) {(x 1, y 1 ), (x i, y max )}, or 3) {(x i, y max ), (x 2, y 2 )}. We can clip against the bottom, right, and left lines independently, using the same equations with the roles of x and y exchanged as necessary, and the values for sides of the window inserted.

chapter 715 Polygon Clipping – Example of pipeline clipping

chapter 716 Clipping of Other Primitives Sometimes, we may want to clip objects before they reach the hardware or to employ algorithms optimized for other primitives. Bounding Boxes If we try to use clipping to clip a polygon with many sides, we may end up with a situation where the polygon lie outside the clipping window. We can exploit this observation through the use of bounding box or extent of polygon: The smallest rectangle, aligned with the window, that contains the polygon. How can we calculate such a window?

chapter 717 Bounding Boxes – cont. What is next? Three situations may appear: 1) Polygon outside the window; no clipping is necessary. Why? 2) The polygon inside the window, we can determine that it is inside by comparing the bounding box with the window. 3) This case is more complicated. When a polygon partially inside. In such a case, we have to carry detail clipping, using all the edges of the polygon.

chapter 718 Curves, Surfaces, and Text The variety of curves and surfaces that we can define mathematically makes it difficult to find general algorithms for processing these objects. The potential difficulties can be seen from the two-dimensional curves such as those shown here. If we have a simple curve, such as a quadratic, we can compute intersections. This cost more than that of a line. For more complex curves, we need to calculate intersections. That is a difficult task. We can avoid such problems by approximating curves with line segments and surfaces with planar polygons. The use of bounding boxes can prove helpful.

chapter 719 Curves, Surfaces, and Text The handling of text differs from API to API, with many APIs allowing the user to specify how detailed a rendering of text is required. There are two extremes: 1) Text is stored as bit patterns and is rendered directly by the hardware without any geometric processing. Any required clipping is done in the frame buffer. 2) Text is defined like any other geometric object, and is then processed through the standard viewing pipeline. OpenGL allows both types. The user can decide between the bitmap or the stroke characters. We can do the clipping until after objects have been projected and converted into screen coordinates. So clipping can be done in the frame buffer through a technique called, scissoring. However, it is better to to clip geometric entities before the vertices reach the frame buffer.

chapter 720 Clipping in Three Dimensions In three dimension, we clip against a bounded volume, rather than against a bounded region in the plane.

chapter 721 Clipping in Three Dimensions – cont. In three dimension, we clip against a bounded volume, rather than against a bounded region in the plane. The concepts of all three clipping algorithms can be extended to 3-D case. For example, for the Cohen-Sutherland algorithm, we replace the 4-bit outcode with a 6-bit outcode. What do we use the extra 2 bits for? For the Liang-Barsky algorithm, we add The difference between 2-D and 3-D clippers is that instead of clipping lines against lines, as we do in 2-D, we are clipping either lines against surfaces or surface against surfaces. Cohen- Sutherland regions in 3-D

chapter 722 Clipping in Three Dimensions – cont. If we write the line and plane equations in matrix form (where n is the normal to the plane and p 0 is a point on the plane), we must solve the equation: For the corresponding to the point of Intersection: Plane-line intersection Clipping for orthographic viewing

chapter 723 Hidden-Surface Removal (All very Important) Object-Space and Image-Space Approaches Back face Removal The z-Buffer Algorithm Depth Sort and the Painter’s Algorithm The Scan-line Algorithm Scan Conversion Pixels can be set to a given color using a call like: write_pixel(int ix, int iy, int value); The argument value can be either an index, in color-index mode, or a pixel value, such as a 32-bit number in RGBA-color mode. The simplest scan conversion algorithm is DDA algorithm stands for the Digital Differential Analyzer.

chapter 724 Scan Conversion