Maths & Technologies for Games Spatial Partitioning 1 CO3303 Week 8-9.

Slides:



Advertisements
Similar presentations
Computer Graphics - Rasterization -
Advertisements

CS 352: Computer Graphics Chapter 7: The Rendering Pipeline.
Advanced Light and Shadow Culling Methods Eric Lengyel.
Optimized Stencil Shadow Volumes
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
10/10/02 (c) 2002 University of Wisconsin, CS 559 Last Time Finished viewing: Now you know how to: –Define a region of space that you wish to view – the.
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.
Occlusion Culling Fall 2003 Ref: GamasutraGamasutra.
CHAPTER 12 Height Maps, Hidden Surface Removal, Clipping and Level of Detail Algorithms © 2008 Cengage Learning EMEA.
CSE 381 – Advanced Game Programming Scene Management
Visibility Culling. Back face culling View-frustrum culling Detail culling Occlusion culling.
Computer Graphics Viewing.
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.
Vertices and Fragments I CS4395: Computer Graphics 1 Mohan Sridharan Based on slides created by Edward Angel.
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.
Fall 2006 revised1 Frustum Culling in OpenGL Ref: MarkMoley.com.
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.
Hidden Surface Removal
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Games Development 2 Entity / Architecture Review CO3301 Week
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
10/09/2001CS 638, Fall 2001 Today Spatial Data Structures –Why care? –Octrees/Quadtrees –Kd-trees.
COMPUTER AIDED DESIGN -(CAD)-3
Computer Graphics Texture Mapping
The Visibility Problem In many environments, most of the primitives (triangles) are not visible most of the time –Architectural walkthroughs, Urban environments.
10/16/2001CS 638, Fall 2001 Today Visibility –Overview –Cell-to-Cell –Cell-to-Region –Eye-To-Region –Occlusion Culling (maybe)
CSE 381 – Advanced Game Programming Quickhull and GJK.
Culling Techniques “To cull” means “to select from group” In graphics context: do not process data that will not contribute to the final image The “group”
Real-Time Rendering SPEEDING UP RENDERING Lecture 04 Marina Gavrilova.
Emerging Technologies for Games Alpha Sorting and “Soft” Particles CO3303 Week 15.
1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”
Motion Planning in Games Mark Overmars Utrecht University.
2 COEN Computer Graphics I Evening’s Goals n Discuss application bottleneck determination n Discuss various optimizations for making programs execute.
Real-time Graphics for VR Chapter 23. What is it about? In this part of the course we will look at how to render images given the constrains of VR: –we.
CO1301: Games Concepts Dr Nick Mitchell (Room CM 226) Material originally prepared by Gareth Bellaby.
Games Development 1 Camera Projection / Picking CO3301 Week 8.
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.
Implementation II.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
Advanced Computer Graphics Shadow Techniques CO2409 Computer Graphics Week 20.
10/07/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Spatial data structures.
Computer Graphics Rendering 2D Geometry CO2409 Computer Graphics Week 2.
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Emerging Technologies for Games Deferred Rendering CO3303 Week 22.
Basic Perspective Projection Watt Section 5.2, some typos Define a focal distance, d, and shift the origin to be at that distance (note d is negative)
Coherent Hierarchical Culling: Hardware Occlusion Queries Made Useful Jiri Bittner 1, Michael Wimmer 1, Harald Piringer 2, Werner Purgathofer 1 1 Vienna.
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
Maths & Technologies for Games Graphics Optimisation - Batching CO3303 Week 5.
Computer Graphics I, Fall 2010 Implementation II.
Honours Graphics 2008 Session 5. Today’s focus Rasterization Visibility determination Coarse / fine visibility determination.
1Computer Graphics Implementation 1 Lecture 15 John Shearer Culture Lab – space 2
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.
Lecture 9 From Vertices to Fragments. Objectives Introduce basic implementation strategies Clipping Rasterization hidden-surface removal.
Computer Graphics Implementation II
Bounding Volume Hierarchies and Spatial Partitioning
Bounding Volume Hierarchies and Spatial Partitioning
Concepts, algorithms for clipping
CSCE 441: Computer Graphics Hidden Surface Removal
Implementation II Ed Angel Professor Emeritus of Computer Science
CS679 - Fall Copyright Univ. of Wisconsin
Introduction to Computer Graphics with WebGL
Implementation II Ed Angel Professor Emeritus of Computer Science
Games Development 2 Entity / Architecture Review
Presentation transcript:

Maths & Technologies for Games Spatial Partitioning 1 CO3303 Week 8-9

Contents 1.Introduction / Rationale 2.Uses for Spatial Partitioning 3.Potentially Visible Sets (PVS) 4.Portal Systems

Introduction Spatial Partitioning is any scheme that divides the game world into smaller spaces We have previously considered the game world as a single huge area The game world has had a single global list of entity instances All instances rendered / processed every frame OK for small scale projects Not efficient enough for many commercial games

Problems with Large Games A complex game world can contain millions of instances The majority are likely to be far from the player –Probably not visible as well Consider rendering all instances: –Viewport clipping removes off-screen instances –Z buffer removes those hidden behind other things –But all instances must still be processed Would like to cull these instances instead –Identify that they are not visible quickly –Remove them from processing earlier

Simple Culling Methods Can cull entity instances against the viewing frustum –The volume of space visible from camera –The shape is a trapezium Check each instance against each of the six planes defining the frustum –Reject any instance that lies entirely on the outside of any one plane Or more simply: just reject those behind the camera near clip plane Use bounding volumes and simple maths –Boxes, AABB or spheres This approach sufficient for simple cases Large game - still processing millions of instances per-frame

Rationale for Spatial Partitioning Culling instances one-by-one is not the best approach for very complex environments –Too many instances to even consider in one frame Need to reformulate the problem: –Not “For each instance: Is this instance visible? Render, update…” –But “Select the visible instances. For each one…” Don’t process non-visible instances at all –Easier said than done… What if we consider partitions (chunks) of space? –With everything inside –Identify instead which partitions are (in)visible –Allowing use to accept / reject large groups of instances at once

Simple Example Most space partitioning schemes use some form of graph to subdivide the world –Each node represents a space –Shape of the spaces vary by scheme –The edges represent how the spaces are related / connected This example shows a very basic partition / graph demonstrating: –How areas in the scene are connected –How a group of instances can be rejected by one check

Level Division Space partitions are not just for visibility checks The can help in a variety of non-rendering situations Partitioning a game into levels should be familiar: –Or these could be sections of a single level Traversal from section to section might imply: –Loading / releasing resources –New PP effects, lighting etc. –Changing music etc.

Game Logic Space partitions can also help with game logic needs: Race track split into sectors Only current / neighbouring sectors used for opponent AI & physics (+ rendering) Simpler logic elsewhere Could apply to any game, but here sectors also simplify lap processing: –Distance covered –Wrong way detection –Telemetrics gathering, etc

Visibility / Audibility We will mainly consider partitions for determining visibility Could also use them to help calculate audibility: Many other uses for space partitions –Be imaginative May use multiple partitions schemes simultaneously for different purposes –Visibility, physics, logic, etc.

Potentially Visible Sets (PVS) Regardless of partitioning scheme, each node in a space partition has a potentially visible set (PVS): –The nodes that can, in some way, be seen from that node –Independent of camera position within the node The PVS is can be pre-calculated and stored with each node –Indicates which other nodes to render when in that node –All other nodes rejected without calculation

Generating PVS A PVS scheme is conceptually simple –Trivial run-time implementation However, generating the PVS for each node is non-trivial –A PVS is not just the nodes visible from one camera position –But the nodes visible from any camera position Possible approaches: –Brute force: consider many different camera positions – slow, possible errors –Manually create PVS: only possible for simpler graphs – error prone (see this in lab) –Mathematical / geometric approaches – complex and often have limitations

PVS Limitations A PVS does not consider dynamic geometry –E.g. if a level contains a door that opens, then the door must be considered open for PVS –Losing some possibilities for node rejection –Possible to extend implementation to cover such cases Potentially visible sets must be conservative –Consider a node visible from only a tiny portion of the current node –It must be considered visible in the entire of the current node So whilst efficient to execute, PVS systems are not ideally effective in node rejection

PVS Use A PVS system is not a space partitioning scheme as such –Rather a scheme for storing additional data in an existing graph Potentially visible sets can be added to any space partition graph, regardless of scheme used –E.g. manually created graphs, portal systems or any of the other partitioning schemes described later Used as a quick way to reduce number of nodes under consideration –Before using more complex techniques –Satisfies the paradigm from earlier – reject nodes (and hence many entity instances) without any run-time calculation

Portal Systems A portal system is a method that concentrates on the graph edges –The connections between spaces –The nodes (spaces) in the partition can be arbitrarily shaped Spaces in such a system are connected through portals –A portal is typically a natural opening such as a door or window –In general a convex planar polygon Portals allow us to reject other nodes based on the camera view –A natural adjunct for a PVS system

Basic Portal Usage First identify which node the camera is in –Render that node’s instances –Some instances are in multiple nodes, e.g. a door-frame –An issue in other schemes too Then identify whether each of the node’s portals are visible in the viewport –Use 2D work / frustum culling Now we know the nodes connected through the visible portals are also visible –Repeat process on those nodes

Refinements When visible portal is found store its viewport dimensions –A 2D rectangle Clip portals in the connected node against this smaller area –Only check for further portals visible through the clipped area –Rejects obscured nodes –All relatively simple 2D processing Must watch out for multiple portals leading to same node –Don’t want to render nodes twice –Combine into a single area or store “isRendered” state for each node

Portal Benefits Portals are fairly cheap and simple to implement Extremely effective for indoor geometry where there are many natural portals Portals can handle dynamic geometry: –Portals can move or change size –Portals can be “opened” and “closed” by simply enabling or disabling them Can make physically impossible portals, joining unexpected locations (e.g. the game “Portal”) –Each portal has two 2 sides that don’t need to be in the same place –Alter camera position when rendering through a portal –Change entity position when passing through a portal

Portal Drawbacks Given arbitrarily shaped nodes, it can be tricky to know which node a particular point is in In particular, we need to know which node the camera is in to start the algorithm –Can keep track of camera as it moves between nodes –What if the camera travels through a wall or teleports? Portals are of little use for open areas –No obvious portals – everything tends to be “visible” Not at all easy to automatically generate portals from arbitrary geometry –So portals are generally created manually or created from specific assets (doors) or tools (level editor)