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

A reference implementation of drtk.interpolate() in pure PyTorch.

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 V 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]#

A reference implementation of drtk.interpolate() in pure PyTorch. This function is used for tests only, please see drtk.interpolate() for documentation.