nerfacc icon indicating copy to clipboard operation
nerfacc copied to clipboard

traverse_grids has bug in some situation?

Open SamuelSJTU opened this issue 9 months ago • 1 comments

There is something wrong with the result of this function traverse_grids. Sometimes may filter ray cause black line.

from nerfacc.grid import _enlarge_aabb, traverse_grids

binaries = torch.zeros([1,32,32,32],dtype=torch.bool).cuda().fill_(True)
aabbs = torch.tensor([[-1,-1,-1,1,1,1]]).float().cuda()

tmp_rays_o = torch.tensor([[1,0,0],[1,0,0]]).float().cuda()
tmp_rays_d = torch.tensor([[-1,1e-16,0],[-1,-1e-16,0]]).float().cuda()  ## use -1e-16 is wrong
far_planes = torch.tensor([3,3]).float().cuda()
near_planes = torch.tensor([0,0]).float().cuda()
render_step_size = 0.001
cone_angle = 0

traverse_grids(tmp_rays_o,tmp_rays_d,binaries,aabbs,near_planes=near_planes,far_planes=far_planes,step_size=render_step_size,cone_angle=cone_angle)[0].ray_indices

## result tensor([0, 0, 0,  ..., 0, 0, 0], device='cuda:0')

## should has ray id 1
from nerfacc.grid import _enlarge_aabb, traverse_grids

binaries = torch.zeros([1,32,32,32],dtype=torch.bool).cuda().fill_(True)
aabbs = torch.tensor([[-1,-1,-1,1,1,1]]).float().cuda()

tmp_rays_o = torch.tensor([[1,0,0],[1,0,0]]).float().cuda()
tmp_rays_d = torch.tensor([[-1,1e-16,0],[-1,-1e-7,0]]).float().cuda()  ## use -1e-7 is right
far_planes = torch.tensor([3,3]).float().cuda()
near_planes = torch.tensor([0,0]).float().cuda()
render_step_size = 0.001
cone_angle = 0

traverse_grids(tmp_rays_o,tmp_rays_d,binaries,aabbs,near_planes=near_planes,far_planes=far_planes,step_size=render_step_size,cone_angle=cone_angle)[0].ray_indices

## result  tensor([0, 0, 0,  ..., 1, 1, 1], device='cuda:0')

SamuelSJTU avatar Nov 20 '23 09:11 SamuelSJTU

Yeah floating error is always a headache -- currently i dont have a better way to deal with it

liruilong940607 avatar Dec 12 '23 03:12 liruilong940607