Hidden Surface Removal 1.  Suppose that we have the polyhedron which has 3 totally visible surfaces, 4 totally invisible/hidden surfaces, and 1 partially.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

Visible-Surface Detection(identification)
Hidden Surface Removal CSE 581. Visibility Assumption: All polygons are opaque What polygons are visible with respect to your view frustum?  Outside:
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
CECS461 Computer Graphics II University of Missouri at Columbia Hidden Surface Removal.
Hidden Surface Removal Why make the effort?  Realistic models.  Wasted time drawing. OpenGL and HSR  OpenGL does handle HSR using the depth buffer.
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 고려대학교 컴퓨터 그래픽스 연구실.
Part I: Basics of Computer Graphics
Korea Univ. Graphics Lab. 3D Game Engine Design Chapter 12. Spatial Sorting Chung Ji Hye
UBI 516 Advanced Computer Graphics
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.
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,
Visible-surface Detection Computer Graphics Seminar MUM
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.
Part I: Basics of Computer Graphics Rendering Polygonal Objects (Read Chapter 1 of Advanced Animation and Rendering Techniques) Chapter
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
Visible Surface Determination
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.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Zakrite ploskve. Problem outline Given a set of 3D objects and a viewing specification, we wish to determine which lines or surfaces are visible, so that.
Polygon Scan Conversion and Z-Buffering
CS 325 Introduction to Computer Graphics 03 / 08 / 2010 Instructor: Michael Eckmann.
CSC418 Computer Graphics n BSP tree n Z-Buffer n A-buffer n Scanline.
Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
Visible-Surface Detection Jehee Lee Seoul National University.
3D Graphics for Game Programming Chapter IV Fragment Processing and Output Merging.
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.
Visible-Surface Detection Methods
CS 325 Introduction to Computer Graphics 03 / 22 / 2010 Instructor: Michael Eckmann.
Binary Space Partitioning Trees Ray Casting Depth Buffering
CS 376 Introduction to Computer Graphics 03 / 21 / 2007 Instructor: Michael Eckmann.
Hidden Surface Removal
Implementation II.
1 3D Hidden Surface Removal 김 성 남. 2 Contents Goal Motivation Approaches - back face detection - depth buffer - A-buffer - Scan line - Depth.
CS123 | INTRODUCTION TO COMPUTER GRAPHICS Andries van Dam © Visible Surface Determination (VSD) To render or not to render, that is the question… 1 of.
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 determination. Problem outline Given a set of 3D objects and a viewing specification, we wish to determine which lines or surfaces are.
1 Computer Graphics Week11 : Hidden Surface Removal.
Learning Objectives Classification of Visible Surface Detection Algorithms Classification of Visible Surface Detection Algorithms Back-Face Detection Back-Face.
Computer Graphics One of the central components of three-dimensional graphics has been a basic system that renders objects represented by a set of polygons.
COMPUTER GRAPHICS CS 482 – FALL 2015 NOVEMBER 10, 2015 VISIBILITY CULLING HIDDEN SURFACES ANTIALIASING HALFTONING.
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.
Lecture 30: Visible Surface Detection
Computer Graphics Implementation II
Hidden Surface Removal
CSC418 Computer Graphics Back Faces Visibility Algorithms.
Hidden Surfaces Dr. Scott Schaefer.
Graphics Pipeline Hidden Surfaces
CSCE 441: Computer Graphics Hidden Surface Removal
Implementation II Ed Angel Professor Emeritus of Computer Science
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Introduction to Computer Graphics with WebGL
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Hidden Surface Removal 1

 Suppose that we have the polyhedron which has 3 totally visible surfaces, 4 totally invisible/hidden surfaces, and 1 partially visible/hidden surface.  Obviously, invisible/hidden surfaces do not contribute to the final image.  The procedure that distinguishes between visible surfaces from invisible/hidden surfaces is called visible-surface determination, which is often called hidden-surface removal. 2

Back Face Culling 3  Performance goals in real-time rendering  frame rate: frames/sec?  resolution: 1600x1200?  photorealism (if necessary): undistinguishable from real scene!  Unfortunately, there is no real upper limit on the scene complexity.  We should cull those portions of the scene that are not considered to contribute to the final image, and process only the rest of the scene.  The simplest is back-face culling, which distinguishes between front faces (faces towards the viewer) and back faces (faces away from the viewer). back faces front faces polygon normals

Back Face Culling (cont’d)  Back-face culling works as a preprocessing step for hidden surface removal, and is very powerful in that almost half of polygons of an object are discarded as back faces.  Especially, for a single convex polyhedron, the back-face culling does the entire job of hidden-surface removal.  Hidden-surface removal is applied to only the remaining front faces. 4 single convex polyhedron convex, but not a single polyhedron

Face Normal  The normal of a triangle is computed as v 1 X v 2 where v 1 is the vector connecting p 1 and p 2, and v 2 connects p 1 and p 3.  If the vertices of every polygon are ordered consistently (CCW or CW), we can make every polygon’s normal point out of the polyhedron. All mesh data used in this class have triangles of CCW vertex ordering. 5 p q r s t 1 = ( p, q, r ) t 2 = ( s, q, p ) t 1 ’s normal = ( q - p )X( r - p ) t 2 ’s normal = ( q - s )X( p - s )

Dot Product (revisited) 6 x y c =(1,1) b =(0,1) a =(-1,1) d =(-1,0) a·d = (-1,1)·(-1,0) = 1 > 0 b·d = (0,1)·(-1,0) = 0 c·d = (1,1)·(-1,0) = -1 < 0  Recall the dot product of two vectors v i & v j.  If v iv j = 0, v i & v j are orthogonal/perpendicular.  If v iv j > 0, angle < 90  If v iv j 90  The same applies to 3D.

Dot Product for Back Face Culling  Determining if a polygon is a front face or a back face  Generate a vector C connecting COP and a vertex of the polygon.  Take the dot product CN of the vector C and the polygon’s normal N.  If CN > 0, it’s a back face.  If CN < 0, it’s a front face.  If CN = 0, it’s a face that is projected as an edge/silhouette on the screen. 7 C 2 N 2 > 0 C 3 N 3 < 0 COP C1C1 N1N1 N2N2 N3N3 C 1 N 1 = 0 C2C2 C3C3

Hidden Surface Removal 8 x=349 y=249 DOP Fig-2 Fig-1  Suppose that we have two triangles in the viewport defined by (x min, y min, width, height) = (0,0,350,250).  Consider a pixel at (241,200).  The above scene should result in Fig-1, not Fig-2.  Note that Fig-1 does correct hidden-surface removal. z=1 Pixel (241,200) at 350  250 resolution viewport. It should be blue.

Z-buffer 9 frame buffer z-buffer should be “blue” ?  The most popular hidden-surface removal algorithm uses z-buffer or depth-buffer.  It’s called z-buffer algorithm, where we need z-buffer in addition to the frame buffer. Their sizes are the same. x=349 y=249 DOP z=1 Pixel (241,200) at 350  250 resolution screen. It should be blue.

Z-buffer Algorithm  The frame buffer will have a color-value for each pixel.  The z-buffer will have a z-value for each pixel.  The z-buffer is initialized to the z-values of the back plane (in our case, - 1).  Similarly, the frame buffer is initialized to the background color (in our case, white). 10 ……………. : : w w w w ….. : w w w w ….. frame buffer ……………. : : : z-buffer ① initial states

Z-buffer Algorithm (cont’d)  Select polygons/triangles of a mesh in an arbitrary order.  Project each triangle onto the z=0 plane, and draw it using the scan- line algorithm.  When drawing each polygon, if the polygon point at (x,y) has a bigger z- value than the current value of the z-buffer, the point’s color & z-value replace the old ones in both buffers. 11 x y y=201 y=200 y=  Let’s take the red triangle.  For example, when processing y=200 scan line, x=[241,242] will be filled.  For the pixel (241,200), its z-value a of the red triangle should be greater than (or equal to) the current z-buffer’s value -1.  So, set frame-buffer[241,200] to red, and set z-buffer[241,200] to a.

Z-buffer Algorithm (cont’d) 12 ② When scan line 200 is completed x=241 ……………. : : w w w w ….. : w R R w ….. frame buffer ……………. : : : z-buffer y=200 x=241 y=200 A point (242,200,0.5) on the red triangle ③ When the red triangle is completely processed ……………. : : w w w w ….. : w R R w ….. R R R R ……………. : : : :

Z-buffer Algorithm (cont’d)  When a triangle is completed, arbitrarily select the next triangle and repeat the scan-line algorithm. 13  Let’s now take the blue triangle.  For example, when processing y=200 scan line, x=[*,241] will be filled.  For the pixel (241,200), its z-value b of the blue triangle should be greater than the current z-buffer’s value a.  Then, set frame-buffer[241,200] to blue, and set z-buffer[241,200] to b. pixel (241,200) x y y=201 y=200 y=

Z-buffer Algorithm (cont’d)  Note that we will have the same result if we process blue triangle first and then red triangle (unless they are partially transparent). 14 ④ When the blue triangle is completely processed ……………. : : B B w w ….. : B B R w ….. R R R R ……………. : : : : updated! x=241 y=200 x=241 y=200 updated!

Depth Computation  A polygon has the plane equation Ax+By+Cz+D=0.  We can compute A, B, C and D from the 3 vertices of the polygon.  (A,B,C) is the plane’s normal vector, and computed using cross product.  The remaining unknown D is obtained by inserting any vertex out of p 1, p 2 and p 3 into Ax+By+Cz+D=0.  The depth value (z-value) at a pixel position (x,y) is computed by inserting (x,y) into the plane equation Ax+By+Cz+D=0. For example, at (x,y)=(241,200), 15 (A,B,C) pixel (241,200)

Incremental Depth Computation  Note that the z-buffer testing is integrated into the polygon-filling scan- line algorithm.  In a scan line, the scan-line algorithm processes pixels of the range [x min, x max ] one by one from the left to the right.  Once the z-value z 1 at (x,y) is computed, the z-value z 2 at the next pixel (x+1,y) is computed incrementally using z 1 as follows: 16 z1z1 y x x+1 z1z1 z2z2

Discussions on Z-buffer Algorithm  Z-buffer algorithm is the standard algorithm for hidden-surface removal.  Why is the z-buffer algorithm so popular?  simplest among hidden-surface removal algorithms  easy for H/W implementation  compatible with rendering pipeline architecture  etc.  However, the z-buffer algorithm needs a separate memory for the z- buffer. The size of the z-buffer depends on the accuracy to which the depth value of each point (x,y) is to be stored, which is a function of the scene complexity. Suppose that 4 bytes are used for a pixel. Then, it’s as large as the frame buffer!  e.g  1024  4 > 4MB 17

The Paiter’s algorithm Sort the faces list on the basis of the extent.far value paint entire faces, in order from farthest to closest Depth sort, back to front rendering 18

Depth Sort If z overlapped X, y overlapped? All the vertices of a face on one side of the plane defined by the other face? If still overlap, Partition!!! 19

HSR using Binary-Space Partition Trees BSP the polygons are rearranged into BT and certain faces are split into pieces the tree can traversed in a systematic way to draw the scene with HS properly removed. 20

Building a BSP Tree 2D example 3D example 21

Traverse the tree If the eye is outside { draw all faces in the inside of F draw F draw all faces in the outside of F } else{ { draw all faces in the outside of F draw F draw all faces in the inside of F } 22

A 2D Scene 23

A BSP tree 24

A 3D Scene and its BSP tree 25

Traverse Order 26