# tfg.rendering.barycentrics.compute_barycentric_coordinates

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/rendering/barycentrics.py#L204-L237) |

Computes per-pixel barycentric coordinates.

    tfg.rendering.barycentrics.compute_barycentric_coordinates(
        triangle_ids: type_alias.TensorLike,
        triangle_matrices: type_alias.TensorLike,
        px: type_alias.TensorLike,
        py: type_alias.TensorLike
    ) -> tf.Tensor

<br />

<br />

<br />

| ## Args ||
|---|---|
| `triangle_ids` | 2-D int tensor with shape \[image_height, image_width\] containing per-pixel triangle ids, as computed by rasterize_triangles. |
| `triangle_matrices` | 3-D float32 tensor with shape \[3, 3, triangle_count\] containing per-triangle matrices computed by compute_triangle_matrices. |
| `px` | 2-D float32 tensor with shape \[image_height, image_width\] containing per-pixel x-coordinates, as computed by normalized_pixel_coordinates. |
| `py` | 2-D float32 tensor with shape \[image_height, image_width\] containing per-pixel y-coordinates, as computed by normalized_pixel_coordinates. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| 3-D float32 tensor with shape \[height, width, 3\] containing the barycentric coordinates of the point at each pixel within the triangle specified by triangle_ids. ||

<br />