NVIDIA PROPRIETARY AND CONFIDENTIAL Occlusion (HP and NV Extensions) Ashu Rege.

Slides:



Advertisements
Similar presentations
Technische Universität München Computer Graphics SS 2014 Graphics Effects Rüdiger Westermann Lehrstuhl für Computer Graphik und Visualisierung.
Advertisements

Optimized Stencil Shadow Volumes
Game Programming 09 OGRE3D Lighting/shadow in Action
University of Sulaimani - School of Science - Computer Dept.
CSL 859: Advanced Computer Graphics Dept of Computer Sc. & Engg. IIT Delhi.
GAM532 DPS932 – Week 7 Introduction to shadows. Shadow Effects Light Surface No Shadows Shadows.
Interactive Rendering using the Render Cache Bruce Walter, George Drettakis iMAGIS*-GRAVIR/IMAG-INRIA Steven Parker University of Utah *iMAGIS is a joint.
Week 7 - Monday.  What did we talk about last time?  Specular shading  Aliasing and antialiasing.
Two Methods for Fast Ray-Cast Ambient Occlusion Samuli Laine and Tero Karras NVIDIA Research.
Occlusion Culling Fall 2003 Ref: GamasutraGamasutra.
Visibility Culling using Hierarchical Occlusion Maps Hansong Zhang, Dinesh Manocha, Tom Hudson, Kenneth E. Hoff III Presented by: Chris Wassenius.
Fast GPU Histogram Analysis for Scene Post- Processing Andy Luedke Halo Development Team Microsoft Game Studios.
Real-Time Rendering SPEACIAL EFFECTS Lecture 03 Marina Gavrilova.
黃聰賢. Light Position Mesh Polygon Shadow Polygon  Clear color buffer and stencil buffer  Render the scene with ambient only.
Practical and Robust Stenciled Shadow Volumes for Hardware-Accelerated Rendering Cass Everitt and Mark J. Kilgard Speaker: Alvin Date: 5/28/2003 NVIDIA.
Point Rendering for Impostors Andreas Bærentzen IMM.
Adapted from: CULLIDE: Interactive Collision Detection Between Complex Models in Large Environments using Graphics Hardware Naga K. Govindaraju, Stephane.
Final Gathering on GPU Toshiya Hachisuka University of Tokyo Introduction Producing global illumination image without any noise.
1 Dynamic Shadows and Lighting for Walkthrus of Large Models Brandon Lloyd COMP 258 December 2002.
Z-Buffer Optimizations Patrick Cozzi Analytical Graphics, Inc.
Z-Buffer Optimizations Patrick Cozzi Analytical Graphics, Inc.
Course Website: Computer Graphics 5: Line Drawing Algorithms.
The UNIVERSITY of NORTH CAROLINA at CHAPEL HILL Geometric Computations on GPU: Proximity Queries Avneesh Sud &Dinesh Manocha.
University of Texas at Austin CS 378 – Game Technology Don Fussell CS 378: Computer Game Technology Beyond Meshes Spring 2012.
Computer Graphics Shadows
09/18/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Bump Mapping Multi-pass algorithms.
Computer Graphics: Programming, Problem Solving, and Visual Communication Steve Cunningham California State University Stanislaus and Grinnell College.
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.
Erdem Alpay Ala Nawaiseh. Why Shadows? Real world has shadows More control of the game’s feel  dramatic effects  spooky effects Without shadows the.
Computer Graphics Mirror and Shadows
Shadow Algorithms Ikrima Elhassan.
Ray Tracing and Photon Mapping on GPUs Tim PurcellStanford / NVIDIA.
CS 638, Fall 2001 Today Light Mapping (Continued) Bump Mapping with Multi-Texturing Multi-Pass Rendering.
Visibility Queries Using Graphics Hardware Presented by Jinzhu Gao.
Cg Programming Mapping Computational Concepts to GPUs.
Computer Graphics 2 Lecture 8: Visibility Benjamin Mora 1 University of Wales Swansea Pr. Min Chen Dr. Benjamin Mora.
Advanced Computer Graphics Depth & Stencil Buffers / Rendering to Textures CO2409 Computer Graphics Week 19.
Visibility Culling III: Image-Space Occlusion David Luebke Computer Science Department University of Virginia
Real-Time Rendering SPEEDING UP RENDERING Lecture 04 Marina Gavrilova.
CS 638, Fall 2001 Multi-Pass Rendering The pipeline takes one triangle at a time, so only local information, and pre-computed maps, are available Multi-Pass.
Occlusion Query. Content Occlusion culling Collision detection (convex) Etc. Fall
Shadow Mapping Chun-Fa Chang National Taiwan Normal University.
2 COEN Computer Graphics I Evening’s Goals n Discuss application bottleneck determination n Discuss various optimizations for making programs execute.
Computer graphics & visualization Shadows / Transparency.
09/16/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Environment mapping Light mapping Project Goals for Stage 1.
Stencil Routed A-Buffer
Recap: General Occlusion Culling l When cells and portals don’t work… –Trees in a forest –A crowded train station l Need general occlusion culling algorithms:
Coherent Hierarchical Culling: Hardware Occlusion Queries Made Useful Jiri Bittner 1, Michael Wimmer 1, Harald Piringer 2, Werner Purgathofer 1 1 Vienna.
Computer Graphics 3 Lecture 6: Other Hardware-Based Extensions Benjamin Mora 1 University of Wales Swansea Dr. Benjamin Mora.
Single Pass Point Rendering and Transparent Shading Paper by Yanci Zhang and Renato Pajarola Presentation by Harmen de Weerd and Hedde Bosman.
Maths & Technologies for Games Graphics Optimisation - Batching CO3303 Week 5.
Advanced Programmable Shading: Beyond Per-vertex and Per-pixel Shading.
Real-Time Dynamic Shadow Algorithms Evan Closson CSE 528.
Shadows David Luebke University of Virginia. Shadows An important visual cue, traditionally hard to do in real-time rendering Outline: –Notation –Planar.
Hierarchical Occlusion Map Zhang et al SIGGRAPH 98.
09/23/03CS679 - Fall Copyright Univ. of Wisconsin Last Time Reflections Shadows Part 1 Stage 1 is in.
CHC ++: Coherent Hierarchical Culling Revisited Oliver Mattausch, Jiří Bittner, Michael Wimmer Institute of Computer Graphics and Algorithms Vienna University.
Image Fusion In Real-time, on a PC. Goals Interactive display of volume data in 3D –Allow more than one data set –Allow fusion of different modalities.
Stenciling Effects Glenn G. Chappell
Discrete Techniques.
Real-Time Soft Shadows with Adaptive Light Source Sampling
Week 7 - Monday CS361.
From Turing Machine to Global Illumination
© University of Wisconsin, CS559 Fall 2004
Visibility Computations
UMBC Graphics for Games
Texture and Shadow Mapping
Frame Buffer Applications
Balancing the Graphics Pipeline for Optimal Performance
Presentation transcript:

NVIDIA PROPRIETARY AND CONFIDENTIAL Occlusion (HP and NV Extensions) Ashu Rege

NVIDIA PROPRIETARY AND CONFIDENTIAL Overview What are the HP and NV occlusion tests Why should you care How do you use them Example – Incremental Object-level Culling Example – Order Independent Transparency Example – Lens Flares, Halos, etc. Example – Stencil Shadow Volumes

NVIDIA PROPRIETARY AND CONFIDENTIAL HP Occlusion Test (1) Extension name: HP_occlusion_test Provides a mechanism for determining “visibility” of a set of geometry After rendering geometry, query if any of the geometry could have or did modify the depth buffer. If occlusion test returns false, geometry could not have affected depth buffer If it returns true, it could have or did modify depth buffer

NVIDIA PROPRIETARY AND CONFIDENTIAL HP Occlusion Test (2) All this verbiage basically means that your object is not visible if the test fails (returns false) It is visible if the test passes (returns true) in “usual” circumstances That is, e.g., you haven’t turned off the depth mask or color mask Typical usage: Render bounding box for target geometry. If test fails, you can skip the geometry altogether.

NVIDIA PROPRIETARY AND CONFIDENTIAL HP Occlusion Test – How to Use (Optional) Disable updates to color/depth buffers glDepthMask(GL_FALSE) glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE) Enable occlusion test glEnable(GL_OCCLUSION_TEST_HP) Render (bounding) geometry Disable occlusion test glDisable(GL_ OCCLUSION_TEST_HP) Read occlusion test result glGetBooleanv(GL_OCCLUSION_TEST_RESULT_HP,&result)

NVIDIA PROPRIETARY AND CONFIDENTIAL HP Occlusion Test - Limitations Returns a simple TRUE or FALSE Often useful to know how many pixels were rendered Uses a “stop-and-wait” model for multiple tests Driver has to stop and wait for result of previous test before beginning next test Mediocre performance for multiple tests Eliminates parallelism between CPU and GPU

NVIDIA PROPRIETARY AND CONFIDENTIAL NV Occlusion Query (1) Extension name: NV_occlusion_query Solves problems in HP_occlusion_test Returns pixel count – the no. of pixels that pass Provides an interface to issue multiple queries at once before asking for the result of any one Applications can now overlap the time it takes for the queries to return with other work increasing the parallelism between CPU and GPU

NVIDIA PROPRIETARY AND CONFIDENTIAL NV Occlusion Query – How to Use (1) (Optional) Disable Depth/Color Buffers (Optional) Disable any other irrelevant non-geometric state Generate occlusion queries Begin i th occlusion query Render i th (bounding) geometry End occlusion query Do other CPU computation while queries are being made (Optional) Enable Depth/Color Buffers (Optional) Re-enable other state Get pixel count of i th query If (count > MAX_COUNT) render i th geometry

NVIDIA PROPRIETARY AND CONFIDENTIAL NV Occlusion Query – How to Use (2) Generate occlusion queries Gluint queries[N]; GLuint pixelCount; glGenOcclusionQueriesNV(N, queries); Loop over queries for (i = 0; i < N; i++) { glBeginOcclusionQueryNV(queries[i]); // render bounding box for i th geometry glEndOcclusionQueryNV(); } Get pixel counts for (i = 0; i < N; i++) { glGetOcclusionQueryuivNV(queries[i], GL_PIXEL_COUNT_NV, &pixelCount); if (pixelCount > MAX_COUNT) // render i th geometry }

NVIDIA PROPRIETARY AND CONFIDENTIAL Example – Incremental Object-Level Culling Previous example was rather naïve Rendering a bounding box will cost you fill Need to be more intelligent in how you issue queries! Big win if you use query for object that you were going to render in any case If you have too many objects and want to avoid generating too many queries, you can skip the occlusion queries for visible objects for the next few frames. (For occluded objects you still have to test in case it has become visible.)

NVIDIA PROPRIETARY AND CONFIDENTIAL Incremental Object-Level Culling (2) Better approach for multi-pass algorithms: Render scene (roughly) from front to back Make sure your big occluders like walls etc. are drawn first Issue queries for other objects in the scene If query returns 0 in first pass, you can skip the object in subsequent passes If object is occluded it will get eliminated at worst in the second pass. (Might pass test in first pass because of sorting) Works great if your first pass is used to set up the depth buffer only. (Turn off everything but…) This will get even faster on future hardware.

NVIDIA PROPRIETARY AND CONFIDENTIAL Example – Order Independent Transparency (OIT) Cool approach to transparency! See whitepaper by Cass Everitt on developer site for details Hardware does the sorting for you Can be ‘bolted on’ to applications very easily Uses ‘depth peeling’ to sort the layers in the scene

NVIDIA PROPRIETARY AND CONFIDENTIAL OIT – Depth Peeling Strip away depth layers with each pass Capture RGBA after each layer is peeled Blend from back to front How many layers to use? Use occlusion query with some pixel count (e.g. as % of screen size) to determine when to stop! 0 depth 1 Layer 0Layer 1Layer 2 0 depth 1

NVIDIA PROPRIETARY AND CONFIDENTIAL Example – Lens Flares, Halos,… (1) In typical algorithm lens flare is applied last A 2D texture map is rendered as a billboard Occlusion is dealt with by first rendering the objects in the scene including the light source Determining whether the light source is visible or occluded is typically done by using glReadPixels of the depth buffer To determine how much of the light source is visible you would grab the region of the screen that corresponds to the light source and get the ratio of the visible to total pixels

NVIDIA PROPRIETARY AND CONFIDENTIAL Example – Lens Flares, Halos,… (2) Problems with this approach: To read back contents of the scene, application must wait for rendering to complete, i.e., the pipeline must be flushed – requires CPU wait Reading back data is slow and done at PCI speeds Solution: Use NV_occlusion_query of course! Pixel count will tell you what % of the light source is visible to get an approximation on intensity The query is aysynchronous so CPU can proceed with other computation during the query computation

NVIDIA PROPRIETARY AND CONFIDENTIAL Example – Stencil Shadow Volumes Typical algorithm: (for a given light source) Generate b-rep’s for shadow volumes of occluders Determine whether pixel is shadowed or not using depth and stencil buffers Use NV_occlusion_query to eliminate occluders: If the bounding box of an occluder returns a pixel count of 0, it cannot produce visible shadows so you can eliminate it from consideration One issue to bear in mind: The fill for a bbox might make eliminating occluders more expensive. One solution might be to use lower resolution depth buffer

NVIDIA PROPRIETARY AND CONFIDENTIAL Other Examples For determining whether a light with falloff that is outside the view should be considered in shadow computations. Associate geometry with lit region. Determine if geometry is occluded or not to tell you if light is relevant Use in conjunction with L.O.D. rendering

NVIDIA PROPRIETARY AND CONFIDENTIAL Conclusion Simple to use in applications yet very powerful Provides pixel count – a very useful quantity Can be used asynchronously, more parallelism for you and me Versatile extension that can be used in a wide variety of algorithms/applications

NVIDIA PROPRIETARY AND CONFIDENTIAL Questions, comments, feedback? Ashu Rege,