Occlusion Culling Using Direct3D 9.0

In the view frustum culling scenario, the culling-in objects like the bottom figure shows:
But in the practical view looks like the bottom figure, we just need to render three objects: red, purple, and blue one. The green and yellow one are hidden.
In this condition, we can adopt GPU hardware support. Direct3D provides Occlusion Query to calculate number of pixel visible. If the number is zero, meaning it is fully occluded, else is greater than zero  the pixel is visible by the viewer.

The IDirect3DQuery9 process is presented below:
  1. Render every object's bounding mesh
  2. For every object:

    1. Begin query
    2. Re-render the bounding mesh
    3. End query
    4. 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.
In the first step, we need to decide the bounding mesh. Use bounding box? sphere?...The suit way is using lower vertex count mesh to instead of bounding box or sphere.
Bounding sphere may have the same vertex count with bounding mesh, but it can't approximate like bounding mesh, use bounding mesh can effectively test the occlusion, and well enough accurate. render the bounding mesh first to make sure the scene is present in the Z buffer.
 
At the second step, occlusion query to determine each object's visibility status. If the query is zero pixel, the object is exclude from the final draw, else the object is include in the render list. Adopt much smaller surface (320 pixels to 240 pixels) is used to improve performance.


reference: Occlusion Culling Using DirectX 9, http://www.gamedev.net/reference/programming/features/occlusionculling/
CodeSampler: http://www.codesampler.com/dx9src/dx9src_7.htm#dx9_occlusion_query
Direct3D 9: http://msdn.microsoft.com/en-us/library/bb147308%28VS.85%29.aspx
Image-Based Occlusion Culling: http://cggmwww.csie.nctu.edu.tw/~danki/myweb/projects/hom/index.html  
GPU Gems2: Chapter 6. Hardware Occlusion Queries Made Useful http://http.developer.nvidia.com/GPUGems2/gpugems2_chapter06.html

Comments

Popular posts from this blog

董事長您好

After reading Steve Jobs Autobiography

Drawing textured cube with Vulkan on Android