Tomas Mőller © 2000 Speed-up Techniques for Real-Time Rendering or “What makes your real-time video game fly” Tomas Möller Chalmers University of Technology,

Slides:



Advertisements
Similar presentations
Christian Lauterbach COMP 770, 2/16/2009. Overview  Acceleration structures  Spatial hierarchies  Object hierarchies  Interactive Ray Tracing techniques.
Advertisements

Optimized Stencil Shadow Volumes
Intersection Testing Chapter 13 Tomas Akenine-Möller Department of Computer Engineering Chalmers University of Technology.
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.
Week 10 - Monday.  What did we talk about last time?  Global illumination  Shadows  Projection shadows  Soft shadows.
Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research.
Occlusion Culling Fall 2003 Ref: GamasutraGamasutra.
CAP4730: Computational Structures in Computer Graphics Visible Surface Determination.
Visibility in Computer Graphics Toni Sellarès Unversitat de Girona
CSE 381 – Advanced Game Programming Scene Management
HLODs: Hierarchical Levels of Detail Hierarchical Simplifications for Faster Display of Massive Geometric Environments Carl Erikson, Dinesh Manochahttp://
Visibility Culling. Back face culling View-frustrum culling Detail culling Occlusion culling.
Rasterization and Ray Tracing in Real-Time Applications (Games) Andrew Graff.
Chapter 6: Vertices to Fragments Part 2 E. Angel and D. Shreiner: Interactive Computer Graphics 6E © Addison-Wesley Mohan Sridharan Based on Slides.
1 Dr. Scott Schaefer Hidden Surfaces. 2/62 Hidden Surfaces.
CGDD 4003 THE MASSIVE FIELD OF COMPUTER GRAPHICS.
Tomas Mőller © 2000 Speeding up your game The scene graph Culling techniques Level-of-detail rendering (LODs) Collision detection Resources and pointers.
Bounding Volume Hierarchies and Spatial Partitioning Kenneth E. Hoff III COMP-236 lecture Spring 2000.
Vertices and Fragments III Mohan Sridharan Based on slides created by Edward Angel 1 CS4395: Computer Graphics.
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
1 Occlusion Culling ©Yiorgos Chrysanthou, , Anthony Steed, 2004.
Shadows Computer Graphics. Shadows Shadows Extended light sources produce penumbras In real-time, we only use point light sources –Extended light sources.
Computer Graphics 2 Lecture x: Acceleration Techniques for Ray-Tracing Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
1 Perception, Illusion and VR HNRS 299, Spring 2008 Lecture 19 Other Graphics Considerations Review.
Spatial Data Structures Jason Goffeney, 4/26/2006 from Real Time Rendering.
Managing Your Objects Paul Taylor 2009 Assignment Due Fri 5/6/2009.
Open Scene Graph Visualization II MSIM 842, CS 795/895
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.
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”
Week 2 - Friday.  What did we talk about last time?  Graphics rendering pipeline  Geometry Stage.
Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
Real-Time Rendering SPEEDING UP RENDERING Lecture 04 Marina Gavrilova.
1 Advanced Scene Management. 2 This is a game-type-oriented issue Bounding Volume Hierarchies (BVHs) Binary space partition trees (BSP Trees) “Quake”
PRESENTED BY – GAURANGI TILAK SHASHANK AGARWAL Collision Detection.
Collaborative Visual Computing Lab Department of Computer Science University of Cape Town Graphics Topics in VR By Shaun Nirenstein.
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.
CIS 350 – I Game Programming Instructor: Rolf Lakaemper.
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.
Binary Space Partitioning Trees Ray Casting Depth Buffering
Implementation II.
1 Visiblity: Culling and Clipping Computer Graphics COMP 770 (236) Spring 2009 January 21 & 26: 2009.
David Luebke11/26/2015 CS 551 / 645: Introductory Computer Graphics David Luebke
CSCE 552 Spring D Models By Jijun Tang. Triangles Fundamental primitive of pipelines  Everything else constructed from them  (except lines and.
Ray Tracing Fall, Introduction Simple idea  Forward Mapping  Natural phenomenon infinite number of rays from light source to object to viewer.
Computer Graphics I, Fall 2010 Implementation II.
1 CSCE 441: Computer Graphics Hidden Surface Removal Jinxiang Chai.
Computer Graphics Inf4/MSc 1 Computer Graphics Lecture 5 Hidden Surface Removal and Rasterization Taku Komura.
David Luebke 3/5/2016 Advanced Computer Graphics Lecture 4: Faster Ray Tracing David Luebke
David Luebke3/12/2016 Advanced Computer Graphics Lecture 3: More 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”
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
- Introduction - Graphics Pipeline
Scene Manager Creates and places movable objects like lights and cameras so as to access them efficiently, e.g. for rendering. Loads and assembles world.
Computer Graphics Implementation II
Bounding Volume Hierarchies and Spatial Partitioning
Week 2 - Friday CS361.
Bounding Volume Hierarchies and Spatial Partitioning
Parts of these slides are based on
CSCE 441: Computer Graphics Hidden Surface Removal
Implementation II Ed Angel Professor Emeritus of Computer Science
Introduction to Computer Graphics with WebGL
Collision Detection.
Implementation II Ed Angel Professor Emeritus of Computer Science
Presentation transcript:

Tomas Mőller © 2000 Speed-up Techniques for Real-Time Rendering or “What makes your real-time video game fly” Tomas Möller Chalmers University of Technology, Sweden

Tomas Mőller © 2000 Motivation Graphics hardware 2x faster in 6 months! Wait… then it will be fast enough! NOT! We will never be satisfied – Screen resolution: 2000x1000 – Realism: global illumination – Geometrical complexity: no upper limit!

Tomas Mőller © 2000 Keep this in mind during lecture… Rendering pipeline: 3 stages – Application (CPU but also bandwidth from CPU to graphics hardware) – Geometry (transform, lighting) – Rasterizer (fill, texture, per pixel ops) To get faster overall performance: – Reduce time spent in bottleneck stage!

Tomas Mőller © 2000 Overview of lecture The scene graph Culling techniques Level-of-detail rendering (LODs) Combination of techniques Collision detection Resources and pointers

Tomas Mőller © 2000 The Scene Graph DAG – directed acyclic graph – Simply an n-ary tree without loops Uses: collision detection and faster rendering internal node=

Tomas Mőller © 2000 Contents of Scene Graph Leaves contains geometry Each node holds a – Bounding Volume (BV) – pointers to children – possibly a transform Examples of BVs: spheres, boxes The BV in a node contains all geometry in its subtree

Tomas Mőller © 2000 Scene graph example circles=BVs scene graph root

Tomas Mőller © 2000 Transforms in the Scene Graph Put a transform in each internal node Gives instancing, and hierarchical animation Move right, Rotate 45° Move up

Tomas Mőller © 2000 Example: a running leg AB C No hierarchy: one transform 21 3 Hierarchy:3 transforms LegXform KneeFootHipXform

Tomas Mőller © 2000 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” is the entire scene, and the selection is a subset of the scene that we do not consider to contribute

Tomas Mőller © 2000 Culling: Overview Backface culling Hierarchical view-frustum culling Portal culling Detail culling Occlusion culling

Tomas Mőller © 2000 Culling examples view frustumdetail backface portal occlusion

Tomas Mőller © 2000 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)

Tomas Mőller © 2000 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 back facing

Tomas Mőller © 2000 How to cull backfaces screen space front back front back eye eye space

Tomas Mőller © 2000 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) Avoid further processing of such BV’s and their containing geometry

Tomas Mőller © 2000 Can we accelerate VF culling further? Do what we always do in graphics… Use a hierarchical approach, e.g, the scene graph Which stages benefits? – Geometry and Rasterizer – Bus between CPU and Geometry

Tomas Mőller © 2000 Example of Hierarchical View Frustum Culling root camera

Tomas Mőller © 2000 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

Tomas Mőller © 2000 Portal culling example In a building from above Circles are objects to be rendered

Tomas Mőller © 2000 Portal Culling Algorithm 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 VF cull w.r.t. AABB – Traverse to closest cells (through portals) – Intersection of AABB & AABB of traversed portal – Goto *

Tomas Mőller © 2000 Portal overestimation To simplify: actual portaloverestimated portal

Tomas Mőller © 2000 Portal Culling Algorithm 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 Which stages benefits? – Geometry, Rasterizer, and Bus Source (for Performer):

Tomas Mőller © 2000 Detail Culling Idea: objects whose projected BV occupy less than N pixels are culled This is an approximative algorithm as the things you cull away may actually contribute to the final image Advantage: trade-off quality/speed Which stages benefits? – Geometry, Rasterizer, and Bus

Tomas Mőller © 2000 Example of Detail Culling detail culling OFF Not much difference, but % faster Good when moving detail culling ON Images courtesy of ABB Robotics Products, created by Ulf Assarsson

Tomas Mőller © 2000 Projection Projection gets halved when distance is doubled eye

Tomas Mőller © 2000 Projection (cont’d) dot( d, ( c - v )) is distance along d p=nr/ dot( d, ( c - v )) is estimation of projected radius  p 2 is the area (eye) v (near plane) n d (normalized view direction) r c

Tomas Mőller © 2000 Occlusion Culling Main idea: Objects that lies completely “behind” another set of objects can be culled Hard problem to solve efficiently

Tomas Mőller © 2000 Example final image Note that “Portal Culling” is an algorithm for occlusion culling

Tomas Mőller © 2000 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;

Tomas Mőller © 2000 Occlusion culling algorithm example Process from front to back Maintain an occlusion horizon (yellow)

Tomas Mőller © 2000 Occlusion culling algorithm example To process tetrahedron (which is behind grey objects): – find axis-aligned box of projection – compare against occlusion horizon culled

Tomas Mőller © 2000 Occlusion culling algorithm example When an object is considered visible: Add its “occluding power” to the occlusion representation

Tomas Mőller © 2000 Level-of-Detail Rendering Use different levels of detail at different distances from the viewer More triangles closer to the viewer

Tomas Mőller © 2000 LOD rendering Not much visual difference, but a lot faster Use area of projection of BV to select appropriate LOD

Tomas Mőller © 2000 Scene graph with LODs Car chair

Tomas Mőller © 2000 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 (detail culling)! Which stages benefits? – Geometry, Rasterizer, and Bus

Tomas Mőller © 2000 Combinations of Techniques Not trivial to combine! VF Cull + LOD == minimal if serious about performance Indoors: LOD + portal culling Outdoors (cities, suburbia): VF Cull + LOD + occlusion culling

Tomas Mőller © 2000 Real-Time Rendering? In computer graphics, “real-time” is used in a soft way: say >30 fps for most frames In other contexts, it’s a tougher requirement: the framerate must never be <30 fps, i.e., constant framerate What can we do? – Reactive LOD algorithm – Reactive detail culling – Reactive visual quality

Tomas Mőller © 2000 Collision Detection To get interesting and more realistic interaction between geometric objects in an application Cannot test each triangle against each other: O(n*m) Alas, need smarter approaches Use BVs because these are cheap to test Use a scene graph (hiearchy) – For efficiency use only one triangle per leaf

Tomas Mőller © 2000 How to collide two scene graphs? Three cases: Reach two internal nodes’ BVs – If not overlap, then exit – If overlap, then descend into the children of the internal node with largest volume Reach an internal node and a triangle – Descend into the internal node If you reach two triangles – Test for overlap Start recursion with the two roots of the scene graphs

Tomas Mőller © 2000 Bounding Volumes in Collision Detection Wanted: tight fitting BV, and fast to test for overlap Common choices are – Spheres – Axis aligned box – Oriented box

Tomas Mőller © 2000 Triangle-triangle overlap test Compute the line of intersection between the two planes Compute the intersection interval between this line and triangles – gives two intervals If intervals overlap then triangles overlap!

Tomas Mőller © 2000 Simpler collision detection Only shoot rays to find collisions, i.e., approximate an object with a set of rays Cheaper, but less accurate Can use the scene graph again or a BSP tree

Tomas Mőller © 2000 Can you compute the time of a collision? Move ball, test for hit, move ball, test for hit… can get “quantum effects”! In some cases it’s possible to find closed- form expression: t=s/v v s

Tomas Mőller © 2000 Collision detection resources Check out RAPID: uses OBBs SOLID: handles deformable objects Eberly: code for dynamic CD – where no quantum effects can occur – Each object has a velocity direction

Tomas Mőller © 2000 Resources and Pointers Journal of Graphics Tools – – source for projected screen area of box – intersection test routines – occlusion culling