• Docs >
  • Utils >
  • nerfacc.render_transmittance_from_density
Shortcuts

nerfacc.render_transmittance_from_density

nerfacc.render_transmittance_from_density(t_starts, t_ends, sigmas, packed_info=None, ray_indices=None, n_rays=None, prefix_trans=None)

Compute transmittance \(T_i\) from density \(\sigma_i\).

\[T_i = exp(-\sum_{j=1}^{i-1}\sigma_j\delta_j)\]

This function supports both batched and flattened input tensor. For flattened input tensor, either (packed_info) or (ray_indices and n_rays) should be provided.

Parameters:
  • t_starts (Tensor) – Where the frustum-shape sample starts along a ray. Tensor with shape (all_samples,) or (n_rays, n_samples).

  • t_ends (Tensor) – Where the frustum-shape sample ends along a ray. Tensor with shape (all_samples,) or (n_rays, n_samples).

  • sigmas (Tensor) – The density values of the samples. Tensor with shape (all_samples,) or (n_rays, n_samples).

  • packed_info (Optional[Tensor]) – A tensor of shape (n_rays, 2) that specifies the start and count of each chunk in the flattened samples, with in total n_rays chunks. Useful for flattened input.

  • ray_indices (Optional[Tensor]) – Ray indices of the flattened samples. LongTensor with shape (all_samples).

  • n_rays (Optional[int]) – Number of rays. Only useful when ray_indices is provided.

  • prefix_trans (Optional[Tensor]) – The pre-computed transmittance of the samples. Tensor with shape (all_samples,).

Returns:

The rendering transmittance and opacities, both with the same shape as sigmas.

Return type:

Tuple[Tensor, Tensor]

Examples:

>>> t_starts = torch.tensor([0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0], device="cuda")
>>> t_ends = torch.tensor([1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0], device="cuda")
>>> sigmas = torch.tensor([0.4, 0.8, 0.1, 0.8, 0.1, 0.0, 0.9], device="cuda")
>>> ray_indices = torch.tensor([0, 0, 0, 1, 1, 2, 2], device="cuda")
>>> transmittance, alphas = render_transmittance_from_density(
>>>     t_starts, t_ends, sigmas, ray_indices=ray_indices)
transmittance: [1.00, 0.67, 0.30, 1.00, 0.45, 1.00, 1.00]
alphas: [0.33, 0.55, 0.095, 0.55, 0.095, 0.00, 0.59]