drtk.interpolate#

drtk.interpolate module provides functions for differentiable interpolation of vertex attributes across the fragments, e.i. pixels covered by the primitive.

interpolate

Performs a linear interpolation of the vertex attributes given the barycentric coordinates

interpolate_ref

Pure PyTorch reference implementation used by tests.

drtk.interpolate(vert_attributes, vi, index_img, bary_img)[source]#

Performs a linear interpolation of the vertex attributes given the barycentric coordinates

Parameters:
  • vert_attributes (th.Tensor) – vertex attribute tensor N x V x C

  • vi (th.Tensor) – face vertex index list tensor F x 3 or N x F x 3

  • index_img (th.Tensor) – index image tensor N x H x W

  • bary_img (th.Tensor) – 3D barycentric coordinate image tensor N x 3 x H x W

Returns:

A tensor with interpolated vertex attributes with a shape [N, C, H, W]

Warning

The returned tensor has only valid values for pixels which have a valid index in index_img. For all other pixels, which had index -1 in index_img, the returned tensor will have non-zero values which should be ignored.

drtk.interpolate_ref(vert_attributes, vi, index_img, bary_img)[source]#

Pure PyTorch reference implementation used by tests.

This helper is intentionally not part of the documented public API. See drtk.interpolate() for the supported implementation.