Totoro97/NeuS

near_far_from_sphere

013292 opened this issue · 1 comments

Hi, since the previous issue on this topic has been closed, I open up this new one.
the snippet:

  def near_far_from_sphere(self, rays_o, rays_d):
      a = torch.sum(rays_d**2, dim=-1, keepdim=True)
      b = 2.0 * torch.sum(rays_o * rays_d, dim=-1, keepdim=True)
      mid = 0.5 * (-b) / a
      near = mid - 1.0
      far = mid + 1.0
      return near, far

May I take it this way: the sphere is centered at the origin of world space and its radius is 1, so that c = torch.sum(rays_o**2, dim=-1, keepdim=True) - 1?
But if I calculate x = (-b + torch.sqrt(b**2 - 4*a*c))/(2*a), it is non of near or far.
What's the difference between the solution x and the near and far?
Thank you :-)

In my understanding, the near and far points in this snippet are hard coded as points 1 unit away from the middle point of the actual intersections. With this setup, the sampling is always performed on 2-unit line segments.
Screen Shot 2023-05-12 at 12 38 30