fast_voxel_traversal
fast_voxel_traversal copied to clipboard
Wrong next_voxel_boundary_* on negative directions
Hello, when the next_voxel_boundary_*
is calculated and the ray is in a given direction negative, the next_voxel_boundary
in this direction is assumed to be on the line of the coordinate of the voxel itself. Meaning the boundary will be off by one.
2D Case: The ray is towards the negative direction, hence
stepY = -1
The origin lies in the voxel (0, 0). The next_voxel_boundary_y
is calculated by (current_voxel[1]+stepY)*_bin_size
. However this references in this case the bottom edge of the voxel (0, 1) which then results in a wrongly calculated tMaxY. In the paper tMaxY is described as the value of t at which the ray crosses the first horizontal voxel boundary. A Possible fix is to add _bin_size
to next_voxel_boundary_*
if step*
is negative.
I've only noticed it because a dense raymarcher traversed other voxels. To receive identical voxel traversal, the lines 64 to 73 (69 excluded) must be removed. In total the bug can rarely be observed but with large enough voxels one can see voxels disappearing or taking an irregular shape. Only after changing this my voxel raytracer renderer gave correct results. Cheers!
Thanks! you are my life saver