Skip to content

adding near plane #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion nerfacc/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ def volumetric_marching(
t_min: Tensor = None,
t_max: Tensor = None,
render_step_size: float = 1e-3,
stratified: bool = False,
near_plane: float = 0.0,
stratified: bool = False
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
"""Volumetric marching with occupancy test.
Expand All @@ -64,6 +65,7 @@ def volumetric_marching(
t_max: Optional. Ray far planes. Tensor with shape (n_ray,). \
If not given it will be calculated using aabb test. Default is None.
render_step_size: Marching step size. Default is 1e-3.
near_plane: Near plane of the camera. Default is 0.0.
stratified: Whether to use stratified sampling. Default is False.
Returns:
Expand All @@ -83,6 +85,8 @@ def volumetric_marching(
raise NotImplementedError("Only support cuda inputs.")
if t_min is None or t_max is None:
t_min, t_max = ray_aabb_intersect(rays_o, rays_d, aabb)
if near_plane > 0.0:
t_min = torch.clamp(t_min, min=near_plane)
assert (
scene_occ_binary.numel()
== scene_resolution[0] * scene_resolution[1] * scene_resolution[2]
Expand Down
3 changes: 3 additions & 0 deletions nerfacc/volumetric_rendering.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ def volumetric_rendering(
scene_resolution: Tuple[int, int, int],
render_bkgd: torch.Tensor,
render_step_size: int,
near_plane: float = 0.0,
stratified: bool = False,
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
"""A *fast* version of differentiable volumetric rendering."""
Expand Down Expand Up @@ -48,6 +49,8 @@ def volumetric_rendering(
scene_occ_binary=scene_occ_binary,
# sampling
render_step_size=render_step_size,
# optional settings
near_plane=near_plane,
stratified=stratified,
)
frustum_positions = (
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "nerfacc"
version = "0.0.4"
version = "0.0.5"
authors = [{name = "Ruilong", email = "[email protected]"}]
license = { text="MIT" }
requires-python = ">=3.8"
Expand Down