Skip navigation
I've been writing some code for efficient traversal in voxel spaces recently.
0:00 / 0:31

I've been writing some code for efficient traversal in voxel spaces recently.

Topotoy Labs

@topotoylabs1.4K followers

Visit on X
498 likesDownloadOriginal post

25,850 views #gamedev #solodev #indiedev

I've been writing some code for efficient traversal in voxel spaces recently. Here's a visual comparison between the Bresenham line algorithm, and the Amanatides-Woo "Fast Voxel Traversal Algorithm". #gamedev #solodev #indiedev #customengine

13 Comments

Comments from the original post on X (Twitter)

  • Meetem's profile picture

    @Meetem4

    At first I used it too, but unfortunately it’s too slow for big volumes and too rigid / expensive when it comes to skipping larger steps (like skipping 128/64/32 voxels etc), so only left it for small chunks where it works perfectly, and higher level is a traced tree

    5 likes

  • Topotoy Labs's profile picture

    @topotoylabs

    Good point. Indeed, per-cell traversal is an insufficient approach for sparse/big volumes. But I will address that with a multi-resolution grid and a lo-hi precalculation of the contents of each cell.

  • Meetem's profile picture

    @Meetem4

    If you have an option to make mipmaps like Teardown did then HDDA can make sense, yes

    1 like

  • Maurog's profile picture

    @MaurogDark

    I dunno what you're building there, but in any case, this might help 🤔

    4 likes

  • Topotoy Labs's profile picture

    @topotoylabs

    Thanks! This is part of a larger system I am building for terrain rendering.

    1 like

  • Xiltsch's profile picture

    @Xiltsch

    Is there any difference between Amanatides-Woo and the DDA(Digital Differential Analyzer) Algorithm?

    2 likes

  • Topotoy Labs's profile picture

    @topotoylabs

    Somebody correct me if I'm wrong. My understanding is that DDA is any algorithm that incrementally steps through a line in a grid. Bresenham is a 2D, integer-only version. Amanatides–Woo traverses the 2D/3D cells pierced by the line segment between two floating-point endpoints.

    1 like

  • Xiltsch's profile picture

    @Xiltsch

    I looked the termup and found a paper titled "A Fast Voxel Traversal Algorithm for Ray Tracing" it appears to be a variant of DDA

    1 like

  • Floorislava's profile picture

    @Floorislava

    I was messing around doing a line of sight/lighting map and came up with a worse way of doing this but I thought it was interesting. Find the normal of the ray cast. Each voxel step, add the normal which is only 2 floating point adds with no branching.

    2 likes

  • AlbedoLux's profile picture

    @AlbedoLux

    The Bresenham line algorithm is so clean. Understanding how it works teaches you so much about efficiency

    1 like

  • ShiroJR's profile picture

    @ShiroJR1811

    Oh i had the pleasure of doing 3D DDA recently too. Nothing fancy tho, just the basics...

    1 like

  • Yuri Karabatov's profile picture

    @karabatov

    Looks like line rasterizing 😅

    1 like

  • Topotoy Labs's profile picture

    @topotoylabs

    That's what it is!