Speedup Techniques for RealTime Rendering or What makes
- Slides: 47
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 2 x faster in 6 months! l Wait… then it will be fast enough! l NOT! l We will never be satisfied l – – – Screen resolution: 2000 x 1000 Realism: global illumination Geometrical complexity: no upper limit! Tomas Mőller © 2000
Keep this in mind during lecture… l Rendering pipeline: 3 stages – – – l 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 l The scene graph l Culling techniques l Level-of-detail rendering (LODs) l Combination of techniques l Collision detection l Resources and pointers Tomas Mőller © 2000
The Scene Graph l DAG – directed acyclic graph – l 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 l Each node holds a l – – – Bounding Volume (BV) pointers to children possibly a transform Examples of BVs: spheres, boxes l The BV in a node contains all geometry in its subtree l Tomas Mőller © 2000
Scene graph example scene graph circles=BVs root Tomas Mőller © 2000
Transforms in the Scene Graph l l Put a transform in each internal node Gives instancing, and hierarchical animation Move up Move right, Rotate 45° Tomas Mőller © 2000
Example: a running leg No hierarchy: A one transform C B Xform Leg Hierarchy: 3 transforms 1 Xform 2 3 Hip Xform Knee Xform Foot Tomas Mőller © 2000
Culling Techniques “To cull” means “to select from group” l In graphics context: do not process data that will not contribute to the final image l The “group” is the entire scene, and the selection is a subset of the scene that we do not consider to contribute l Tomas Mőller © 2000
Culling: Overview Backface culling l Hierarchical view-frustum culling l Portal culling l Detail culling l Occlusion culling l Tomas Mőller © 2000
Culling examples view frustum detail backface l a t r o p occlusion Tomas Mőller © 2000
Backface Culling Simple technique to discard polygons that faces away from the viewer l Can be used for: l – – 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) l Which stages benefits? Rasterizer, but also Geometry (where test is done) l Tomas Mőller © 2000
Backface culling (cont’d) Often implemented for you in the API l Open. GL: gl. Cull. Face(GL_BACK); l How to determine what faces away? l First, must have consistently oriented polygons, e. g. , counterclockwise l 2 0 2 1 front facing 1 0 back facing Tomas Mőller © 2000
How to cull backfaces 1 2 2 back eye 1 0 front back screen space front 0 eye space Tomas Mőller © 2000
View-Frustum Culling Bound every “natural” group of primitives by a simple volume (e. g. , sphere, box) l If a bounding volume (BV) is outside the view frustum, then the entire contents of that BV is also outside (not visible) l Avoid further processing of such BV’s and their containing geometry l Tomas Mőller © 2000
Can we accelerate VF culling further? Do what we always do in graphics… l Use a hierarchical approach, e. g, the scene graph l Which stages benefits? l – – 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 l l Average: culled 20 -50% of the polys in view Speedup: from slightly better to 10 times Tomas Mőller © 2000
Portal culling example l l 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) l For each frame: l – – – Locate cell of viewer and init 2 D 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 l To simplify: actual portal overestimated portal Tomas Mőller © 2000
Portal Culling Algorithm l 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 l Which stages benefits? l – l Geometry, Rasterizer, and Bus Source (for Performer): http: //www. cs. virginia. edu/~luebke/ Tomas Mőller © 2000
Detail Culling Idea: objects whose projected BV occupy less than N pixels are culled l This is an approximative algorithm as the things you cull away may actually contribute to the final image l Advantage: trade-off quality/speed l Which stages benefits? l – Geometry, Rasterizer, and Bus Tomas Mőller © 2000
Example of Detail Culling Images courtesy of ABB Robotics Products, created by Ulf Assarsson detail culling OFF detail culling ON Not much difference, but 80 -400% faster l Good when moving l Tomas Mőller © 2000
Projection eye l Projection gets halved when distance is doubled Tomas Mőller © 2000
Projection (cont’d) (eye) v d (normalized view direction) r (near plane) n l l l c dot(d, (c-v)) is distance along d p=nr/dot(d, (c-v)) is estimation of projected radius pp 2 is the area Tomas Mőller © 2000
Occlusion Culling Main idea: Objects that lies completely “behind” another set of objects can be culled l Hard problem to solve efficiently l Tomas Mőller © 2000
Example final image l Note that “Portal Culling” is an algorithm for occlusion culling Tomas Mőller © 2000
Occlusion culling algorithm Use some kind of occlusion representation OR for each object g do: if( not Occluded(OR , g)) render(g); update(OR , g); end; Tomas Mőller © 2000
Occlusion culling algorithm example l l Process from front to back Maintain an occlusion horizon (yellow) Tomas Mőller © 2000
Occlusion culling algorithm example l 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: l Add its “occluding power” to the occlusion representation l Tomas Mőller © 2000
Level-of-Detail Rendering l l Use different levels of detail at different distances from the viewer More triangles closer to the viewer Tomas Mőller © 2000
LOD rendering l Not much visual difference, but a lot faster l 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 l When the object is really far away, do not render it (detail culling)! l Which stages benefits? l – Geometry, Rasterizer, and Bus Tomas Mőller © 2000
Combinations of Techniques Not trivial to combine! l VF Cull + LOD == minimal if serious about performance l Indoors: LOD + portal culling l Outdoors (cities, suburbia): VF Cull + LOD + occlusion culling l Tomas Mőller © 2000
Real-Time Rendering? In computer graphics, “real-time” is used in a soft way: say >30 fps for most frames l In other contexts, it’s a tougher requirement: the framerate must never be <30 fps, i. e. , constant framerate l What can we do? l – – – 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 l Cannot test each triangle against each other: O(n*m) l Alas, need smarter approaches l Use BVs because these are cheap to test l Use a scene graph (hiearchy) l – For efficiency use only one triangle per leaf Tomas Mőller © 2000
How to collide two scene graphs? l l Three cases: Reach two internal nodes’ BVs – – l Reach an internal node and a triangle – l Descend into the internal node If you reach two triangles – l If not overlap, then exit If overlap, then descend into the children of the internal node with largest volume 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 l Common choices are l – – – Spheres Axis aligned box Oriented box Tomas Mőller © 2000
Triangle-triangle overlap test Compute the line of intersection between the two planes l Compute the intersection interval between this line and triangles l – l gives two intervals If intervals overlap then triangles overlap! Tomas Mőller © 2000
Simpler collision detection l l l 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? v s Move ball, test for hit, move ball, test for hit… can get “quantum effects”! l In some cases it’s possible to find closedform expression: t=s/v l Tomas Mőller © 2000
Collision detection resources Check out www. realtimerendering. com l RAPID: uses OBBs l SOLID: handles deformable objects l Eberly: code for dynamic CD l – – where no quantum effects can occur Each object has a velocity direction Tomas Mőller © 2000
Resources and Pointers http: //www. realtimerendering. com l Journal of Graphics Tools l – – l http: //www. acm. org/jgt/ source for projected screen area of box intersection test routines occlusion culling http: //www. magic-software. com Tomas Mőller © 2000
- Visual rendering
- Rendering realtime compositing
- Yix speedup
- Speedup theorem
- Wireframe techniques
- Game rendering techniques
- Rational rose
- Real time software definition
- Realtime it
- Js code
- Realtime
- Paul viskovich
- Realtime mobile communication
- Eva rov
- Realtime communications
- Real time characteristics of embedded operating systems
- Frankfurt realtime
- Ams realtime weather maps central
- Realtime aps software
- Iptv infrastructure design
- Realtime interaction management
- Realtime iep
- Realtime big data
- Realtime it
- Realtime interaction
- Firebase push notification android
- Rto real time optimization
- Realtime etl
- Cac realtime
- Lightning realtime
- Realtime messaging protocol
- Ad hoc realtime
- Realtime it
- Realtime networks
- Realtime streaming protocol
- Realtime diagnostics
- Cos realtime
- Realtime forex
- Simple online and realtime tracking
- Alyac realtime service
- Kajiya rendering equation
- Indirect volume rendering
- Clustered forward rendering
- Beauty pass render
- Rendering
- Forma urbis
- Windowscolorsystem
- Christopher buehler