CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

Collisions and Intersections When objects move, test for collision. When projecting surfaces, check for intersections. (Many slides adapted from Amitabh.
CSC418 Computer Graphics n Polygon normals n Back Faces n Visibility Algorithms.
CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
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
Hidden Surface Removal CSE 581. Visibility Assumption: All polygons are opaque What polygons are visible with respect to your view frustum?  Outside:
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.
Part I: Basics of 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.
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
Clipping & Scan Conversion
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,
1 Clipping and Hidden Surfaces CS-184: Computer Graphics Prof. James O’Brien.
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
10/11/2001CS 638, Fall 2001 Today Kd-trees BSP Trees.
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
Adapted from Ben Slides
10/29/02 (c) 2002 University of Wisconsin, CS559 Today Hidden Surface Removal Exact Visibility.
CSE 381 – Advanced Game Programming Basic 3D Graphics
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.
CS 450: COMPUTER GRAPHICS REVIEW: INTRODUCTION TO COMPUTER GRAPHICS – PART 2 SPRING 2015 DR. MICHAEL J. REALE.
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.
Using BSP for CD Ref: BSP in deBerg et al ’ s book (url)url.
CAP4730: Computational Structures in Computer Graphics 3D Transformations.
Hidden Surface Removal 1.  Suppose that we have the polyhedron which has 3 totally visible surfaces, 4 totally invisible/hidden surfaces, and 1 partially.
2 COEN Computer Graphics I Evening’s Goals n Discuss application bottleneck determination n Discuss various optimizations for making programs execute.
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.
Binary Space Partitioning Trees Ray Casting Depth Buffering
Implementation II.
Computer Graphics Zhen Jiang West Chester University.
CS 325 Introduction to Computer Graphics 03 / 29 / 2010 Instructor: Michael Eckmann.
David Luebke 1 12/8/2015 Visibility CS 445/645 Introduction to Computer Graphics David Luebke, Spring 2003.
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.
Honours Graphics 2008 Session 5. Today’s focus Rasterization Visibility determination Coarse / fine visibility determination.
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.
BSP Tree Supplement Jyun-Ming Chen. Fall Kd-Tree and BSP tree kd-tree is a special kind of bsp tree.
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.
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
Visible Surface Detection
Computer Graphics Implementation II
Hidden Surface Removal
CSC418 Computer Graphics Back Faces Visibility Algorithms.
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Hidden Surfaces Dr. Scott Schaefer.
CSCE 441: Computer Graphics Hidden Surface Removal
Implementation II Ed Angel Professor Emeritus of Computer Science
Lecture 13 Clipping & Scan Conversion
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
CSCE 441: Computer Graphics Hidden Surface Removal (Cont.)
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

CAP4730: Computational Structures in Computer Graphics Visible Surface Determination

Outline The goal of visible surface determination Normals Backface Culling Depth Buffer BSP Trees Determining if something isn’t in the view frustum (research topics)

Goal of Visible Surface Determination To draw only the surfaces (triangles) that are visible, given a view point and a view direction

Three reasons to not draw something 1. It isn’t in the view frustum 2. It is “back facing” 3. Something is in front of it (occlusion) We need to do this computation quickly. How quickly?

Surface Normal Surface Normal - vector perpendicular to the surface Three non-collinear points (that make up a triangle), also describes a plane. The normal is the vector perpendicular to this plane.

Normals

How do we compute a normal? Q: Given a Triangle, how do we compute a normal? A: Normal = V 0 V 1 X V 0 V 2 But…. we know V 0 V 1 X V 0 V 2 != V 0 V 2 X V 0 V 1

Vertex Order Vertex order matters. We usually agree that counterclockwise determines which “side” or a triangle is labelled the “front”. Think: Right handed coordinate system.

What do the normals tell us? Q: How can we use normals to tell us which “face” of a triangle we see?

Examine the angle between the normal and the view direction V N Front if V. N <0

Viewing Coordinates If we are in viewing coordinates, how can we simplify our comparison? Think about the different components of the normals you want and don’t want.

Backface Culling Before scan converting a triangle, determine if it is facing you Compute the dot product between the view vector (V) and triangle normal (N) Simplify this to examining only the z component of the normal If N z <0 then it is a front facing triangle, and you should scan convert it What surface visibility problems does this solve? Not solve? Review OpenGL code

Multiple Objects If we want to draw: We can sort in z. What are the advantages? Disadvantages? Called Painter’s Algorithm or splatting.

Painter’s Algorithm Subtleties What do we mean sort in z? That is for a triangle, what is its representative z value? –Minimum z –Maximum z –Polygon’s centroid Work cost = sort + draw We still use Painter’s Algorithms for blended objects (discussed in the Blending Lesson) An object space visibility algorithm

Side View

Side View - What is a solution?

Even Worse… Why?

Painter’s Algorithm Pros: –No extra memory –Relatively fast –Easy to understand and implement Cons: –Precision issues (and additional work to handle them) –Sort stage –Intersecting objects

Depth Buffers Goal: We want to only draw something if it appears in front of what is already drawn. What does this require? Can we do this on a per object basis?

Depth Buffers We can’t do it object based, it must be image based. What do we know about the x,y,z points where the objects overlap? Remember our “eye” or “camera” is at the origin of our view coordinates. What does that mean need to store?

Side View

Algorithm We need to have an additional value for each pixel that stores the depth value. What is the data type for the depth value? How much memory does this require? Playstation 1 had 2 MB. The first 512 x 512 framebuffer cost $50,000 Called Depth Buffering or Z buffering

Depth Buffer Algorithm Begin frame –Clear color –Clear depth to z = z max Draw Triangles –When scan converting z new pixel < z value at the pixel, set color and z value at the pixel = z new pixel –What does it mean if z new pixel > z value at the pixel ? –Why do we clear the depth buffer? –Now we see why it is sometimes called the z buffer

Computing the z new pixel Q: We can compute the z nsc at the vertices, but what is the z nsc as we scan convert? A: We interpolate z nsc while we scan convert too!

Metrics for Visibility Algorithms Running Time - 1 extra compare Storage Overhead - 1 extra field per pixel Overdraw - we have to scan convert all triangles Memory Bandwidth - how much we have to retrieve from memory. Increased Precision - Let’s examine the possible values of z and what that means

Z Buffer Precision What does the # of bits for a depth buffer element mean? The z from eye space to normalized screen space is not linear. That is we do not have the same precision across z. (we divided by z). In fact, half of our precision is in z=0 and z=0.5. What does this mean? What happens if we do NOT have enough precision?

Z Fighting If we do not have enough precision in the depth buffer, we can not determine which fragment should be “in front”. What does this mean for the near and far plane? We want them to as closely approximate our volume

Z Fighting Zoomed In Run Demo

Don’t forget Even in 1994, memory wasn’t cheap. If we wanted 1024x768x16bit = 1.6 MB additional memory. Depth Buffers weren’t common till recently because of this. Since we have to draw every triangle -> fill rate goes UP. Currently graphics cards approach the many billions of pixels per second. An image space algorithm Let’s review OpenGL code

Depth Buffer Algorithm Pros: –Easy to understand and implement –per pixel “correct” answer –no preprocess –draw objects in any order –no need to redivide objects Cons: –Z precision –additional memory –Z fighting

BSP Trees (Fuchs, et. al 1980) Binary Space Partitioning –Doom and most games before depthbuffers (circa ) –Given a world, we want to build a data structure that given any point, it can return a sorted list of objects –What assumptions are we making? –Note, what happens in those “old” games like Doom?

BSP Trees Two stages: –preprocess - we do this at the “offline” –runtime - what we do per frame Draw parallels to Doom –Since this is easier in 2D, note all “old” FPS are really 3D.

BSP Algorithm For a viewpoint, determine where it sits on the tree. Now draw objects on the “other half of the tree” –farside.draw(viewpoint) –nearside.draw(viewpoint) Intuition - we draw things farther away first Is this an image space or object space algorithm?

BSP Trees Pros –Preprocess step means fast determination of what we can see and can’t –Works in 3D -> Quake1 –Painter’s algorithm Pros Cons –Still has intersecting object problems –Static scene

Determining if something is viewable Viewfrustum Culling (football example) Cells and Portals –definitions cell portal –preprocess step –runtime computation –where do we see it? Quake3