nerfacc.render_transmittance_from_alpha¶
- nerfacc.render_transmittance_from_alpha(alphas, packed_info=None, ray_indices=None, n_rays=None, prefix_trans=None)¶
Compute transmittance \(T_i\) from alpha \(\alpha_i\).
\[T_i = \prod_{j=1}^{i-1}(1-\alpha_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:
alphas (Tensor) – The opacity 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 with the same shape as alphas.
- Return type:
Tensor
Examples:
>>> alphas = 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 = render_transmittance_from_alpha(alphas, ray_indices=ray_indices) tensor([1.0, 0.6, 0.12, 1.0, 0.2, 1.0, 1.0])