Computer Graphics Inf4/MSc 28/10/08Lecture 91 Computer Graphics Lecture 9 Visible Surface Determination Taku Komura.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Visible-Surface Detection(identification)
15.1 Si23_03 SI23 Introduction to Computer Graphics Lecture 15 – Visible Surfaces and Shadows.
8.1si31_2001 SI31 Advanced Computer Graphics AGR Lecture 8 Polygon Rendering.
Lecture 8 Transparency, Mirroring
CSC418 Computer Graphics n Polygon normals n Back Faces n Visibility Algorithms.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Computer Graphics Inf4/MSc Computer Graphics Lecture 9 Visible Surface Determination.
03/12/02 (c) 2002 University of Wisconsin, CS559 Last Time Some Visibility (Hidden Surface Removal) algorithms –Painter’s Draw in some order Things drawn.
David Luebke5/11/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Lecture Fall 2001 Visibility Back-Face Culling Painter’s Algorithm.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Hidden Surface Removal Why make the effort?  Realistic models.  Wasted time drawing. OpenGL and HSR  OpenGL does handle HSR using the depth buffer.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
Visibility in Computer Graphics Toni Sellarès Unversitat de Girona
Computer Graphics Visible Surface Determination. Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a.
Graphics Graphics Korea University cgvr.korea.ac.kr 1 Hidden Surface Removal 고려대학교 컴퓨터 그래픽스 연구실.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2007 Tamara Munzner Clipping II, Hidden Surfaces.
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.
CS 4731: Computer Graphics Lecture 18: Hidden Surface Removal Emmanuel Agu.
Hidden Surface Elimination Wen-Chieh (Steve) Lin Institute of Multimedia Engineering I-Chen Lin’ CG Slides, Rich Riesenfeld’s CG Slides, Shirley, Fundamentals.
1 CSCE 441: Computer Graphics Hidden Surface Removal (Cont.) Jinxiang Chai.
University of British Columbia CPSC 314 Computer Graphics Jan-Apr 2005 Tamara Munzner Visibility II Week 7,
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
Spatial Data Structure: Quadtree, Octree,and BSP tree Mengxia Zhu Fall 2007.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
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.
Graphics Pipeline Hidden Surface CMSC 435/634. Visibility We can convert simple primitives to pixels/fragments How do we know which primitives (or which.
Computer Graphics Mirror and Shadows
10/29/02 (c) 2002 University of Wisconsin, CS559 Today Hidden Surface Removal Exact Visibility.
CSC418 Computer Graphics n BSP tree n Z-Buffer n A-buffer n Scanline.
The BSP-tree from Prof. Seth MIT.. Motivation for BSP Trees: The Visibility Problem We have a set of objects (either 2d or 3d) in space. We have.
Visible-Surface Detection Jehee Lee Seoul National University.
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.
Chris Mayer & Nic Shulver Hidden Surface Wire frame drawings Wire frame drawings are quick to produce but are often confusing It is difficult to determine.
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
Binary Space Partitioning Trees Ray Casting Depth Buffering
Hidden Surface Removal
Implementation II.
1 Visiblity: Culling and Clipping Computer Graphics COMP 770 (236) Spring 2009 January 21 & 26: 2009.
Computer Graphics Zhen Jiang West Chester University.
Review on Graphics Basics. Outline Polygon rendering pipeline Affine transformations Projective transformations Lighting and shading From vertices to.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Visible Surface Determination (VSD) To render or not to render, that is the question… 1 of.
Where We Stand At this point we know how to: –Convert points from local to window coordinates –Clip polygons and lines to the view volume –Determine which.
Computer Graphics I, Fall 2010 Implementation II.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
CS559: Computer Graphics Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008.
01/28/09Dinesh Manocha, COMP770 Visibility Computations Visible Surface Determination Visibility Culling.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 5 Hidden Surface Removal and Rasterization Taku Komura.
Visible-Surface Detection Methods. To identify those parts of a scene that are visible from a chosen viewing position. Surfaces which are obscured by.
Hidden Surface Removal. 2 Goal: Determine which surfaces are visible and which are not. Z-Buffer is just one of many hidden surface removal algorithms.
Computer Graphics Implementation II
Hidden Surfaces Dr. Scott Schaefer.
Graphics Pipeline Hidden Surfaces
CSCE 441: Computer Graphics Hidden Surface Removal
3D Rendering Pipeline Hidden Surface Removal 3D Primitives
Implementation II Ed Angel Professor Emeritus of Computer Science
Visibility (hidden surface removal)
Introduction to Computer Graphics with WebGL
Hidden Surface Removal
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Computer Graphics Inf4/MSc 28/10/08Lecture 91 Computer Graphics Lecture 9 Visible Surface Determination Taku Komura

Computer Graphics Inf4/MSc 28/10/08Lecture 92 Hidden surface removal Drawing polygonal faces on screen consumes CPU cycles  – We cannot see every surface in scene – We don’t want to waste time rendering primitives which don’t contribute to the final image.

Computer Graphics Inf4/MSc 28/10/08Lecture 93 Visibility (hidden surface removal)‏ A correct rendering requires correct visibility calculations Correct visibility –when multiple opaque polygons cover the same screen space, only the closest one is visible (remove the other hidden surfaces)‏ –wrong visibility correct visibility

Computer Graphics Inf4/MSc 28/10/08Lecture 94 Visibility of primitives A scene primitive can be invisible for 3 reasons: –Primitive lies outside field of view –Primitive is back-facing –Primitive is occluded by one or more objects nearer the viewer How do we remove these efficiently? How do we identify these efficiently?

Computer Graphics Inf4/MSc 28/10/08Lecture 95 The visibility problem. Two problems remain: (Clipping we have covered)‏ Removal of faces facing away from the viewer. Removal of faces obscured by closer objects.

Computer Graphics Inf4/MSc 28/10/08Lecture 96 Visible surface algorithms. Definitions: Object space techniques: applied before vertices are mapped to pixels Back face culling, Painter’s algorithm, BSP Trees Image space techniques: applied after vertices have been rasterized Z-buffering

Computer Graphics Inf4/MSc 28/10/08Lecture 97 Back face culling. We saw in modelling, that the vertices of polyhedra are oriented in an anticlockwise manner when viewed from outside – surface normal N points out. Project a polygon. –Test z component of surface normal. If negative – cull, since normal points away from viewer. –Or if N. V > 0 we are viewing the back face so polygon is obscured. Only works for convex objects without holes, ie. closed orientable manifolds.

Computer Graphics Inf4/MSc 28/10/08Lecture 98 Back face culling Back face culling can be applied anywhere in the pipeline: geometry stage or rasterization stage If we clip our scene to the view frustrum, then remove all back-facing polygons – are we done? NO! Most views involve overlapping polygons.

Computer Graphics Inf4/MSc 28/10/08Lecture 99 Painters algorithm (object space). Draw surfaces in back to front order – nearer polygons “paint” over farther ones. Supports transparency. Key issue is order determination. Doesn’t always work – see image at right.

Computer Graphics Inf4/MSc 28/10/08Lecture 910 One Solution Binary Space Partitioning Tree (or BSP Tree)‏ A data structure that is used to organize objects within a space. Polygons are subdivided and queued

Computer Graphics Inf4/MSc 28/10/08Lecture 911 BSP (Binary Space Partitioning) Tree. One of class of “list-priority” algorithms – returns ordered list of polygon fragments for specified view point (static pre-processing stage). Choose polygon arbitrarily Divide scene into front (relative to normal) and back half-spaces. Split any polygon lying on both sides. Choose a polygon from each side – split scene again. Recursively divide each side until each node contains only 1 polygon View of scene from above

Computer Graphics Inf4/MSc 28/10/08Lecture 912 BSP Tree. Choose polygon arbitrarily Divide scene into front (relative to normal) and back half-spaces. Split any polygon lying on both sides. Choose a polygon from each side – split scene again. Recursively divide each side until each node contains only 1 polygon a 5b 1 2 5a 4 5b back front

Computer Graphics Inf4/MSc 28/10/08Lecture 913 BSP Tree. Choose polygon arbitrarily Divide scene into front (relative to normal) and back half-spaces. Split any polygon lying on both sides. Choose a polygon from each side – split scene again. Recursively divide each side until each node contains only 1 polygon a 5b 4 5b back front 2 15a front

Computer Graphics Inf4/MSc 28/10/08Lecture 914 BSP Tree. Choose polygon arbitrarily Divide scene into front (relative to normal) and back half-spaces. Split any polygon lying on both sides. Choose a polygon from each side – split scene again. Recursively divide each side until each node contains only 1 polygon a 5b back front 2 15a front 5b 4

Computer Graphics Inf4/MSc 28/10/08Lecture 915 BSP Tree. Choose polygon arbitrarily Divide scene into front (relative to normal) and back half-spaces. Split any polygon lying on both sides. Choose a polygon from each side – split scene again. Recursively divide each side until each node contains only 1 polygon back 2 1 front 5 4 back Alternate formulation starting at 5

Computer Graphics Inf4/MSc 28/10/08Lecture 916 Displaying a BSP tree. Once we have the regions – need priority list BSP tree can be traversed to yield a correct priority list for an arbitrary viewpoint. Start at root polygon. –If viewer is in front half-space, draw polygons behind root first, then the root polygon, then polygons in front. –If polygon is on edge – either can be used. –Recursively descend the tree. If eye is in rear half-space for a polygon – then can back face cull.

Computer Graphics Inf4/MSc 28/10/08Lecture 917 BSP Tree. A lot of computation required at start. –Try to split polygons along good dividing plane –Intersecting polygon splitting may be costly Cheap to check visibility once tree is set up. Can be used to generate correct visibility for arbitrary views.  Efficient when object location don’t change very often in the scene.

Computer Graphics Inf4/MSc 28/10/08Lecture 918 Z-buffering : image space approach Basic Z-buffer idea: rasterize every input polygon For every pixel in the polygon interior, calculate its corresponding z value (by interpolation)‏ Track depth values of closest polygon (smallest z) so far Paint the pixel with the color of the polygon whose z value is the closest to the eye.

Computer Graphics Inf4/MSc 28/10/08Lecture 919

Computer Graphics Inf4/MSc 28/10/08Lecture 920

Computer Graphics Inf4/MSc 28/10/08Lecture 921

Computer Graphics Inf4/MSc 28/10/08Lecture 922

Computer Graphics Inf4/MSc 28/10/08Lecture 923 Triangle Rasterization Consider a 2D triangle with vertices p0, p1, p2. Let x be any point in the plane. We can always find a, b, c such that We will have if and only if x is inside the triangle. We call the barycentric coordinates of x.

Computer Graphics Inf4/MSc 28/10/08Lecture 924 Rasterization We assume that p are normalized device coordinates (NDC); that is, the canvas corresponds to the region [-1, 1] × [-1, 1]. -This is what you get after applying all transformation matrices.

Computer Graphics Inf4/MSc 28/10/08Lecture 925 Bounding box of the triangle First, identify a rectangular region on the canvas that contains all of the pixels in the triangle (excluding those that lie outside the canvas). Calculate a tight bounding box for a triangle: simply calculate pixel coordinates for each vertex, and find the minimum/maximum for each axis

Computer Graphics Inf4/MSc 28/10/08Lecture 926 Scanning inside the triangle Once we've identified the bounding box, we loop over each pixel in the box. For each pixel, we first compute the corresponding NDC coordinates (x, y). Next we convert these into barycentric coordinates for the triangle being drawn. Only if the barycentric coordinates are within the range of [0,1], we plot it (and compute the depth)‏

Computer Graphics Inf4/MSc 28/10/08Lecture 927 Computing the baricentric coordinates of the interior pixels Depth can be computed by Can do the same thing for color, normals

Computer Graphics Inf4/MSc 28/10/08Lecture 928 Implementation. Initialise frame buffer to background colour. Initialise depth buffer to z = max. value for far clipping plane For each triangle –Calculate value for z for each pixel inside –Update both frame and depth buffer

Computer Graphics Inf4/MSc 28/10/08Lecture 929 Why is z-buffering so popular ? Advantage Simple to implement in hardware. –Memory for z-buffer is now not expensive Diversity of primitives – not just polygons. Unlimited scene complexity Don’t need to calculate object-object intersections. Disadvantage Extra memory and bandwidth Waste time drawing hidden objects Z-precision errors May have to use point sampling

Computer Graphics Inf4/MSc 28/10/08Lecture 930 Z-buffer performance Brute-force image-space algorithm scores best for complex scenes – not very accurate but is easy to implement and is very general. Storage overhead: O(1)‏ Time to resolve visibility to screen precision: O(n)‏

Computer Graphics Inf4/MSc 28/10/08Lecture 931 Exercise Write a program to load 3D polygons Use OpenGL’s 2D functions to draw triangles glOrtho2D(); glColor3f(); glRecti(i,j,i+1,j+1); -Try to use barycentric coordinates to rasterize the triangle

Computer Graphics Inf4/MSc 28/10/08Lecture 932 References for this lecture Foley et al. Chapter 15, all of it. Introductory text, Chapter 13, all of it Baricentric coordinates ric.pdf Or equivalents in other texts, look out for: –(as well as the topics covered today)‏ –Depth sort – Newell, Newell & Sancha –Scan-line algorithms