Demos

This is a collection of old and new demos I've written over the years and finally decided to upload to this blog.  All of the demo downloads include precompiled executables, GLSL shaders and/or OpenCL kernels and the main source file.

Single Pass GPU Voxelization (OpenGL 4.2)
This demo is an implementation of single pass voxelization on the GPU as described by Cyril Crassin and Simon Green at the beginning of their OpenGL Insights article Octree-Based Sparse Voxelization Using the GPU Hardware Rasterizer. The geometry shader is used to project each triangle orthographically along the dominant axis of its normal. Each rasterized voxel is then written directly to a 3D texture. Writing directly to a sparse voxel octree was left out for simplicity purposes.
Download Windows 64-bit Demo
OIT with MSAA (OpenGL 4.2)
This is a modified version of the basic OIT demo below that adds support for MSAA.
Download Windows 64-bit Demo
OIT Using Linked Lists (OpenGL 4.2)
This is bare bones code needed to implement Order Independent Transparency using linked lists under OpenGL 4.2.  I've never felt that there were very good examples on the web for implementing OIT under OpenGL (with the exception of Cyril Crassin's but his uses a shared fragment pool that complicates the implementation).  I wanted to implement one that was as simple and straight forward as possible.
Download Windows 64-bit Demo
OIT Using Stencil Routed K-Buffer
This demo demonstrates Order Independent Transparency using the Stencil Routed K-Buffer technique in OpenGL.  This demo only works on NVIDIA cards.  AMD's drivers apparently have a bug which does not execute sample masking correctly.  The demo is hard coded to allocate an 8x multi-sampled stencil buffer, so only 8 layers are supported.
Download Windows 64-bit Demo
Volumetric Ambient Occlusion
This demo demonstrates volumetric ambient occlusion whereby a 4096x4096 texture is used to represent a 256^3 volume.  Each texel stores an occlusion factor for that particular voxel in the scene.  The scene's depth buffer is captured from multiple view points.  Each texel in the 4096x4096 texture projects onto the current view.  If the texel's depth is greater than the depth value sampled from the current view, then it's occluded.  The occlusion factor is accumulated in a single channel floating point texture then applied in a post process step to the scene.
Download Windows 64-bit Demo
Terrain Ray Tracing
This demo demonstrates basic heightmap ray tracing.  To accelerate traversing the heightmap, a mipmap chain of min/max displacement maps are generated from the original heightmap.  Each ray performs an intersection test with the highest mipmap level then traverses down the chain until the heightmap is reached.  Once the heightmap is reached, instead of performing an iterative binary intersection test, 2 triangles are reconstructed from a 2x2 pixel area on the heightmap and the ray is intersected with these.
Download Windows 64-bit Demo
Voxel Ray Tracing
This demo demonstrates voxel ray tracing using a sparse voxel octree.  Each node in the sparse voxel octree is stored as a 32-bit integer.  The first 2 bits designate whether the node is a leaf node and whether it has any children.  The remaining 30 bits represent the color of the voxel (if it's a leaf node) or the starting address of the node's 8 children within the data array.  I also ported this to OpenCL.
Download GLSL Version Windows 64-bit Demo
Download OpenCL Version Windows 64-bit Demo
DXT1 Texture Compression
This demo demonstrates basic DXT1 texture compression on the GPU using a GLSL shader.  Nothing fancy is done to calculate the two endpoints of the color line for each 4x4 block of pixels.  The min and max values of the block are used.  I also ported this to OpenCL.  Both the GLSL and OpenCL versions can be downloaded below.
Download GLSL Version Windows 64-bit Demo
Download OpenCL Version Windows 64-bit Demo