nerfstudio-project / nerfacc

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

Question about the new sampling function #209

Closed bolopenguin closed 1 year ago

bolopenguin commented 1 year ago

Hello I'm upgrading my project to the new version of nerfacc (in particular I'm currently using the 0.5.2 version).

I have a question concerning the new nerfacc.OccGridEstimator.sampling and the old nerfacc.ray_marching. In particular, I used to set the scene_aabb parameter, but I have noticed that it disappeared and I did not find something similar.

How should I change the code to use the scene_aabb in the new nerfacc version? Thank you a lot

liruilong940607 commented 1 year ago

Hi now you don’t need to set the scene aabb anymore as it will be automatically calculated based on aabb of the grid. Specifically, the largest aabb of the Occupancy Grid is just the scene aabb.

bolopenguin commented 1 year ago

I agree but only at training time. I have a GUI similar to instant-ngp, and I want to crop the scene like they do.

I was using the scene_aabb with the older version, now in this release I found this way:

t_min, t_max, _ = nerfacc.ray_aabb_intersect(
    rays_o=rays_o_chunk,
    rays_d=rays_d_chunk,
    aabbs=scene_aabb.unsqueeze(0),
)
ray_indices, t_starts, t_ends = occupancy_grid.sampling(
    rays_o=rays_o_chunk,
    rays_d=rays_d_chunk,
    t_min=t_min.squeeze(-1),
    t_max=t_max.squeeze(-1),
    render_step_size=render_step_size,
)

Do you see any problem with this implementation? Or maybe there is a better/faster way to do it?

liruilong940607 commented 1 year ago

Oh i see. yeah this implementation is exactly what you need.