"...api/git@developer.sourcefind.cn:renzhc/diffusers_dcu.git" did not exist on "a062e47ec399fb9d9a274882180f453ce16ca52b"
Unverified Commit 7804cb2f authored by Ethan Weber's avatar Ethan Weber Committed by GitHub
Browse files

adding near plane (#12)

* small fixes to occupancy code

* adding near plane

* adding near plane

* removed files. make sure to squash

* upgrade version
parent 98f820b1
...@@ -45,7 +45,8 @@ def volumetric_marching( ...@@ -45,7 +45,8 @@ def volumetric_marching(
t_min: Tensor = None, t_min: Tensor = None,
t_max: Tensor = None, t_max: Tensor = None,
render_step_size: float = 1e-3, 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]: ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor, torch.Tensor]:
"""Volumetric marching with occupancy test. """Volumetric marching with occupancy test.
...@@ -64,6 +65,7 @@ def volumetric_marching( ...@@ -64,6 +65,7 @@ def volumetric_marching(
t_max: Optional. Ray far planes. Tensor with shape (n_ray,). \ t_max: Optional. Ray far planes. Tensor with shape (n_ray,). \
If not given it will be calculated using aabb test. Default is None. If not given it will be calculated using aabb test. Default is None.
render_step_size: Marching step size. Default is 1e-3. 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. stratified: Whether to use stratified sampling. Default is False.
Returns: Returns:
...@@ -83,6 +85,8 @@ def volumetric_marching( ...@@ -83,6 +85,8 @@ def volumetric_marching(
raise NotImplementedError("Only support cuda inputs.") raise NotImplementedError("Only support cuda inputs.")
if t_min is None or t_max is None: if t_min is None or t_max is None:
t_min, t_max = ray_aabb_intersect(rays_o, rays_d, aabb) 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 ( assert (
scene_occ_binary.numel() scene_occ_binary.numel()
== scene_resolution[0] * scene_resolution[1] * scene_resolution[2] == scene_resolution[0] * scene_resolution[1] * scene_resolution[2]
......
...@@ -19,6 +19,7 @@ def volumetric_rendering( ...@@ -19,6 +19,7 @@ def volumetric_rendering(
scene_resolution: Tuple[int, int, int], scene_resolution: Tuple[int, int, int],
render_bkgd: torch.Tensor, render_bkgd: torch.Tensor,
render_step_size: int, render_step_size: int,
near_plane: float = 0.0,
stratified: bool = False, stratified: bool = False,
) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]: ) -> Tuple[torch.Tensor, torch.Tensor, torch.Tensor]:
"""A *fast* version of differentiable volumetric rendering.""" """A *fast* version of differentiable volumetric rendering."""
...@@ -48,6 +49,8 @@ def volumetric_rendering( ...@@ -48,6 +49,8 @@ def volumetric_rendering(
scene_occ_binary=scene_occ_binary, scene_occ_binary=scene_occ_binary,
# sampling # sampling
render_step_size=render_step_size, render_step_size=render_step_size,
# optional settings
near_plane=near_plane,
stratified=stratified, stratified=stratified,
) )
frustum_positions = ( frustum_positions = (
......
...@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta" ...@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
[project] [project]
name = "nerfacc" name = "nerfacc"
version = "0.0.4" version = "0.0.5"
authors = [{name = "Ruilong", email = "ruilongli94@gmail.com"}] authors = [{name = "Ruilong", email = "ruilongli94@gmail.com"}]
license = { text="MIT" } license = { text="MIT" }
requires-python = ">=3.8" requires-python = ">=3.8"
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment