Computer Graphics. Bing-Yu Chen National Taiwan University

Similar documents
Computer Graphics. Bing-Yu Chen National Taiwan University The University of Tokyo

Page 1. Area-Subdivision Algorithms z-buffer Algorithm List Priority Algorithms BSP (Binary Space Partitioning Tree) Scan-line Algorithms

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

Identifying those parts of a scene that are visible from a chosen viewing position, and only process (scan convert) those parts

Hidden surface removal. Computer Graphics

CEng 477 Introduction to Computer Graphics Fall 2007

9. Visible-Surface Detection Methods

Hidden Surface Removal

Hidden Surface Elimination: BSP trees

Spatial Data Structures

Computing Visibility. Backface Culling for General Visibility. One More Trick with Planes. BSP Trees Ray Casting Depth Buffering Quiz

Visible-Surface Detection Methods. Chapter? Intro. to Computer Graphics Spring 2008, Y. G. Shin

Spatial Data Structures

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Spatial Data Structures and Speed-Up Techniques. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Visibility and Occlusion Culling

CSE328 Fundamentals of Computer Graphics: Concepts, Theory, Algorithms, and Applications

Visible Surface Detection Methods

Announcements. Written Assignment2 is out, due March 8 Graded Programming Assignment2 next Tuesday

Today. CS-184: Computer Graphics. Lecture #10: Clipping and Hidden Surfaces. Clipping. Hidden Surface Removal

Spatial Data Structures

Werner Purgathofer

Spatial Data Structures

Visible Surface Determination: Intro

8. Hidden Surface Elimination

Spatial Data Structures

VIII. Visibility algorithms (II)

More Hidden Surface Removal

Computer Graphics II

Visibility: Z Buffering

Drawing the Visible Objects

Ray Tracing III. Wen-Chieh (Steve) Lin National Chiao-Tung University

CS 563 Advanced Topics in Computer Graphics Culling and Acceleration Techniques Part 1 by Mark Vessella

Overview. Pipeline implementation I. Overview. Required Tasks. Preliminaries Clipping. Hidden Surface removal

Visible Surface Detection. (Chapt. 15 in FVD, Chapt. 13 in Hearn & Baker)

CS559: Computer Graphics. Lecture 12: Antialiasing & Visibility Li Zhang Spring 2008

Rendering. Converting a 3D scene to a 2D image. Camera. Light. Rendering. View Plane

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

More Visible Surface Detection. CS116B Chris Pollett Mar. 16, 2005.

Computer Graphics: 8-Hidden Surface Removal

Computer Graphics. Rendering. by Brian Wyvill University of Calgary. cpsc/enel P 1

Pipeline Operations. CS 4620 Lecture 10

Determination (Penentuan Permukaan Tampak)

Class of Algorithms. Visible Surface Determination. Back Face Culling Test. Back Face Culling: Object Space v. Back Face Culling: Object Space.

Ray Tracing: Intersection

Lecture 11: Ray tracing (cont.)

CSE 167: Lecture #5: Rasterization. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2012

CS 498 VR. Lecture 18-4/4/18. go.illinois.edu/vrlect18

8. Hidden Surface Elimination

Advanced 3D-Data Structures

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

3D Object Representation

CSE 167: Introduction to Computer Graphics Lecture #9: Visibility. Jürgen P. Schulze, Ph.D. University of California, San Diego Fall Quarter 2018

Clipping & Culling. Lecture 11 Spring Trivial Rejection Outcode Clipping Plane-at-a-time Clipping Backface Culling

Speeding up your game

VISIBILITY & CULLING. Don t draw what you can t see. Thomas Larsson, Afshin Ameri DVA338, Spring 2018, MDH

CS Computer Graphics: Hidden Surface Removal

Clipping. Angel and Shreiner: Interactive Computer Graphics 7E Addison-Wesley 2015

Real-Time Rendering (Echtzeitgraphik) Dr. Michael Wimmer

Lecture 25 of 41. Spatial Sorting: Binary Space Partitioning Quadtrees & Octrees

Renderer Implementation: Basics and Clipping. Overview. Preliminaries. David Carr Virtual Environments, Fundamentals Spring 2005

Chapter 11 Global Illumination. Part 1 Ray Tracing. Reading: Angel s Interactive Computer Graphics (6 th ed.) Sections 11.1, 11.2, 11.

Spatial Data Structures and Speed-Up Techniques. Ulf Assarsson Department of Computer Science and Engineering Chalmers University of Technology

Acceleration Data Structures

Accelerating Ray-Tracing

COMP 175: Computer Graphics April 11, 2018

CS488. Visible-Surface Determination. Luc RENAMBOT

INFOGR Computer Graphics. J. Bikker - April-July Lecture 11: Visibility. Welcome!

Solid Modeling. Thomas Funkhouser Princeton University C0S 426, Fall Represent solid interiors of objects

Binary Space Partition Trees. Overview. Binary Space Partitioning Trees (Fuchs, Kedem and Naylor `80)

The Traditional Graphics Pipeline

Ray tracing. Computer Graphics COMP 770 (236) Spring Instructor: Brandon Lloyd 3/19/07 1

Hidden-Surface Removal.

Painter s HSR Algorithm

Point Cloud Filtering using Ray Casting by Eric Jensen 2012 The Basic Methodology

The Traditional Graphics Pipeline

Computer Graphics Shadow Algorithms

Scene Management. Video Game Technologies 11498: MSc in Computer Science and Engineering 11156: MSc in Game Design and Development

Sung-Eui Yoon ( 윤성의 )

Effects needed for Realism. Ray Tracing. Ray Tracing: History. Outline. Foundations of Computer Graphics (Spring 2012)

Algorithms for GIS:! Quadtrees

Culling. Computer Graphics CSE 167 Lecture 12

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics Fall 2010 Don Fussell

Anti-aliased and accelerated ray tracing. University of Texas at Austin CS384G - Computer Graphics

The Traditional Graphics Pipeline

Global Rendering. Ingela Nyström 1. Effects needed for realism. The Rendering Equation. Local vs global rendering. Light-material interaction

Hidden Surfaces II. Week 9, Mon Mar 15

CS452/552; EE465/505. Clipping & Scan Conversion

Two basic types: image-precision and object-precision. Image-precision For each pixel, determine which object is visable Requires np operations

4.5 VISIBLE SURFACE DETECTION METHODES

Pipeline Operations. CS 4620 Lecture Steve Marschner. Cornell CS4620 Spring 2018 Lecture 11

(Refer Slide Time 03:00)

University of British Columbia CPSC 314 Computer Graphics Jan-Apr Tamara Munzner. Hidden Surfaces.

Intersection Acceleration

Spatial Data Structures and Acceleration Algorithms

CSE 167: Introduction to Computer Graphics Lecture #10: View Frustum Culling

Motivation. Culling Don t draw what you can t see! What can t we see? Low-level Culling

Pipeline Operations. CS 4620 Lecture 14

Ray Tracing Acceleration Data Structures

Transcription:

Computer Graphics Bing-Yu Chen National Taiwan University

Visible-Surface Determination Back-Face Culling The Depth-Sort Algorithm Binary Space-Partitioning Trees The z-buffer Algorithm Scan-Line Algorithm Visible-Surface Ray Tracing (Ray Casting) Warnock s Algorithm

Visible-Surface Determination = Hidden Surface Removal Determining what to render at each pixel. A point is visible if there exists a direct line-of-sight to it, unobstructed by another other objects (visible surface determination). Moreover, some objects may be invisible because there are behind the camera, outside of the field-ofview, too far away (clipping) or back faced (backface culling).

Hidden Surfaces: why care? Occlusion: Closer (opaque) objects along same viewing ray obscure more distant ones. Reasons for removal Efficiency: As with clipping, avoid wasting work on invisible objects. Correctness: The image will look wrong if we don t model occlusion properly.

Back-Face Culling = Front Facing B x A D C H E F z G

Back-Face Culling = Front Facing use cross-product to get the normal of the face (not the actual normal) use inner-product to check the facing N v 1 N = ( v v ) ( v v ) 2 1 3 1 v 2 V v 3

Clipping (View Frustum Culling) view frustum eye back face occlusion view frustum

List-Priority Algorithms The Painter s Algorithm The Depth-Sort Algorithm Binary Space-Partitioning Trees

The Painter s Algorithm Draw primitives from back to front need for depth comparisons.

The Painter s Algorithm for the planes with constant z not for real 3D, just for 2½D sort all polygons according to the smallest (farthest) z coordinate of each scan convert each polygon in ascending order of smallest z coordinate (i.e., back to front)

The Depth-Sort Algorithm sort all polygons according to the smallest (farthest) z coordinate of each resolve any ambiguities that sorting may cause when the polygons z extents overlap, splitting polygons if necessary scan convert each polygon in ascending order of smallest z coordinate (i.e., back to front)

Overlap Cases x y y R P Q Q P P Q z x x

Overlap Detection Do the polygons x not overlap? Do the polygons y not overlap? Is P entirely on the opposite side of Q s plane from the viewpoint? Is Q entirely on the same side of P s plane as the viewpoint? Do the projections of the polygons onto the (x,y) plane not overlap?

Binary Space-Partitioning Trees An improved painter s algorithm Key observation: f(p)<0 f(p)>0 T 3 T 1 T 5 T 2 T 4 Ax+By+Cz+D=0 f(p): n(p-a)=0

Binary Space-Partitioning Trees - T 1 + T 1 T 2 T 3 T 2 T 3

Binary Space-Partitioning Trees - T 1 + T 1 - T 2 + T 3 T 2 T 3

Splitting triangles a a A c A c B B b b

BSP Tree Construction BSPtree makebsp(l: list of polygons) { if (L is empty) { return the empty tree; } Choose a polygon P from L to serve as root; Split all polygons in L according to P return new TreeNode ( P, makebsp(polygons on negative side of P), makebsp(polygons on positive side of P)) } Splitting polygons is expensive! It helps to choose P wisely at each step. Example: choose five candidates, keep the one that splits the fewest polygons.

BSP Tree Display void showbsp(v: Viewer, T: BSPtree) { if (T is empty) return; P = root of T; if (viewer is in front of P) { showbsp(back subtree of T); draw P; showbsp(front subtree of T); } else { showbsp(front subtree of T); draw P; showbsp(back subtree of T); } } 2D BSP demo

Binary Space-Partitioning Trees P1 P1 A P2 front back 1 P2 P2 D 3 C 2 B back front front back D C A B 3,1,2 3,2,1 1,2,3 2,1,3 extremely efficient for static objects

Binary Space-Partitioning Trees Same BSP tree can be used for any eye position, constructed only once if the scene if static. It does not matter whether the tree is balanced. However, splitting triangles is expensive and try to avoid it by picking up different partition planes.

BSP Tree 6 5 9 7 1 10 11 8 2 4 3

BSP Tree 6 5 1 7 1 10 9 11 8 inside ones outside ones 2 4 3

BSP Tree 6 5 1 2 7 1 10 9 11 8 2 3 4 5 6 7 8 9 10 11 4 3

BSP Tree 6 5 1 2 7 1 10 9a 11a 9 9b 11b 11 8 6 7 9a 10 11a 5 8 9b 11b 4 3

BSP Tree 6 5 1 9 9b 2 5 2 7 1 10 9a 11a 11 11b 8 4 3 7 6 9b 8 4 9a 11b 3 10 11a

BSP Tree 6 5 1 9 9b 2 5 2 7 1 10 9a 11a 11 11b 8 4 3 7 6 9b 8 3 4 point 10 9a 11b 11a

BSP Tree Traversal 6 5 1 9 9b 2 5 2 7 1 10 9a 11a 11 11b 8 4 3 7 6 9b 8 3 4 point 10 9a 11b 11a

BSP Tree Traversal 6 5 1 9 9b 2 5 2 7 1 10 9a 11a 11 11b 8 4 3 7 6 9b 8 3 4 point 10 9a 11b 11a

The z-buffer Algorithm Resolve depths at the pixel level Idea: add Z to frame buffer, when a pixel is drawn, check whether it is closer than what s already in the frame buffer

The z-buffer Algorithm + = + =

The z-buffer Algorithm void zbuffer() { int pz; for (each polygon) { for (each pixel in polygon s projection) { pz=polygon s z-value at (x,y); if (pz>=readz(x,y)) { WriteZ(x,y,pz); WritePixel(x,y,color); } } } }

The z-buffer Algorithm y y 1 y 2 y 3 y s z 1 z 2 z 3 z a z p z b Scan line a b p b a b b p s b s a x x x x z z z z y y y y z z z z y y y y z z z z = = = ) ( ) ( ) ( 3 1 1 3 1 1 2 1 1 2 1 1

z-buffer: Example color buffer depth buffer

The z-buffer Algorithm Benefits Easy to implement Works for any geometric primitive Parallel operation in hardware independent of order of polygon drawn Limitations Memory required for depth buffer Quantization and aliasing artifacts Overfill Transparency does not work well

Scan-Line Algorithm y E γ+2 γ+1 γ D B β C α F A x

Scan-Line Algorithm AET contents Scan line Entries ET entry x y max Δx ID α AB AC β AB AC FD FE γ,γ+1 AB DE CB FE PT entry ID Plane eq. Shading info In-out γ+2 AB CB DE FE ET = edge table PT = polygon table AET = active-edge table

General Scan-Line Algorithm add surfaces to polygon table (PT); initialize active-edge table (AET); for (each scan line) { update AET; } for (each pixel on scan line) { determine surfaces in AET that project to pixel; find closest such surface; determine closest surface s shade at pixel; }

Ray Tracing = Ray Casting select center of projection and window on viewplane; for (each scan line in image) { for (each pixel in scan line) { determine ray from center of projection through pixel; for (each object in scene) { if (object is intersected and is closest considered thus far) record intersection and object name; } set pixel s color to that at closest object intersection; } }

Ray Casting Center of projection Window

Ray Casting (Appel, 1968)

Ray Casting (Appel, 1968)

Ray Casting (Appel, 1968)

Ray Casting (Appel, 1968) k a I a + nls i= 1 I i ( ( ) + ( ) ) n k L N k R V d i s i

Ray Casting (Appel, 1968) direct illumination

Spatial Partitioning

Spatial Partitioning R C A B

Spatial Partitioning 1 A B 3 2

Space Subdivision Approaches Uniform grid K-d tree

Space Subdivision Approaches Quadtree (2D) Octree (3D) BSP tree

Uniform Grid

Uniform Grid Preprocess scene 1. Find bounding box

Uniform Grid Preprocess scene 1. Find bounding box 2. Determine grid resolution

Uniform Grid Preprocess scene 1. Find bounding box 2. Determine grid resolution 3. Place object in cell if its bounding box overlaps the cell

Uniform Grid Preprocess scene 1. Find bounding box 2. Determine grid resolution 3. Place object in cell if its bounding box overlaps the cell 4. Check that object overlaps cell (expensive!)

Uniform Grid Traversal Preprocess scene Traverse grid 3D line = 3D-DDA

From Uniform Grid to Quadtree

Quadtree (Octrees) subdivide the space adaptively

Quadtree Data Structure Quadrant Numbering

Quadtree Data Structure Quadrant Numbering

Quadtree Data Structure Quadrant Numbering

Quadtree Data Structure Quadrant Numbering

From Quadtree to Octree y x z

K-d Tree A A Leaf nodes correspond to unique regions in space

K-d Tree A B A Leaf nodes correspond to unique regions in space

K-d Tree A B B A Leaf nodes correspond to unique regions in space

K-d Tree C A B B A

K-d Tree C A B B C A

K-d Tree C A D B B C A

K-d Tree C A D B B A D C

K-d Tree A D B B C C D A Leaf nodes correspond to unique regions in space

K-d Tree Traversal A D B B C C D A Leaf nodes correspond to unique regions in space

Warnock s Algorithm an area-subdivision algorithm

Warnock s Algorithm 1. all the polygons are disjoint from the area 2. there is only one intersecting or only one contained polygon 3. there is a single surrounding polygon, but no intersecting or contained polygons 4. more than one polygon is intersecting, contained in, or surrounding the area, but one is a surrounding polygon that is in front of all the other polygons

Warnock s Algorithm surrounding intersecting contained disjoint

Warnock s Algorithm x x Contained polygon Intersecting polygon z Intersecting polygon Surrounding polygon z Surrounding polygon

Performance of Four Algorithms for Visible-Surface Determination Algorithm Number of Polygons 100 2,500 60,000 Depth sort 1 10 507 z-buffer 54 54 54 Scan line 5 21 100 Warnock area subdivision 11 64 307