nerfstudio-project / nerfacc

A General NeRF Acceleration Toolbox in PyTorch.
https://www.nerfacc.com/
Other
1.37k stars 113 forks source link

about single_traversal #231

Closed yyzzyy78 closed 1 year ago

yyzzyy78 commented 1 year ago

Thanks for the great work!

I'm confused about the function single_traversal. In the code, https://github.com/KAIR-BAIR/nerfacc/blob/master/nerfacc/cuda/csrc/include/utils_grid.cuh#L119 , it seems that the smallest component of tdist is chosen to march one step in the voxel. That means, if tdist.x <tdist.y<tdist.z, then the current_index will march one step in the direction of step_index.x. I don't understand why the smallest component is chosen.

For example, if a ray which basically parallels to the y-axis travels through the voxel(tdist.x&tdist.y&tdist.z!=0), and the hit voxels will travel along the y-axis. I think the tdist(tmax_xyz) means the distance emitted from the ray origin to the currently calculated voxel. In this case, the dist.x and dist.z will be smaller than dist.y, which means the voxel will travel along the x-axis or z-axis in the code. But I think the current_index voxel will go in y-axis only. Maybe I didn't understand the meaning of tdist(tmax_xyz). I am looking forward to your reply.

yyzzyy78 commented 1 year ago

The link to the code is here, https://github.com/KAIR-BAIR/nerfacc/blob/433130618da036d64581e07dc1bf5520bd213129/nerfacc/cuda/csrc/include/utils_grid.cuh#L119

liruilong940607 commented 1 year ago

This repo has a nice go-thru illustration of the algorithm of ray-voxel-traversal. The tmax section is the answer for your question (you might need to read from the start to follow the flow).

https://github.com/cgyurgyik/fast-voxel-traversal-algorithm/blob/master/overview/FastVoxelTraversalOverview.md#tmax

yyzzyy78 commented 1 year ago

Thanks,I will read it!