Visibility Queries Using Graphics Hardware
-
Upload
deacon-bean -
Category
Documents
-
view
42 -
download
1
description
Transcript of Visibility Queries Using Graphics Hardware
Visibility Queries Using Visibility Queries Using Graphics HardwareGraphics Hardware
Presented by Jinzhu Gao
MotivationMotivation
Visibility queries is popular used in different applications– 70% of total computation time in hierarchical
radiosity
Graphics hardware provides fast access to the data computed by the graphics hardware
Point-based Visibility QueryPoint-based Visibility Query
Visibility queries with the same starting point and different ending points
For example: – Eye ray-tracing– A point light source illuminating a scene
Visibility MethodsVisibility Methods
Ray castingZ-bufferUsing object ID imageHP ExtensionsNV Extensions
Using Object ID Image Using Object ID Image
Basic Idea:– Assign a specific color for each element in the
scene– Render all the elements in the scene– The first surface in a given direction is the one
with the color of the pixel intersected in this direction
Using Object ID ImageUsing Object ID Image
Advantage:– Easy to implement– Extremely fast
Disadvantage:– Have aliasing errors
Using Object ID ImageUsing Object ID Image Aliasing errors
– Sampling the scene using a regular grid– Visibility query is at different points than the original samples
Using Object ID ImageUsing Object ID Image
Solution:– Querying neighboring pixels– If all correspond to same surface, answer is correct– Otherwise, just use ray-casting or enhance the image resolution
PerformancePerformance
Test results on a Silicon Graphics RealityEngine II
ConclusionConclusion
The ID images gives us rapid answers in places where there are no problems
Use ray-casting for small problems that concern few visibility queries
Use a better ID image for larger problems that concern several visibility queries
HP Occlusion Test (1)HP Occlusion Test (1)
Extension Name: HP_occlusion_test Provides a visibility determination mechanism After rendering, query if any of the geometry
could have or did modify the depth buffer.– False = geometry could not have affected depth buffer– True = it could have or did modify depth buffer
HP Occlusion Test (2)HP Occlusion Test (2)
The object is not visible if the test fails (returns false)
It is visible if the test passes (returns true)Typical usage:
– Render bounding box for target geometry. – If test fails, you can skip the geometry altogether.
HP Occlusion Test – How to UseHP 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)
HP Occlusion Test - LimitationsHP 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
NV Occlusion Query (1)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
NV Occlusion Query – How to Use (1)NV Occlusion Query – How to Use (1) (Optional) Disable Depth/Color Buffers (Optional) Disable any other irrelevant non-geometric state Generate occlusion queries
– Begin ith occlusion query– Render ith (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 ith query If (count > MAX_COUNT) render ith geometry
NV Occlusion Query – How to Use (2)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 ith geometry glEndOcclusionQueryNV(); }
Get pixel counts
for (i = 0; i < N; i++) { glGetOcclusionQueryuivNV(queries[i], GL_PIXEL_COUNT_NV, &pixelCount); if (pixelCount > MAX_COUNT) // render ith geometry }
Example – Incremental Object-Level CullingExample – Incremental Object-Level Culling
Rendering a bounding box will cost you fillNeed to be more intelligent in how you issue
queries!Good if you use query for object that you were
going to render in any caseSkip the occlusion queries for visible objects
for the next few frames.
Incremental Object-Level Culling (2)Incremental Object-Level Culling (2)
Render scene from front-to-back Draw the big occluders 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.
ConclusionConclusion
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