Skip to content

Commit 7804cb2

Browse files
authored
adding near plane (#12)
* small fixes to occupancy code * adding near plane * adding near plane * removed files. make sure to squash * upgrade version
1 parent 98f820b commit 7804cb2

File tree

3 files changed

+9
-2
lines changed

3 files changed

+9
-2
lines changed

nerfacc/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ def volumetric_marching(
4545
t_min: Tensor = None,
4646
t_max: Tensor = None,
4747
render_step_size: float = 1e-3,
48-
stratified: bool = False,
48+
near_plane: float = 0.0,
49+
stratified: bool = False
4950
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
5051
"""Volumetric marching with occupancy test.
5152
@@ -64,6 +65,7 @@ def volumetric_marching(
6465
t_max: Optional. Ray far planes. Tensor with shape (n_ray,). \
6566
If not given it will be calculated using aabb test. Default is None.
6667
render_step_size: Marching step size. Default is 1e-3.
68+
near_plane: Near plane of the camera. Default is 0.0.
6769
stratified: Whether to use stratified sampling. Default is False.
6870
6971
Returns:
@@ -83,6 +85,8 @@ def volumetric_marching(
8385
raise NotImplementedError("Only support cuda inputs.")
8486
if t_min is None or t_max is None:
8587
t_min, t_max = ray_aabb_intersect(rays_o, rays_d, aabb)
88+
if near_plane > 0.0:
89+
t_min = torch.clamp(t_min, min=near_plane)
8690
assert (
8791
scene_occ_binary.numel()
8892
== scene_resolution[0] * scene_resolution[1] * scene_resolution[2]

nerfacc/volumetric_rendering.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def volumetric_rendering(
1919
scene_resolution: Tuple[int, int, int],
2020
render_bkgd: torch.Tensor,
2121
render_step_size: int,
22+
near_plane: float = 0.0,
2223
stratified: bool = False,
2324
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
2425
"""A *fast* version of differentiable volumetric rendering."""
@@ -48,6 +49,8 @@ def volumetric_rendering(
4849
scene_occ_binary=scene_occ_binary,
4950
# sampling
5051
render_step_size=render_step_size,
52+
# optional settings
53+
near_plane=near_plane,
5154
stratified=stratified,
5255
)
5356
frustum_positions = (

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "nerfacc"
7-
version = "0.0.4"
7+
version = "0.0.5"
88
authors = [{name = "Ruilong", email = "[email protected]"}]
99
license = { text="MIT" }
1010
requires-python = ">=3.8"

0 commit comments

Comments
 (0)