tfg.rendering.rasterization_backend.rasterize

Stay organized with collections Save and categorize content based on your preferences.

Rasterizes the scene.

This rasterizer estimates which triangle is associated with each pixel.

vertices A tensor of shape [batch, num_vertices, 3] containing batches of vertices, each defined by a 3D point.
triangles A tensor of shape [num_triangles, 3] containing triangles, each associated with 3 vertices from vertices.
view_projection_matrices A tensor of shape [batch, 4, 4] containing batches of view projection matrices.
image_size A tuple of integers (width, height) containing the dimensions in pixels of the rasterized image.
enable_cull_face A boolean, which will enable BACK face culling when True and no face culling when False.
num_layers Number of depth layers to render. Output tensors shape depends on whether num_layers=1 or not. Supported by CPU rasterizer only and does nothing for OpenGL backend.
backend An enum containing the backend method to use for rasterization. Supported options are defined in the RasterizationBackends enum.

KeyError if backend is not part of supported rasterization backends.

A Framebuffer containing the rasterized values: barycentrics, triangle_id, foreground_mask, vertex_ids. Returned Tensors have shape [batch, num_layers, height, width, channels].
Note triangle_id contains the triangle id value for each pixel in the output image. For pixels within the mesh, this is the integer value in the range [0, num_vertices] from triangles. For vertices outside the mesh this is 0; 0 can either indicate belonging to triangle 0, or being outside the mesh. This ensures all returned triangle ids will validly index into the vertex array, enabling the use of tf.gather with indices from this tensor. The barycentric coordinates can be used to determine pixel validity instead. See framebuffer.py for a description of the Framebuffer fields.