"docs/source/git@developer.sourcefind.cn:OpenDAS/dgl.git" did not exist on "a2a3a9132579ef49929ed00d2ec8a681440cdb63"
Unverified Commit 255352aa authored by Ruilong Li(李瑞龙)'s avatar Ruilong Li(李瑞龙) Committed by GitHub
Browse files

enable default None for occ binary (#21)

* typehints into description

* speed up occ field by 20%

* tests

* fix docs

* backward in tests

* cleanup volumetric rendering func

* enable default None for occ binary
parent d16d5b74
from typing import Callable, List, Tuple from typing import Callable, List, Optional, Tuple
import torch import torch
...@@ -16,9 +17,9 @@ def volumetric_rendering( ...@@ -16,9 +17,9 @@ def volumetric_rendering(
rays_o: torch.Tensor, rays_o: torch.Tensor,
rays_d: torch.Tensor, rays_d: torch.Tensor,
scene_aabb: torch.Tensor, scene_aabb: torch.Tensor,
scene_resolution: List[int], scene_resolution: Optional[List[int]] = None,
scene_occ_binary: torch.Tensor, scene_occ_binary: Optional[torch.Tensor] = None,
render_bkgd: torch.Tensor, render_bkgd: Optional[torch.Tensor] = None,
render_step_size: float = 1e-3, render_step_size: float = 1e-3,
near_plane: float = 0.0, near_plane: float = 0.0,
stratified: bool = False, stratified: bool = False,
...@@ -26,6 +27,17 @@ def volumetric_rendering( ...@@ -26,6 +27,17 @@ def volumetric_rendering(
"""Differentiable volumetric rendering.""" """Differentiable volumetric rendering."""
n_rays = rays_o.shape[0] n_rays = rays_o.shape[0]
if scene_occ_binary is None:
scene_occ_binary = torch.ones(
(1, 1, 1),
dtype=torch.bool,
device=rays_o.device,
)
if scene_resolution is None:
assert scene_occ_binary is not None and scene_occ_binary.dim() == 3
scene_resolution = scene_occ_binary.shape
rays_o = rays_o.contiguous() rays_o = rays_o.contiguous()
rays_d = rays_d.contiguous() rays_d = rays_d.contiguous()
scene_aabb = scene_aabb.contiguous() scene_aabb = scene_aabb.contiguous()
...@@ -106,6 +118,7 @@ def volumetric_rendering( ...@@ -106,6 +118,7 @@ def volumetric_rendering(
# n_rays=n_rays, # n_rays=n_rays,
# ) # )
colors = colors + render_bkgd * (1.0 - opacities) if render_bkgd is not None:
colors = colors + render_bkgd * (1.0 - opacities)
return colors, opacities, n_marching_samples, n_rendering_samples return colors, opacities, n_marching_samples, n_rendering_samples
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