Skip to content

Latest commit

 

History

History
34 lines (19 loc) · 2.16 KB

README.md

File metadata and controls

34 lines (19 loc) · 2.16 KB

grid

GPU-Accelerated Uniform Grid Construction for Ray Tracing

Source code for the article GPU-Accelerated Uniform Grid Construction for Ray Tracing

This repository is a library that implements the uniform grid construction algorithm. Checkout the companion project grid-rt for the GPU-based ray tracing application.

Description

The library includes two implementations of uniform grid construction

  • CPU: src/CpuGrid.*
  • GPU: src/GpuGrid.* + src/cuda + shaders

The GPU algorithm combines very fast scan and sorting procedures to classify scene primitives according to the spatial subdivision. Since the grid structure can be efficiently rebuilt each rendering frame, we can maintain performance with fully animated scenes containing unstructured movements.

The basic idea of the GPU algorithm is to first start a thread per triangle and write to memory, in parallel, which grid cells each triangle overlaps. We write a pair (triangleID, cellID). Then, we rearrange this list so that all triangles belonging to the same cell are contiguous in memory, saving a pair of values per cell (offset to scell start, number of triangles). We use scan and sort procedures to achieve this. Now the structure is ready for GPU-based ray tracing.

Please check the paper reference above for more implementation details.

At rendering time, we trace one ray per GPU thread using a 3D-DDA algorithm. We have two implementations for the ray tracing: GLSL-based and CUDA-based. At the time, the GLSL implementation was about 30% faster. Please check the companion project grid-rt for the implementation of the GPU-based ray tracing application using this library.

Examples

These are some images generated with our algorithm for benchmark animated scenes:

scenes

These are the results in performance, compared to state of the art:

speed

Build

Visual Studio project files available in prj directory.