fast_voxel_traversal icon indicating copy to clipboard operation
fast_voxel_traversal copied to clipboard

Wrong next_voxel_boundary_* on negative directions

Open metropolik opened this issue 6 years ago • 1 comments

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.

next_voxel_boundary 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!

metropolik avatar Oct 27 '18 18:10 metropolik

Thanks! you are my life saver

anzsoup avatar Jan 24 '20 13:01 anzsoup