# tfg.rendering.triangle_rasterizer.rasterize

<br />

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

Rasterizes the scene.

    tfg.rendering.triangle_rasterizer.rasterize(
        vertices: type_alias.TensorLike,
        triangles: type_alias.TensorLike,
        attributes: Dict[str, type_alias.TensorLike],
        view_projection_matrix: type_alias.TensorLike,
        image_size: Tuple[int, int],
        enable_cull_face: bool = True,
        use_vectorized_map: bool = True,
        backend: enum.Enum = https://www.tensorflow.org/graphics/api_docs/python/tfg/rendering/rasterization_backend/RasterizationBackends#OPENGL,
        name: str = 'triangle_rasterizer_rasterize'
    ) -> Dict[str, type_alias.TensorLike]

<br />

<br />

<br />

| ## Note ||
|---|---|
| In the following, A1 to An are optional batch dimensions. ||

<br />

<br />

<br />

<br />

| ## Args ||
|---|---|
| `vertices` | A tensor of shape `[A1, ..., An, V, 3]` containing batches of `V` vertices, each defined by a 3D point. |
| `triangles` | A tensor of shape `[T, 3]` containing `T` triangles, each associated with 3 vertices from `vertices`. |
| `attributes` | A dictionary of tensors, each of shape `[A1, ..., An, V, K]` containing batches of `V` vertices, each associated with K-dimensional attributes. K may vary by attribute. |
| `view_projection_matrix` | A tensor of shape `[A1, ..., An, 4, 4]` containing batches of matrices used to transform vertices from model to clip coordinates. |
| `image_size` | A tuple (height, width) containing the dimensions in pixels of the rasterized image. |
| `enable_cull_face` | Enables BACK face culling when True, and no culling when False. |
| `use_vectorized_map` | If true uses vectorized_map for barycentrics computations otherwise uses map_fn. |
| `backend` | A rasterization_backend.RasterizationBackends enum containing the backend method to use for rasterization. |
| `name` | A name for this op. Defaults to "triangle_rasterizer_rasterize". |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A dictionary. The key "mask" is of shape `[A1, ..., An, height, width, 1]` and stores a value of `0` of the pixel is assciated with the background, and `1` with the foreground. The key "barycentrics" is of shape `[A1, ..., An, height, width, 3]` and stores barycentric weights. Finally, the dictionary contains perspective correct interpolated attributes of shape `[A1, ..., An, height, width, K]` per entry in the `attributes` dictionary. ||

<br />