Include Files:

\trunk\Win32 Precompiled\OcclusionEngineLib.h

Dll Files:

\trunk\Win32 Precompiled\OcclusionEngineLib.dll

 

3D DEMO

There is a C# and Managed DirectX 9 demo available in Demo CSharp folder.Compile the project and select the different demos in the tree on the left.

 

SetUp the Engine:

  • OcclusionHandle InitializeOcclusionEngine(int width, int height, OcclusionEngineOptions options);

Starts the Occlusion Culling Engine and prepares the occlusion buffer based on the options provided. Returns the Handle to the Occlusion Engine or NULL if failed.

Width and Height: The buffer size of the occlusion engine. The values should be a downsampled from the framebuffer size. For example if your framebuffer screen is set to 1920x1080 pixels, then the Width and Height for the buffer could be 480x270   ( 1920/4 and 1080/4).

  • OcclusionEngineOptions
  • EOcclusionEngineMode engineMode
    Choose between
    • Optimized: Uses SSE, lazy tiles and other optimizations. (recommended)
    • NormalRasterization: (No optimization, used to debug)
  • Tile Size
    Used when Optimized Engine mode is selected. Uses Lazy Tiles to speed up rendering. This parameter specifies the tile size used in the occlusion buffer.
    A value of 16 is recommended.
  • numberOfThreads
    The number of threads to distrubute the rasterization work. Best if the value is set to the number of physical CPU cores. Set a value 0 for automatically assign of number of threads.
  • drawAllTiles
    Enable this option to draw all internal Lazy Tiles. Best set to False, used for debugging only.

Example:

const int buffSizeX = 480;
const int buffSizeY = 270;

OcclusionHandle occEngineOptimized;

OcclusionEngineOptions options;

options.drawAllTiles = false;
options.engineMode = Optimized;
options.numberOfThreads = 0;
options.tileSize = 16;

occEngineOptimized = InitializeOcclusionEngine(buffSizeX,buffSizeY, options);

 

Add the occluders:

 

 

  • bool addOccluders(OcclusionHandle handle, const OccluderData occludersData[], const int numberOfOccluders);
    Sends an array of occluders to the engine for rasterization.
  • handle:

The OcclusionHandle obtained after calling InitializeOcclusionEngine in the Engine Setup.

  • occludersData [ ]
    The array of Occluders.

  • numberOfOccluders:

    The number of occluders in the array.

OccluderData

The occluder Data contains the Quads that represent the virtual occluders.
The quads expected must:

  • Be in Screen Space:

The x and y coordinates should be between 0 and BufferSizeX - 1. If the Occlusion Buffer is downsampled, then you should scale the points too.

  • Have a Correct Depth Value:
    The depth should be a value between 0 and 1 (inclusive). If Occluder Boxes lay behind the near plane, clip the quads manually.

struct OccluderPoint
{
    //Occluder vertex point in image space. Can be out of screen bounds.
    int x;
    int y;

    float depth; // Depth value between 0 and 1 (inclusive).
};
   
struct OccluderData
{
    //List of occluder convex hull points ordered counter-clockwise.
    OccluderPoint points[MAX_POINTS_PER_OCCLUDER];
       
    //Number of occluder convex hull points.
    int numberOfPoints;
};

Unexpected results can occur if these conditions are not met.

Test Occluder visibility:

  • bool testOccludeeVisibility(OcclusionHandle handle,const OccludeeData occludee)

    Returns true if occludee is potentially visible. False if occluded.

    • Handle:

The OcclusionHandle obtained after calling InitializeOcclusionEngine in the Engine Setup.

  •  
    • OccludeeData

       Contains the 2D axis Alined bounding box of the Occluder and a conservative depth (Farthest depth value of the whole occludee)

Clear Buffer after every frame:

 

  • void clearOcclusionEngine(OcclusionHandle handle)
    Clear the Occlusion buffer after finishing the visibility test for every frame.
  •  
    • Handle:

The OcclusionHandle obtained after calling InitializeOcclusionEngine in the Engine Setup.

Free Memory on close:

 

  • void disposeOcclusionEngine(OcclusionHandle handle)

Frees the allocated memory for the occlusion buffer.

  • Handle:

The OcclusionHandle obtained after calling InitializeOcclusionEngine in the Engine Setup.

 

 

Last edited Oct 21, 2012 at 11:25 PM by lebarba, version 6

Comments

No comments yet.