Implementation II Ed Angel Professor Emeritus of Computer Science

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Visible-Surface Detection(identification)
From Vertices to Fragments
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.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
1 Dr. Scott Schaefer Hidden Surfaces. 2/62 Hidden Surfaces.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
1 Angel: Interactive Computer Graphics 4E © Addison-Wesley 2005 Implementation I Ed Angel Professor of Computer Science, Electrical and Computer Engineering,
Introduction to 3D Graphics John E. Laird. Basic Issues u Given a internal model of a 3D world, with textures and light sources how do you project it.
Hidden Surface Removal
Graphics Pipeline Hidden Surfaces CMSC 435/634. Visibility We can convert simple primitives to pixels Which primitives (or parts of primitives) should.
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 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.
From Vertices to Fragments II Software College, Shandong University Instructor: Zhou Yuanfeng
Visible-Surface Detection Jehee Lee Seoul National University.
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 5E © Addison-Wesley 2009 Week 3 Lecture 1: Implementation Based on Interactive Computer Graphics (Angel) - Chapter.
Hidden Surface Removal 1.  Suppose that we have the polyhedron which has 3 totally visible surfaces, 4 totally invisible/hidden surfaces, and 1 partially.
CS-378: Game Technology Lecture #2.2: Clipping and Hidden Surfaces Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney,
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.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
Implementation II.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
Computer Graphics I, Fall 2010 Implementation II.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
Visible surface determination. Problem outline Given a set of 3D objects and a viewing specification, we wish to determine which lines or surfaces are.
1 Introduction to Computer Graphics with WebGL Ed Angel Professor Emeritus of Computer Science Founding Director, Arts, Research, Technology and Science.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
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.
Visible surface determination
Computer Graphics Implementation II
Solid Area Scan Conversion or Visible Surface Detection
Introduction to Computer Graphics with WebGL
Computer Graphics Shading in OpenGL
CSC461: Lecture 20 Parallel Projections in OpenGL
3D Graphics Rendering PPT By Ricardo Veguilla.
Implementation I Ed Angel
Introduction to Computer Graphics with WebGL
Models and Architectures
CSCE 441: Computer Graphics Hidden Surface Removal
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 4: Color and Attributes
Introduction to Computer Graphics with WebGL
Building Models Ed Angel Professor Emeritus of Computer Science
Course code: 10CS65 | Computer Graphics and Visualization
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Introduction to Computer Graphics with WebGL
Programming with OpenGL Part 4: Color and Attributes
From Vertices To Fragments
Implementation I Ed Angel Professor Emeritus of Computer Science
Implementation III Ed Angel Professor Emeritus of Computer Science
Implementation II Ed Angel Professor Emeritus of Computer Science
From Vertex to Fragment
From Vertex to Fragment
Presentation transcript:

Implementation II Ed Angel Professor Emeritus of Computer Science University of New Mexico E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Objectives Introduce clipping algorithms for polygons Survey hidden-surface algorithms E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Polygon Clipping 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 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Tessellation and Convexity One strategy is to replace nonconvex (concave) polygons with a set of triangular polygons (a tessellation) Also makes fill easier Tessellation code in GLU library E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Clipping as a Black Box Can consider line segment clipping as a process that takes in two vertices and produces either no vertices or the vertices of a clipped line segment E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Pipeline Clipping of Line Segments Clipping against each side of window is independent of other sides Can use four independent clippers in a pipeline E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Pipeline Clipping of Polygons Three dimensions: add front and back clippers Strategy used in SGI Geometry Engine Small increase in latency E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Bounding Boxes 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 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Bounding boxes Can usually determine accept/reject based only on bounding box reject accept requires detailed clipping E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Clipping and Visibility Clipping has much in common with hidden-surface removal In both cases, we are trying to remove objects that are not visible to the camera Often we can use visibility or occlusion testing early in the process to eliminate as many polygons as possible before going through the entire pipeline E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Hidden Surface Removal Object-space approach: use pairwise testing between polygons (objects) Worst case complexity O(n2) for n polygons partially obscuring can draw independently E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Painter’s Algorithm Render polygons a back to front order so that polygons behind others are simply painted over Fill B then A B behind A as seen by viewer E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Depth Sort Requires ordering of polygons first O(n log n) calculation for ordering Not every polygon is either in front or behind all other polygons Order polygons and deal with easy cases first, harder later Polygons sorted by distance from COP E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Easy Cases A lies behind all other polygons Can render Polygons overlap in z but not in either x or y Can render independently E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Hard Cases cyclic overlap Overlap in all directions but can one is fully on one side of the other penetration E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Back-Face Removal (Culling) face is visible iff 90    -90 equivalently cos   0 or v • n  0  plane of face has form ax + by +cz +d =0 but after normalization n = ( 0 0 1 0)T need only test the sign of c In OpenGL we can simply enable culling but may not work correctly if we have nonconvex objects E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Image Space Approach Look at each projector (nm for an n x m frame buffer) and find closest of k polygons Complexity O(nmk) Ray tracing z-buffer E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

z-Buffer Algorithm Use a buffer called the z or depth buffer to store the depth of the closest object at each pixel found so far As we render each polygon, compare the depth of each pixel to depth in z buffer If less, place shade of pixel in color buffer and update z buffer E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Efficiency If we work scan line by scan line as we move across a scan line, the depth changes satisfy ax+by+cz=0 Along scan line y = 0 z = - x In screen space x = 1 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Scan-Line Algorithm Can combine shading and hsr through scan line algorithm scan line i: no need for depth information, can only be in no or one polygon scan line j: need depth information only when in more than one polygon E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Implementation Need a data structure to store Flag for each polygon (inside/outside) Incremental structure for scan lines that stores which edges are encountered Parameters for planes E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Visibility Testing In many realtime applications, such as games, we want to eliminate as many objects as possible within the application Reduce burden on pipeline Reduce traffic on bus Partition space with Binary Spatial Partition (BSP) Tree E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

Simple Example consider 6 parallel polygons top view The plane of A separates B and C from D, E and F E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012

BSP Tree Can continue recursively Plane of C separates B from A Plane of D separates E and F Can put this information in a BSP tree Use for visibility and occlusion testing E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley 2012