TensoRF
TensoRF copied to clipboard
Non-NDC Ray Sampling Logic
Hey, I am trying to understand this piece of code here. Would you mind explaining what exactly its trying to compute? What is rate_a/b & t_min. I might be rusty of on 3D geom
https://github.com/apchenstu/TensoRF/blob/main/models/tensorBase.py#L281-L284
Hi @ayush29feb - I was just reading into that function also, so I'll try to lend my current understanding here related to the math:
-
Re: your second question -
rate_a
andrate_b
are the distances between sampled points on 2 separate rays. Specifically, the rays that go from eachrays_o
to theaabb[0]
(aka themin_xyz
, or the bottom-left corner of the axis-aligned bounding box) andaabb[1]
(which conversely is themax_xyz
point in theaabb
) respectively. -
Re: t_min: so both
rate_a
andrate_b
tell us the number of sampled points on each of the rays (I like to think of them as the number of "steps" we take along that ray). -
Then we take the element-wise
minimum()
of these two, which I think represents for each ray, along each of the xyz axes, it stores what was the least amount of steps needed to get inside the bounding box. -
Finally it calls
amax()
and passes-1
for thedim
- so now it's just like the tensor before, but we're only taking the largest number of steps that was needed along any of the xyz axes (again, this is for when each ray first enters the bbox).
Hope this is helpful!
The lines that you mentioned are used to filter rays that do not intersect the aabb. Here is a link with more details: https://www.scratchapixel.com/lessons/3d-basic-rendering/minimal-ray-tracer-rendering-simple-shapes/ray-box-intersection
Sorry for opening this one, but I have a slightly related question to this non-ndc sampling logic: Is there a reason why you are using stepsize*(torch.arange(N_samples) + some noise) starting from bbox edge t_min (lines https://github.com/apchenstu/TensoRF/blob/main/models/tensorBase.py#L288-L293), instead of sampling in a (near,far) range as you did for sample_ray_ndc with linspace?
In this way, if I am not mistaken, you have a tradeoff between N_samples vs stepsize to cover whole bbox range (i.e. you need a lot of N_samples to cover full bbox if stepsize is really small)?