https://github.com/potato3d/grid
GPU-accelerated uniform grid construction for ray tracing
https://github.com/potato3d/grid
cuda glsl gpu grid ray-tracing
Last synced: about 1 year ago
JSON representation
GPU-accelerated uniform grid construction for ray tracing
- Host: GitHub
- URL: https://github.com/potato3d/grid
- Owner: potato3d
- License: mit
- Created: 2021-02-13T12:46:55.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-02-13T13:18:42.000Z (over 5 years ago)
- Last Synced: 2025-03-31T02:11:43.779Z (about 1 year ago)
- Topics: cuda, glsl, gpu, grid, ray-tracing
- Language: C
- Homepage:
- Size: 1.73 MB
- Stars: 6
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# grid
GPU-Accelerated Uniform Grid Construction for Ray Tracing
Source code for the article [GPU-Accelerated Uniform Grid Construction for Ray Tracing](http://www.dbd.puc-rio.br/depto_informatica/09_14_ivson.pdf)
This repository is a library that implements the uniform grid construction algorithm. Checkout the companion project [grid-rt](https://github.com/potato3d/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](https://github.com/potato3d/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:

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

# Build
Visual Studio project files available in prj directory.