kaolin.render.spc

API

kaolin.render.spc.mark_first_hit(nuggets)

Mark the first hit in the nuggets.

The nuggets are a packed tensor containing correspondences from ray index to point index, sorted within each ray pack by depth. This will mark True for each first hit (by depth) for a pack of nuggets.

Returns

the boolean mask marking the first hit by depth.

Return type

first_hits (torch.BoolTensor)

kaolin.render.spc.unbatched_ray_aabb(nuggets, point_hierarchy, ray_o, ray_d, level, info=None, info_idxes=None, mask=None)

Ray AABB intersection with points.

Raytrace will already get correspondences, but this will additionally compute distances.

Note

This function is likely to be folded into raytrace in a future version.

Parameters
  • nuggets (torch.IntTensor) – the ray-point correspondences, of shape \((\text{num_nuggets}, 2)\).

  • point_hierarchy (torch.ShortTensor) – the point_hierarchy associated to the octree, of shape \((\text{num_points}, 3)\).

  • ray_o (torch.FloatTensor) – ray origins, of shape \((\text{num_rays}, 3)\).

  • ray_d (torch.FloatTensor) – ray directions, of shape \((\text{num_rays}, 3)\).

  • level (int) – level of the SPC to trace.

  • info (torch.BoolTensor) – First hits. Default: Computed internally.

  • info_idxes (torch.IntTensor) – Packed indices of first hits. Default: Computed internally.

  • mask (torch.BoolTensor) – Mask to determine if the ray is still alive. Default: zeros mask.

Returns

  • Distance from ray origin to ray-aabb intersection, of shape \((\text{num_rays}, 1)\).

  • Corresponding point index, of shape \((\text{num_rays})\).

  • New mask. \((\text{num_rays})\).

Return type

(torch.FloatTensor, torch.LongTensor, torch.BoolTensor)

kaolin.render.spc.unbatched_raytrace(octree, point_hierarchy, pyramid, exsum, origin, direction, level)

Apply ray tracing over an unbatched SPC structure.

The SPC model will be always normalized between -1 and 1 for each axis.

Parameters
  • octree (torch.ByteTensor) – the octree structure, of shape \((\text{num_bytes})\).

  • point_hierarchy (torch.ShortTensor) – the point hierarchy associated to the octree, of shape \((\text{num_points}, 3)\).

  • pyramid (torch.IntTensor) – the pyramid associated to the octree, of shape \((2, \text{max_level} + 2)\).

  • exsum (torch.IntTensor) – the prefix sum associated to the octree. of shape \((\text{num_bytes} + \text{batch_size})\).

  • origin (torch.FloatTensor) – the origins of the rays, of shape \((\text{num_rays}, 3)\).

  • direction (torch.FloatTensor) – the directions of the rays, of shape \((\text{num_rays}, 3)\).

  • level (int) – level to use from the octree.

Returns

Nuggets of intersections sorted by depth,

of shape \((\text{num_intersection}, 2)\) representing pairs \((\text{index_to_ray}, \text{index_to_points})\).

Return type

(torch.IntTensor)