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

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

Speeding up your game

Spatial Data Structures and Acceleration Algorithms

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

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

Spatial Data Structures and Acceleration Algorithms

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

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

Spatial Data Structures

Acceleration Data Structures. Michael Doggett Department of Computer Science Lund university

Spatial Data Structures

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

Computer Graphics. Bing-Yu Chen National Taiwan University

Spatial Data Structures

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

Spatial Data Structures

Spatial Data Structures

l Without collision detection (CD), it is practically impossible to construct e.g., games, movie production tools (e.g., Avatar)

Computer Graphics. Lecture 9 Hidden Surface Removal. Taku Komura

Acceleration Data Structures

LOD and Occlusion Christian Miller CS Fall 2011

COMP 175: Computer Graphics April 11, 2018

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

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

Hidden surface removal. Computer Graphics

Ray Tracing Acceleration Data Structures

Culling. Computer Graphics CSE 167 Lecture 12

CPSC / Sonny Chan - University of Calgary. Collision Detection II

Using Bounding Volume Hierarchies Efficient Collision Detection for Several Hundreds of Objects

Acceleration Data Structures for Ray Tracing

EECE 478. Learning Objectives. Learning Objectives. Rasterization & Scenes. Rasterization. Compositing

TDA362/DIT223 Computer Graphics EXAM (Same exam for both CTH- and GU students)

S U N G - E U I YO O N, K A I S T R E N D E R I N G F R E E LY A VA I L A B L E O N T H E I N T E R N E T

Hidden Surface Elimination: BSP trees

Ray Tracing: Intersection

Accelerating Geometric Queries. Computer Graphics CMU /15-662, Fall 2016

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

Universiteit Leiden Computer Science

improving raytracing speed

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

Visibility and Occlusion Culling

Algorithms for GIS:! Quadtrees

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

Project Gotham Racing 2 (Xbox) Real-Time Rendering. Microsoft Flighsimulator. Halflife 2

Computer Graphics. - Spatial Index Structures - Philipp Slusallek

CS535 Fall Department of Computer Science Purdue University

Intersection Acceleration

Real-Time Rendering (Echtzeitgraphik) Dr. Michael Wimmer

CSE 167: Introduction to Computer Graphics Lecture #11: Visibility Culling

Ray Tracing. Cornell CS4620/5620 Fall 2012 Lecture Kavita Bala 1 (with previous instructors James/Marschner)

Topic 10: Scene Management, Particle Systems and Normal Mapping. CITS4242: Game Design and Multimedia

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

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

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

Comparison of hierarchies for occlusion culling based on occlusion queries

Sung-Eui Yoon ( 윤성의 )

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

11 - Spatial Data Structures

Shadow Rendering EDA101 Advanced Shading and Rendering

Ray Tracing with Spatial Hierarchies. Jeff Mahovsky & Brian Wyvill CSC 305

Spatial Data Structures. Steve Rotenberg CSE168: Rendering Algorithms UCSD, Spring 2017

Computer Graphics. - Ray-Tracing II - Hendrik Lensch. Computer Graphics WS07/08 Ray Tracing II

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

CS 563 Advanced Topics in Computer Graphics QSplat. by Matt Maziarz

Accelerated Raytracing

More Hidden Surface Removal

Space-based Partitioning Data Structures and their Algorithms. Jon Leonard

Spatial Data Structures for Computer Graphics

CS451Real-time Rendering Pipeline

Lecture 18 of 41. Scene Graphs: Rendering Lab 3b: Shader

Ray Tracing II. Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology

Lecture 11: Ray tracing (cont.)

Ray Tracing. Computer Graphics CMU /15-662, Fall 2016

Homework 1: Implicit Surfaces, Collision Detection, & Volumetric Data Structures. Loop Subdivision. Loop Subdivision. Questions/Comments?

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

CSE528 Computer Graphics: Theory, Algorithms, and Applications

Many rendering scenarios, such as battle scenes or urban environments, require rendering of large numbers of autonomous characters.

Speeding Up Ray Tracing. Optimisations. Ray Tracing Acceleration

Accelerating Ray-Tracing

Topics. Ray Tracing II. Intersecting transformed objects. Transforming objects

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

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

Advanced 3D-Data Structures

Recall: Inside Triangle Test

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

Ulf Assarsson Department of Computer Engineering Chalmers University of Technology

Bounding Volume Hierarchies

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

Lecture 2 - Acceleration Structures

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

Collision Detection. These slides are mainly from Ming Lin s course notes at UNC Chapel Hill

Topics. Ray Tracing II. Transforming objects. Intersecting transformed objects

CPSC GLOBAL ILLUMINATION

Accelerating Ray Tracing

Bounding Volume Hierarchies. CS 6965 Fall 2011

Collision Detection. Pu Jiantao.

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

Advanced Ray Tracing

Specialized Acceleration Structures for Ray-Tracing. Warren Hunt

Transcription:

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

Spatial data structures What is it? Data structure that organizes geometry in 2D or 3D or higher The goal is faster processing Needed for most speed-up techniques Faster real-time rendering Faster intersection testing Faster collision detection Faster ray tracing and global illumination Games use them extensively Movie production rendering tools always use them too Read Designing a PC Game Engine. Link available on website

How? Organizes geometry in some hierarchy In 2D space Data structure

What s the point? An example Assume we click on screen, and want to find which object we clicked on click! 1) Test the root first 2) Descend recursively as needed 3) Terminate traversal when possible In general: get O(log n) instead of O(n)

Bounding Volume Hierarchy (BVH) Most common bounding volumes (BVs): Sphere Boxes (AABB and OBB) The BV does not contibute to the rendered image -- rather, encloses an object The data structure is a k-ary tree Leaves hold geometry Internal nodes have at most k children Internal nodes hold BVs that enclose all geometry in its subtree

Some facts about trees Height of tree, h, is longest path from root to leaf A balanced tree has all leaves at height h or h-1 Height of balanced tree with n nodes: floor( log k (n) ) Binary tree (k=2) is the simplest k=4 and k=8 is quite common for computer graphics as well

How to create a BVH? Example: BV=AABB Find minimal box, then split along longest axis x is longest Find minimal boxes Split along longest axis Find minimal boxes Called TOP-DOWN method More complex for other BVs

Stopping criteria for Top-Down creation Need to stop recursion some time Either when BV is empty Or when only one primitive (e.g. triangle) is inside BV Or when <n primitives is inside BV Or when recursion level l has been reached Similar critera for BSP trees and octrees

Binary Space Partitioning (BSP) Trees Two different types: Axis-aligned Polygon-aligned (treated in other graphics course, and in handout text) General idea: Divide space with a plane Sort geometry into the space it belongs Done recursively If traversed in a certain way, we can get the geometry sorted along an axis Exact for polygon-aligned Approximately for axis-aligned

Axis-Aligned BSP tree (1) Can only make a splitting plane along x,y, or z Minimal box Split along plane Split along plane Split along plane

Axis-Aligned BSP tree (2) A Plane 1a B D Plane 0 Plane 2 Plane 1b E 0 1a 1b A B C 2 C D E Each internal node holds a divider plane Leaves hold geometry Differences compared to BVH Encloses entire space and provides sorting The BV hierarchy can be constructed in any way (no sort) BVHs can use any desirable type of BV

Axis-aligned BSP tree Rough sorting Test the planes against the point of view Test recursively from root Continue on the hither side to sort front to back 1a 0 2 1b eye A 1a B 4 5 0 1b C 2 Works in the same way for polygonaligned BSP trees --- but that gives exact sorting 1 D 3 E 2

Polygon-aligned BSP tree Very briefly since treated in the other course on computer graphics Allows exact sorting Very similar to axis-aligned BSP tree But the splitting plane are now located in the planes of the triangles

Algorithm for BSP trees Tree CreateBSP(PolygonList L) { If L empty, return empty tree; Else: T->P = arbitrary polygon in L. T->behindP = CreateBSP(polygons behind P) T->frontOfP = CreateBSP(polygons in front of P) Return t. } class BSPtree: Polygon P; BSPtree behindp; BSPtree frontofp; Drawing Back-to-Front void DrawBSP(Tree t) { If (t==null) return; If eye front of polygon t->p: DrawBSP(t->behindP); Draw P; DrawBSP(t->frontOfP); Else: DrawBSP(t->frontOfP); Draw P; DrawBSP(t->behindP); Ulf Assarsson 2006

Octrees (1) A bit similar to axis-aligned BSP trees Will explain the quadtree, which is the 2D variant of an octree In 3D each square (or rectangle) becomes a box, and 8 children

Octrees (2) Expensive to rebuild (BSPs are too) loose octrees, page 354 A relaxation to avoid problems Octrees can be used to Speed up ray tracing Faster picking Culling techniques Are not used that often in real-time contexts An exception is loose octrees

Scene graphs BVH is the data structure that is used most often Simple to understand Simple code However, it stores just geometry Rendering is more than geometry The scene graph is an extended BVH with: Lights Textures Transforms And more

Speed-Up Techniques Spatial data structures are used to speed up rendering and different queries Why more speed? Graphics hardware 2x faster in 6 months! Wait then it will be fast enough! NOT! We will never be satisfied Screen resolution: 3000x1500 Realism: global illumination Geometrical complexity: no upper limit!

What we ll treat now Culling techniques Level-of-detail rendering (LODs) To cull means to select from group In graphics context: do not process data that will not contribute to the final image

Different culling techniques (red objects are skipped) view frustum detail backface occlusion

Backface Culling Simple technique to discard polygons that faces away from the viewer Can be used for: closed surface (example: sphere) or whenever we know that the backfaces never should be seen (example: walls in a room) Two methods (screen space, eye space) Which stages benefits? Rasterizer, but also Geometry (where test is done)

0 Backface culling (cont d) Often implemented for you in the API OpenGL: glcullface(gl_back); How to determine what faces away? First, must have consistently oriented polygons, e.g., counterclockwise front facing 1 2 1 back facing 2 0

How to cull backfaces Two ways in different spaces: 1 2 2 eye back 0 1 front back screen space 0 eye space front

View-Frustum Culling Bound every natural group of primitives by a simple volume (e.g., sphere, box) If a bounding volume (BV) is outside the view frustum, then the entire contents of that BV is also outside (not visible)

Can we accelerate view frustum culling further? Do what we always do in graphics Use a hierarchical approach, e.g., a spatial data structure (BVH, BSP, scene graph) Which stages benefits? Geometry and Rasterizer Bus between CPU and Geometry

Example of Hierarchical View Frustum Culling root camera

Portal Culling Images courtesy of David P. Luebke and Chris Georges Average: culled 20-50% of the polys in view Speedup: from slightly better to 10 times

Portal culling example In a building from above Circles are objects to be rendered

Portal Culling Algorithm (1) Divide into cells with portals (build graph) For each frame: Locate cell of viewer and init 2D AABB to whole screen * Render current cell with View Frustum culling w.r.t. AABB Traverse to closest cells (through portals) Intersection of AABB & AABB of traversed portal Goto *

Portal Culling Algorithm (2) When to exit: When the current AABB is empty When we do not have enough time to render a cell ( far away from the viewer) Also: mark rendered objects

Occlusion Culling Main idea: Objects that lies completely behind another set of objects can be culled Hard problem to solve efficiently Lots of research in this area

Example final image Note that Portal Culling is type of occlusion culling

Occlusion culling algorithm Use some kind of occlusion representation O R for each object g do: if( not Occluded(O R,g)) render(g); update(o R,g); end; end;

Occlusion Horizon: A simple algorithm Target: urban scenery dense occlusion viewer is about 2 meters above ground Algorithm: Process scene in front-to-back using a quad tree Maintain a piecewise constant horizon Cull objects against horizon Add visible objects occluding power to the horizon

Occlusion testing with occlusion horizons To process tetrahedron (which is behind grey objects): find axis-aligned box of projection compare against occlusion horizon culled

Update horizon When an object is considered visible: Add its occluding power to the occlusion representation

Example: Read about the details in paper on website (compulsory material!)

Level-of-Detail Rendering Use different levels of detail at different distances from the viewer More triangles closer to the viewer

LOD rendering Not much visual difference, but a lot faster Use area of projection of BV to select appropriate LOD

Scene graph with LODs Large area Car chair Area? medium area small area

Far LOD rendering When the object is far away, replace with a quad of some color When the object is really far away, do not render it (called: detail culling)! Use projected area of BV to determine when to skip