nerfacc.accumulate_along_rays¶
- nerfacc.accumulate_along_rays(weights, ray_indices, values=None, n_rays=None)¶
Accumulate volumetric values along the ray.
Note
This function is only differentiable to weights and values.
- Parameters:
weights (Tensor) – Volumetric rendering weights for those samples. Tensor with shape (n_samples,).
ray_indices (Tensor) – Ray index of each sample. LongTensor with shape (n_samples).
values (Optional[Tensor]) – The values to be accmulated. Tensor with shape (n_samples, D). If None, the accumulated values are just weights. Default is None.
n_rays (Optional[int]) – Total number of rays. This will decide the shape of the ouputs. If None, it will be inferred from ray_indices.max() + 1. If specified it should be at least larger than ray_indices.max(). Default is None.
- Returns:
Accumulated values with shape (n_rays, D). If values is not given then we return the accumulated weights, in which case D == 1.
- Return type:
Tensor
Examples:
# Rendering: accumulate rgbs, opacities, and depths along the rays. colors = accumulate_along_rays(weights, ray_indices, values=rgbs, n_rays=n_rays) opacities = accumulate_along_rays(weights, ray_indices, values=None, n_rays=n_rays) depths = accumulate_along_rays( weights, ray_indices, values=(t_starts + t_ends) / 2.0, n_rays=n_rays, ) # (n_rays, 3), (n_rays, 1), (n_rays, 1) print(colors.shape, opacities.shape, depths.shape)