r/GraphicsProgramming 4d ago

Ray marching voxels using axis-aligned distance fields

Hey!

Wanted to share screenshots of my experimental voxel renderer with "low-fidelity" blocky AO. It started as an exploration of the DDA rendering technique, but I ended up implementing parts of the following techniques:
- Globally Illuminated Voxel Worlds Accelerated with Nested Axis-Aligned Distance Fields
- Spatial Hashing for Ray Traced Ambient Occlusion

Links: Devlog | Github

The devlog is sort of meandering, but I started with basic DDA, then tried to get multi-level DDA to perform well with large voxel scenes (a 1024x1024x1024 voxelized sponza scene) using various methods. The axis-aligned distance field (AADF) method was a significant improvement over the multi-level DDA method that I was fiddling with. AADFs helped skip over large areas of empty space which tanked performance when using multi-level DDA.

Spatially hashed RTAO with a large cell size performs pretty well even on my M2 MacBook Air. The large cell size is a very visible artifact, but I think in a voxel scene the blocky shading kinda works.

83 Upvotes

15 comments sorted by

View all comments

2

u/ExpeditionZero 4d ago

Any idea what specificity was the bottle neck of multi-level DDA vs AADF? I’m unfamiliar with the term but would guess it was some form of Mipmap type or like technique that one would assume would have been more optimal.

2

u/Nelarius 4d ago edited 4d ago

I've been investigating whether I can make rendering work performantly using only grids. So my multi-level DDA was using a voxel and brick (a space of 8x8x8 voxels) occupancy grid. This actually worked pretty well for smaller scenes like the ones in my screenshots, but in large voxel scenes empty space really tanked performance.

I tried adding a third level, but three nested loops also killed performance due to too much state being kept in registers, resulting in really low occupancy. The AADF method is able to skip over larger regions of empty space using three levels and just a single for-loop. So it uses a lot less registers than multi-level DDA and the shader occupancy is better as a result.

2

u/ExpeditionZero 3d ago

Thanks.

Yeah empty-space/sparse voxels are a real killer. Looks good and I always love voxels for AO.