Skip to content
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

Update volrend.py #271

Merged
merged 1 commit into from
Dec 14, 2023
Merged
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
5 changes: 4 additions & 1 deletion nerfacc/volrend.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def rendering(
rgb_alpha_fn: Optional[Callable] = None,
# rendering options
render_bkgd: Optional[Tensor] = None,
expected_depths: bool = True,
) -> Tuple[Tensor, Tensor, Tensor, Dict]:
"""Render the rays through the radience field defined by `rgb_sigma_fn`.

Expand All @@ -49,6 +50,7 @@ def rendering(
ray indices} and returns the post-activation rgb (..., 3) and opacity
values (...,). The shape `...` is the same as the shape of `t_starts`.
render_bkgd: Background color. Tensor with shape (3,).
expected_depths: If True, return the expected depths. Else, the accumulated depth is returned.

Returns:
Ray colors (n_rays, 3), opacities (n_rays, 1), depths (n_rays, 1) and a dict
Expand Down Expand Up @@ -150,7 +152,8 @@ def rendering(
ray_indices=ray_indices,
n_rays=n_rays,
)
depths = depths / opacities.clamp_min(torch.finfo(rgbs.dtype).eps)
if expected_depths:
depths = depths / opacities.clamp_min(torch.finfo(rgbs.dtype).eps)

# Background composition.
if render_bkgd is not None:
Expand Down