Optimised ray marching for voxel worlds, written in C# and open sourced from the Vercidium Engine.
The explanation of the source code can be found in this blog post.
This voxel ray marching algorithm is based on A Fast Voxel Traversal Algorithm for Ray Tracing by John Amanatides and Andrew Woo and has been optimised by keeping block lookups within the current working chunk.
Benchmarks were run with a Ryzen 5 1600 CPU.
Ray length (blocks) | Ray march time (nanoseconds) | Rays per 16ms frame |
---|---|---|
1-10 | 250 | 64000 |
200-400 | 3400 | 4700 |
In Sector's Edge, ray marching is used to calculate particle and projectile collision with the map.