Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
CS 551 / 645: Introductory Computer Graphics Clipping Lines and Polygons.
Computer Graphics Viewing.
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.
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.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Graphics Pipeline Clipping CMSC 435/634. Graphics Pipeline Object-order approach to rendering Sequence of operations – Vertex processing – Transforms.
2-Dimension Viewing and Clipping
Objectives Review some advanced topics, including Review some advanced topics, including Chapter 8: Implementation Chapter 8: Implementation Chapter 9:
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Chapter 7: From Vertices to Fragments Ed Angel Professor of Computer Science, Electrical.
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Objectives Introduce basic implementation strategies Clipping Scan conversion.
From Vertices to Fragments Chapter 7. Part I Objectives Introduce basic implementation strategies Introduce basic implementation strategies Clipping Clipping.
CS 480/680 Computer Graphics Shading in OpenGL Dr. Frederick C Harris, Jr. Fall 2013.
Clipping CSCI 440 textbook section Starter Question How do we clip these lines? X=-5 Y=-5 Y=5 X=5 [0,0] [3,3] [7,-3] [0,-3] formula from wikipedia.
1 Angel: Interactive Computer Graphics 5E © Addison-Wesley 2009 Week 3 Lecture 1: Implementation Based on Interactive Computer Graphics (Angel) - Chapter.
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,
Computer Graphics Chapter 6 Andreas Savva. 2 Interactive Graphics Graphics provides one of the most natural means of communicating with a computer. Interactive.
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.
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.
Computer Graphics Lecture 17 Fasih ur Rehman. Last Class 3D Transforms Inverse Rotation.
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
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.
Computer Graphics Lecture 14 CLIPPING I Taqdees A. Siddiqi
Computer Graphics Clipping.
Computer Graphics Implementation II
Introduction to Computer Graphics with WebGL
Computer Graphics CC416 Week 13 Clipping.
Transformations contd.
CS 551 / 645: Introductory Computer Graphics
Computer Graphics Shading in OpenGL
Concepts, algorithms for clipping
3D Clipping.
Implementation I Ed Angel
Graphics Pipeline Clipping
Models and Architectures
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
WINDOWING AND CLIPPING
Computer Graphics : Viewing In 2D
Implementation II Ed Angel Professor Emeritus of Computer Science
Course code: 10CS65 | Computer Graphics and Visualization
WINDOWING AND CLIPPING
Lecture 13 Clipping & Scan Conversion
CSCE 441 Computer Graphics: Clipping Polygons Jinxiang Chai
Two Dimensional Viewing and Clipping.
Introduction to Computer Graphics with WebGL
From Vertices To Fragments
Computer Graphics Viewing. 2 of 30 Viewing in 2D Window in world coordinates. 45  250  Viewport in Device coords 250 x 250 Pixels.
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
From Vertex to Fragment
Presentation transcript:

Lecture 9 From Vertices to Fragments

Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal

Basic implementation strategies In computer graphics, we start with an application program, and we end with an image. We can consider this process as a black box whose inputs are the vertices and states de fi ned in the program—geometric objects, attributes, camera speci fi cations—and whose output is an array of colored pixels in the frame buffer.

Required Tasks There are four major tasks that any graphics system must perform to render a geometric entity, such as a three- dimensional polygon, as that entity passes from de fi nition in a user program to possible display on an output device: 1. Modeling 2. Geometry processing 3. Rasterization 4. Fragment processing

. Figure 6.3 shows how these tasks might be organized in a pipeline implementation. Regardless of the approach, all four tasks must be carried out.

Modeling The usual results of the modeling process are sets of vertices that specify a group of geometric objects supported by the rest of the system. We can look at the modeler as a black box that produces geometric objects and is usually a user program.

. There are other tasks that the modeler might perform, for example, clipping: the process of eliminating parts of objects that cannot appear on the display because they lie outside the viewing volume.

Geometry processing Geometry processing works with vertices. The goals of the geometry processor are to determine which geometric objects can appear on the display and to assign shades or colors to the vertices of these objects. Four processes are required: projection, primitive assembly, clipping, and shading.

Geometry processing The fi rst step in geometry processing is to change representations from object coordinates to camera or eye coordinates using the model-view transformation. The second step is to transform vertices using the projection transformation from VCS (View Coordinates System) to a NDCS (Normalized Device Coordinates System ) in which objects that might be visible are contained in a cube centered at the origin. Vertices are now represented in clip coordinates

Geometry processing Geometric objects are transformed by a sequence of transformations that may reshape and move them (modeling) or may change their representations (viewing).

front-end processing View volume primitives that fi t within a speci fi ed volume, and can appear on the display after rasterization. primitive assembly The process of grouping vertices into objects before clipping can take place.

front-end processing hidden-surface removal Note that even though an object lies inside the view volume, it will not be visible if it is obscured by other objects. Algorithms for hidden-surface removal or visible-surface determination are based on the three- dimensional spatial relationships among objects. This step is normally carried out as part of fragment processing.

Rasterisation Rasterisation is the task of taking an image described in a vector graphics format (shapes) and converting it into a raster image (pixels or dots) for output on a video display or printer, or for storage in a bitmap file format. It the transformation of geometric primitives (line segments, circles, polygons) into a raster image representation, i. e. pixel positions the estimation of an appropriate set of pixel positions to represent a geometric primitive.

Clipping The process of determining which primitives, or parts of primitives, fi t within the clipping or view volume de fi ned by the application program. We shall concentrate on clipping of line segments and polygons because they are the most common primitives to pass down the pipeline.

Line-segment clipping A clipper decides which primitives, or parts of primitives, can possibly appear on the display and be passed on to the rasterizer. Primitives that fi t within the speci fi ed 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.

Clipping Easy for line segments and polygons Hard for curves and text Convert to lines and polygons first

Clipping 2D Line Segments Brute force approach: compute intersections with all sides of clipping window Inefficient: one division per intersection

Line Clipping Line clipping operations should comprise the following cases: Totally plotted. Partially plotted. Not plotted at all

Line Clipping Note that even though neither of two vertices is within the window, certain part of the line segment may be still within. There are many different techniques for clipping line in 2D: The fundamental are : 1-Line equation 2-Intersection computation Next we will discuss Cohen-Sutherland Algorithm.

Cohen-Sutherland Algorithm It is not the most efficient algorithm. It is the most commonly used. The key technique is 4 bit code TBRL where: T is set (to 1 ) if y > top B is set (to 1 ) if y < Bottom R is set (to 1 ) if x > right L is set (to 1 ) if x < left

Cohen-Sutherland Algorithm 21 Idea: eliminate as many cases as possible without computing intersections Start with four lines that determine the sides of the clipping window x = x max x = x min y = y max y = y min

The Cases 22 Case 1: both endpoints of line segment inside all four lines Draw (accept) line segment as is Case 2: both endpoints outside all lines and on same side of a line Discard (reject) the line segment x = x max x = x min y = y max y = y min

The Cases 23 Case 3: One endpoint inside, one outside Must do at least one intersection Case 4: Both outside May have part inside Must do at least one intersection x = x max x = x min y = y max

Defining Outcodes Angel: Interactive Computer Graphics 4E © Addison- Wesley The first bit is set to 1 if the point is above the viewport eg 1001 The Second bit is set to 1 if the point is under the viewport eg 0101 The third bit is set to 1 if the point is right the viewport eg 0010 The forth bit is set to 1 if the point is left the viewport eg 0001

Using Outcodes Angel: Interactive Computer Graphics 4E © Addison- Wesley Consider the 5 cases below AB: outcode(A) = outcode(B) = 0 Accept line segment

Using Outcodes Angel: Interactive Computer Graphics 4E © Addison- Wesley CD: outcode (C) = 0, outcode(D)  0 Compute intersection Location of 1 in outcode(D) determines which edge to intersect with Note if there were a segment from A to a point in a region with 2 ones in outcode, we might have to do two interesections

Using Outcodes Angel: Interactive Computer Graphics 4E © Addison- Wesley EF: outcode(E) logically ANDed with outcode(F) (bitwise)  0 Both outcodes have a 1 bit in the same place Line segment is outside of corresponding side of clipping window reject

Using Outcodes Angel: Interactive Computer Graphics 4E © Addison- Wesley GH and IJ: same outcodes, neither zero but logical AND yields zero Shorten line segment by intersecting with one of sides of window Compute outcode of intersection (new endpoint of shortened line segment) Re-execute algorithm

Efficiency Angel: Interactive Computer Graphics 4E © Addison- Wesley In many applications, the clipping window is small relative to the size of the entire data base Most line segments are outside one or more sides of the window and can be eliminated based on their outcodes Inefficiency when code has to be re-executed for line segments that must be shortened in more than one step

Cohen Sutherland in 3D Angel: Interactive Computer Graphics 4E © Addison- Wesley Use 6-bit outcodes When needed, clip line segment against planes

Polygon Clipping Angel: Interactive Computer Graphics 4E © Addison- Wesley Not as simple as line segment clipping Clipping a line segment yields at most one line segment Clipping a polygon can yield multiple polygons However, clipping a convex polygon can yield at most one other polygon

Pipeline Clipping of Polygons Angel: Interactive Computer Graphics 4E © Addison- Wesley Three dimensions: add front and back clippers Strategy used in SGI( Silicon Graphics International) Geometry Engine. Small increase in latency

Bounding Boxes Angel: Interactive Computer Graphics 4E © Addison- Wesley Rather than doing clipping on a complex polygon, we can use an axis-aligned bounding box or extent Smallest rectangle aligned with axes that encloses the polygon Simple to compute: max and min of x and y

Bounding Boxes 34 Can usually determine accept/reject based only on bounding box reject accept requires detailed clipping