Download presentation
Presentation is loading. Please wait.
Published byDella Parsons Modified over 9 years ago
1
Occlusion Query
2
Content Occlusion culling Collision detection (convex) Etc. Fall 20132
3
3 Modern Occlusion Culling Support from hardware would be nice –Want an “occlusion test”: would this polygon be visible if I rendered it? –How could you use such a test? Test portal polygons before rendering adjacent cell Test object bounding boxes before rendering object hidden don’t render
4
Fall 20134 Modern Occlusion Culling GL_ARB_OCCLUSION_QUERY is the solution –Non-blocking query “Is this occlusion query done yet?” Multiple queries in flight –Returns number of fragments visible Note: can actually render object or not Still lots of issues for efficient culling
5
Fall 20135 Overview Main usage: determine visibility of an object –Render major occluders first; perform an occlusion query for the bounding box of each detail object in the scene –Encapsulate each query in a “query object” that allow applications to issue many queries before asking for the result of any one
6
Fall 20136 API Query object –Contain one piece of state (integer result) –Active query API Summary –GenQueries (n, *ids); DeleteQueries (n, *ids) –IsQuery (id) –BeginQuery (target,id); EndQuery (target) Target: SAMPLES_PASSED –GetQueryObjectiv (id,QUERY_RESULT,*params) –Asynchronous query: QUERY_RESULT_AVAILABLE
7
Fall 20137 Example Asynchronous query; not “stop-and-wait”
8
Fall 20138 Occlusion Culling (ref)ref 1.Render every object's bounding mesh 2.For every object: a.Begin query b.Re-render the bounding mesh c.End query d.Retrieve occlusion query data. If the pixels visible are greater than zero, the object should be rendered. Otherwise, the object should be occluded from rendering.
9
Fall 20139 Demo Program First pass: render scene into depth buffer Second pass: render scene to query Depth test: GL_LEQUAL Get query results
10
Ex: Occlusion Culling Fall 201310
11
Fall 201311
12
Fall 201312 What good is it to know the number of samples visible Objects that are visible but cover only a very small number of pixels can be skipped at a minimal reduction of image quality. Knowing exactly how many pixels an object might cover may help the application decide which level-of-detail model should be used. If only a few pixels are visible, a low-detail model may be acceptable. "Depth peeling" techniques, such as order-independent transparency, need to know when to stop rendering more layers; it is difficult to determine a priori how many layers are needed. A boolean result allows applications to stop when more layers will not affect the image at all, but this will likely result in unacceptable performance. Instead, it makes more sense to stop rendering when the number of pixels in each layer falls below a given threshold. Occlusion queries can replace glReadPixels of the depth buffer to determine whether (for example) a light source is visible for the purposes of a lens flare effect or a halo to simulate glare. Pixel counts allow you to compute the percentage of the light source that is visible, and the brightness of these effects can be modulated accordingly.
13
Other Uses for Occlusion Queries –Approximate culling –LOD size estimation –Lens flare effects –Collision detection (next page) Fall 201313
14
GPUCD – Convex objects Fall 201314 THE NINE CASES IN WHICH A RAY MAY INTERSECT TWO CONVEX OBJECTS, A AND B. collision
15
Two-Pass Algorithm First pass: –Render A to depth buffer (less-equal) –Change depth test to greater-than –Render B with occlusion query if nothing is visible, either B is fully in front of A, or no B [cases 9 & 3 & 1] Second pass: –switch roles of A & B [cases 4 & 2] All other cases: A & B intersect Fall 201315
16
Ex: Two-Pass Algorithm Fall 201316 (a) Initial depth buffer (b) Render A to depth buffer; test B (c) Render B to depth buffer; test A
17
Fall 201317
18
Fall 201318
19
Result Fall 201319
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.