10/02/03CS679 - Fall 2003 - Copyright Univ. of Wisconsin Last Time Octrees.

Slides:



Advertisements
Similar presentations
Visible-Surface Detection(identification)
Advertisements

1 Binary Space Partition Trees ©Anthony Steed, Yiorgos Chrysanthou
Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Advanced Light and Shadow Culling Methods Eric Lengyel.
Collision Detection CSCE /60 What is Collision Detection?  Given two geometric objects, determine if they overlap.  Typically, at least one of.
Computer graphics & visualization Collisions. computer graphics & visualization Simulation and Animation – SS07 Jens Krüger – Computer Graphics and Visualization.
Geometry Primer Lines and rays Planes Spheres Frustums Triangles Polygon Polyhedron.
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.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
CSE 381 – Advanced Game Programming Scene Management
Visibility Culling. Back face culling View-frustrum culling Detail culling Occlusion culling.
Korea Univ. Graphics Lab. 3D Game Engine Design Chapter 12. Spatial Sorting Chung Ji Hye
Week 14 - Monday.  What did we talk about last time?  Bounding volume/bounding volume intersections.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures -Why.
A lion in the desert How do you find a lion in the desert? How about when you have a predicate that tells you if the lion is in front or behind a separating.
Advanced Data Structures for Games and Graphics Lecture 4
Introduction General Data Structures - Arrays, Linked Lists - Stacks & Queues - Hash Tables & Binary Search Trees - Graphs Spatial Data Structures -Why.
1 Clipping and Hidden Surfaces CS-184: Computer Graphics Prof. James O’Brien.
CS6500 Adv. Computer Graphics © Chun-Fa Chang, Spring 2003 Space Partitions.
A lion in the desert How do you find a lion in the desert? How about when you have a predicate that tells you if the lion is in front or behind a separating.
Bounding Volume Hierarchies and Spatial Partitioning Kenneth E. Hoff III COMP-236 lecture Spring 2000.
1 Advanced Scene Management System. 2 A tree-based or graph-based representation is good for 3D data management A tree-based or graph-based representation.
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
Computer Graphics 2 Lecture x: Acceleration Techniques for Ray-Tracing Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
10/29/02 (c) 2002 University of Wisconsin, CS559 Today Hidden Surface Removal Exact Visibility.
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Spatial Partitioning, Visibility and Culling Spring.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
The Visibility Problem In many environments, most of the primitives (triangles) are not visible most of the time –Architectural walkthroughs, Urban environments.
The BSP-tree from Prof. Seth MIT.. Motivation for BSP Trees: The Visibility Problem We have a set of objects (either 2d or 3d) in space. We have.
Visible-Surface Detection Jehee Lee Seoul National University.
1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”
CS-378: Game Technology Lecture #10: Spatial Data Structures Prof. Okan Arikan University of Texas, Austin Thanks to James O’Brien, Steve Chenney, Zoran.
12/4/2001CS 638, Fall 2001 Today Managing large numbers of objects Some special cases.
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
Using BSP for CD Ref: BSP in deBerg et al ’ s book (url)url.
03/14/02 (c) 2002 University of Wisconsin, CS559 Last Time Some more visibility (Hidden Surface Removal) algorithms –A-buffer –Scanline –Depth sorting.
3/23/04© University of Wisconsin, CS559 Spring 2004 Last Time Antialiasing –Area-weighted sampling Visibility –Painters algorithm –Depth buffer (Z-buffer)
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.
Implementation II.
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Ray Tracing II. HW1 Part A due October 10 Camera module Object module –Read from a file –Sphere and Light only Ray tracer module: –No shading. No reflection.
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.
Maths & Technologies for Games Spatial Partitioning 2
Computer Graphics I, Fall 2010 Implementation II.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
BSP Tree Supplement Jyun-Ming Chen. Fall Kd-Tree and BSP tree kd-tree is a special kind of bsp tree.
Ray Tracing Optimizations
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
Ray Tracing Acceleration (3)
Hierarchical Data Structure in Game Programming Yanci Zhang Game Programming Practice.

Computer Graphics Implementation II
Bounding Volume Hierarchies and Spatial Partitioning
Collision Detection Spring 2004.
Bounding Volume Hierarchies and Spatial Partitioning
© University of Wisconsin, CS559 Fall 2004
Modeliranje kompleksnih modelov
CS679 - Fall Copyright Univ. of Wisconsin
BVH Student: Jack Chang.
Modeliranje kompleksnih modelov
Presentation transcript:

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Octrees

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Today Kd-trees BSP trees BVHs Cell Structures (Graph-Based)

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Octree Problems Octrees become very unbalanced if the objects are far from a uniform distribution –Many nodes could contain no objects The problem is the requirement that cube always be equally split amongst children A bad octree case

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Kd-trees A kd-tree is a tree with the following properties –Each node represents a rectilinear region (faces aligned with axes) –Each node is associated with an axis aligned plane that cuts its region into two, and it has a child for each sub-region –The directions of the cutting planes alternate with depth – height 0 cuts on x, height 1 cuts on y, height 2 cuts on z, height 3 cuts on x, … Kd-trees generalize octrees by allowing splitting planes at variable positions –Note that cut planes in different sub-trees at the same level need not be the same

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Kd-tree Example

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Kd-tree Node Data Structure What needs to be stored in a node? –Children pointers (always two) –Parent pointer - useful for moving about the tree –Extents of cell - x max, x min, y max, y min, z max, z min –List of pointers to the contents of the cell –Neighbors are complicated in kd-trees, so typically not stored

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Building a Kd-tree Define a function, buildNode, that: –Takes a node with its cell defined and a list of its contents –Sets the splitting plane, creates the children nodes, divides the objects among the children, and recurses on the children, or –Sets the node to be a leaf node Find the root cell (how?), create the root node and call buildNode with all the objects When do we choose to stop creating children? What is the hard part?

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Choosing a Splitting Plane Two common goals in selecting a splitting plane for each cell –Minimize the number of objects cut by the plane –Balance the tree: Use the plane that equally divides the objects into two sets (the median cut plane) –One possible global goal is to minimize the number of objects cut throughout the entire tree (intractable) One method (assuming splitting on plane perpendicular to x-axis): –Sort all the vertices of all the objects to be stored according to x –Put plane through median vertex, or locally search for low cut plane

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Kd-tree Applications Kd-trees work well when axis aligned planes cut things into meaningful cells –What are some common environments with rectilinear cells? View frustum culling extents trivially to kd-trees Kd-trees are frequently used as data structures for other algorithms – particularly in visibility Specific applications: –Soda Hall Walkthrough project (Teller and Sequin) Splitting planes came from large walls and floors –Real-time Pedestrian Rendering (University College London)

10/02/03CS679 - Fall Copyright Univ. of Wisconsin BSP Trees Binary Space Partition trees –A sequence of cuts that divide a region of space into two Cutting planes can be of any orientation –A generalization of kd-trees, and sometimes a kd-tree is called an axis-aligned BSP tree Divides space into convex cells The industry standard for spatial subdivision in game environments –General enough to handle most common environments –Easy enough to manage and understand –Big performance gains

10/02/03CS679 - Fall Copyright Univ. of Wisconsin BSP Example Notes: –Splitting planes end when they intersect their parent node’s planes –Internal node labeled with planes, leaf nodes with regions BAout8 D 6 C A B C D

10/02/03CS679 - Fall Copyright Univ. of Wisconsin BSP Tree Node Data Structure What needs to be stored in a node? –Children pointers (always two) –Parent pointer - useful for moving about the tree –If a leaf node: Extents of cell How might we store it? –If an internal node: The split plane –List of pointers to the contents of the cell –Neighbors are useful in many algorithms Typically only store neighbors at leaf nodes Cells can have many neighboring cells –Portals are also useful - holes that see into neighbors

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Building a BSP Tree Define a function, buildNode, that: –Takes a node with its cell defined and a list of its contents –Sets the splitting plane, creates the children nodes, divides the objects among the children, and recurses on the children, or –Sets the node to be a leaf node Create the root node and call buildNode with all the objects –Do we need the root node’s cell? What do we set it to? When do we choose to stop creating children? What is the hard part?

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Choosing Splitting Planes Goals: –Trees with few cells –Planes that are mostly opaque (best for visibility calculations) –Objects not split across cells Some heuristics: –Choose planes that are also polygon planes –Choose large polygons first –Choose planes that don’t split many polygons –Try to choose planes that evenly divide the data –Let the user select or otherwise guide the splitting process –Random choice of splitting planes doesn’t do too badly

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Drawing Order from BSP Trees BSP tress can be used to order polygons from back to front, or visa-versa –Descend tree with viewpoint –Things on the same side of a splitting plane as the viewpoint are always in front of things on the far side Can draw from back to front –Removes need for z-buffer, but few people care any more –Gives the correct order for rendering transparent objects with a z- buffer, and by far the best way to do it Can draw front to back –Use info from front polygons to avoid drawing back ones –Useful in software renderers (Doom?)

10/02/03CS679 - Fall Copyright Univ. of Wisconsin BSP in Current Games Use a BSP tree to partition space as you would with an octree or kd-tree –Leaf nodes are cells with lists of objects –Cells typically roughly correspond to “rooms”, but don’t have to The polygons to use in the partitioning are defined by the level designer as they build the space –A brush is a region of space that contributes planes to the BSP –Artists lay out brushes, then populate them with objects –Additional planes may also be specified Sky planes for outdoor scenes, that dip down to touch the tops of trees and block off visibility Planes specifically defined to block sight-lines, but not themselves visible

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Dynamic Lights and BSPs Dynamic lights usually have a limited radius of influence to reduce the number of objects they light The problem is to find, using the BSP tree, the set of objects lit by the light (intersecting a sphere center (x,y,z) radius r) Solution: Find the distance of the center of the sphere from each split plane –What do we do if it’s greater than r distance on the positive side of the plane? –What do we do if it’s greater than r distance on the negative side of the plane? –What do we do if it’s within distance r of the plane? –Any leaf nodes reached contain objects that might be lit

10/02/03CS679 - Fall Copyright Univ. of Wisconsin BSP and Frustum Culling You have a BSP tree, and a view frustum –With near and far clip planes At each splitting plane: –Test the boundaries of the frustum against the split plane –What if the entire frustum is on one side of the split plane? –What if the frustum intersects the split plane? What do you test in situations with no far plane? What do you do when you get to a leaf?

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Bounding Volume Hierarchies So far, we have had subdivisions that break the world into cell General Bounding Volume Hierarchies (BVHs) start with a bounding volume for each object –Many possibilities: Spheres, AABBs, OBBs, k-dops, … –More on these later Parents have a bound that bounds their children’s bounds –Typically, parent’s bound is of the same type as the children’s –Can use fixed or variable number of children per node No notion of cells in this structure

10/02/03CS679 - Fall Copyright Univ. of Wisconsin BVH Example

10/02/03CS679 - Fall Copyright Univ. of Wisconsin BVH Construction Simplest to build top-down –Bound everything –Choose a split plane (or more), divide objects into sets –Recurse on child sets Can also be built incrementally –Insert one bound at a time, growing as required –Good for environments where things are created dynamically Can also build bottom up –Bound individual objects, group them into sets, create parent, recurse –What’s the hardest part about this?

10/02/03CS679 - Fall Copyright Univ. of Wisconsin BVH Operations Some of the operations we’ve looked at so far work with BVHs –Frustum culling –Collision detection BVHs are good for moving objects –Updating the tree is easier than for other methods –Incremental construction also helps (don’t need to rebuild the whole tree if something changes) But, BVHs lack some convenient properties –For example, not all space is filled, so algorithms that “walk” through cells won’t work

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Cell-Portal Structures Cell-Portal data structures dispense with the hierarchy and just store neighbor information –This make them graphs, not trees Cells are described by bounding polygons Portals are polygonal openings between cells Good for visibility culling algorithms, OK for collision detection and ray-casting Several ways to construct –By hand, as part of an authoring process –Automatically, starting with a BSP tree or kd-tree and extracting cells and portals –Explicitly, as part of an automated modeling process

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Cell Portal Example Portals can be one way (directed edges) Graph is normally stored in adjacency list format –Each cell stores the edges (portals) out of it AB CD EF AB CD EF

10/02/03CS679 - Fall Copyright Univ. of Wisconsin Todo By Monday, Oct 13, Stage 2 demo