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

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

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

Hidden surface removal. Computer Graphics

CEng 477 Introduction to Computer Graphics Fall 2007

Spatial Data Structures

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

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

9. Visible-Surface Detection Methods

Hidden Surface Elimination: BSP trees

Spatial Data Structures

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

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

Hidden Surface Removal

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

Visible Surface Detection Methods

Spatial Data Structures

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

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Spatial Data Structures

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

Spatial Data Structures

Werner Purgathofer

Visibility and Occlusion Culling

More Hidden Surface Removal

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

Drawing the Visible Objects

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

VIII. Visibility algorithms (II)

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

Computer Graphics II

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

Ray Tracing: Intersection

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

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

Advanced 3D-Data Structures

Visibility: Z Buffering

8. Hidden Surface Elimination

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

Determination (Penentuan Permukaan Tampak)

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

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

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

Visible Surface Determination: Intro

Pipeline Operations. CS 4620 Lecture 10

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

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

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

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

FROM VERTICES TO FRAGMENTS. Lecture 5 Comp3080 Computer Graphics HKBU

CS Computer Graphics: Hidden Surface Removal

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

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

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

Painter s HSR Algorithm

The Traditional Graphics Pipeline

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

3D Object Representation

8. Hidden Surface Elimination

Acceleration Data Structures

The Traditional Graphics Pipeline

Lecture 11: Ray tracing (cont.)

Real-Time Rendering (Echtzeitgraphik) Dr. Michael Wimmer

Last Time: Acceleration Data Structures for Ray Tracing. Schedule. Today. Shadows & Light Sources. Shadows

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

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

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

graphics pipeline computer graphics graphics pipeline 2009 fabio pellacini 1

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

Spatial Data Structures and Acceleration Algorithms

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

Computer Graphics: 8-Hidden Surface Removal

COMP 175: Computer Graphics April 11, 2018

Intersection Acceleration

Accelerating Ray-Tracing

The Traditional Graphics Pipeline

Ray Tracing Acceleration Data Structures

Algorithms for GIS:! Quadtrees

Computer Graphics Shadow Algorithms

Accelerated Raytracing

Spatial Data Structures and Acceleration Algorithms

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

Hidden-Surface Removal.

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

Hidden Surfaces II. Week 9, Mon Mar 15

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

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

Topic #1: Rasterization (Scan Conversion)

Computer Graphics (CS 543) Lecture 13b Ray Tracing (Part 1) Prof Emmanuel Agu. Computer Science Dept. Worcester Polytechnic Institute (WPI)

Accelerating Ray Tracing

Culling. Computer Graphics CSE 167 Lecture 12

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

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

Spatial Data Structures for Computer Graphics

Previously... contour or image rendering in 2D

BSP Trees. Chapter Introduction. 8.2 Overview

Transcription:

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

Hidden-Surface Removal Back-Face Culling The Depth-Sort Algorithm Binary Space-Partitioning Trees The z-buffer Algorithm Visible-Surface Ray Tracing (Ray Casting) Space Subdivision Approaches

Hidden-Surface Removal =Visible-Surface Determination 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

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

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

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

K-d Tree A B A

K-d Tree A B B A

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