mirror of
https://github.com/nerfstudio-project/nerfstudio.git
synced 2026-12-03 22:38:48 +08:00
Make resetting the near_plane in NearFarCollider optional. (#2465)
* Make resetting the near_plane in NearFarCollider optional. It is not always desired to reset the near plane to 0.0 during inference. Added an optional flag. * no need to change precision * Update scene_colliders.py --------- Co-authored-by: Brent Yi <yibrenth@gmail.com>
This commit is contained in:
1 parent
87773bb081
commit
793fca55e6
1 file changed
+6
-2
@@ -172,16 +172,20 @@ class NearFarCollider(SceneCollider):
|
|||||||
Args:
|
Args:
|
||||||
near_plane: distance to near plane
|
near_plane: distance to near plane
|
||||||
far_plane: distance to far plane
|
far_plane: distance to far plane
|
||||||
|
reset_near_plane: whether to reset the near plane to 0.0 during inference. The near plane can be
|
||||||
|
helpful for reducing floaters during training, but it can cause clipping artifacts during
|
||||||
|
inference when an evaluation or viewer camera moves closer to the object.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, near_plane: float, far_plane: float, **kwargs) -> None:
|
def __init__(self, near_plane: float, far_plane: float, reset_near_plane: bool = True, **kwargs) -> None:
|
||||||
self.near_plane = near_plane
|
self.near_plane = near_plane
|
||||||
self.far_plane = far_plane
|
self.far_plane = far_plane
|
||||||
|
self.reset_near_plane = reset_near_plane
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
|
|
||||||
def set_nears_and_fars(self, ray_bundle: RayBundle) -> RayBundle:
|
def set_nears_and_fars(self, ray_bundle: RayBundle) -> RayBundle:
|
||||||
ones = torch.ones_like(ray_bundle.origins[..., 0:1])
|
ones = torch.ones_like(ray_bundle.origins[..., 0:1])
|
||||||
near_plane = self.near_plane if self.training else 0
|
near_plane = self.near_plane if (self.training or not self.reset_near_plane) else 0
|
||||||
ray_bundle.nears = ones * near_plane
|
ray_bundle.nears = ones * near_plane
|
||||||
ray_bundle.fars = ones * self.far_plane
|
ray_bundle.fars = ones * self.far_plane
|
||||||
return ray_bundle
|
return ray_bundle
|
||||||
Reference in new issue
Block a user