nerfstudio-project / nerfacc

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

Fixed grid traversal with near and far planes #204

Closed arterms closed 1 year ago

arterms commented 1 year ago

This PR fixes wrong points sampling behind the far_plane, as described in #201

liruilong940607 commented 1 year ago

Hi thanks for doing this fix.

It does not seem correct to me as clamping t_traverse to far plane would not terminate marching. As a result there would be many zero length segments returned in intervals.vals

I think it should be just break the loop once t_traverse exceed the far plane

Have you printed out the returned intervals?

arterms commented 1 year ago

Yes, I have checked this PR by printing out the returned intervals. It doesn't produce degenerated samples with intervals of zero length. Moreover I have added a test named test_traverse_grids_with_near_far_planes to verify that no points are sampled behind far_planes. As for me, with this fix the function works as expected. If I clearly understand the code, the loop of marching will be terminated as the sampled point exceeds the t_traversal value (clamped to far plane value).

liruilong940607 commented 1 year ago

Actually I revisited the code and I agree it would not create degenerated samples because of this line. Yeah now I agree this is the right fix. I’ll merge it then. Thanks for the contribution!!

liruilong940607 commented 1 year ago

There is a formatting test failure. You can fix it by running:

pip install .[dev]
black docs/ nerfacc/ scripts/ examples/ tests/ --exclude examples/pycolmap --line-length 80
arterms commented 1 year ago

Just fixed the formatting