tfg.rendering.rasterization_backend.rasterize
Stay organized with collections
Save and categorize content based on your preferences.
Rasterizes the scene.
tfg.rendering.rasterization_backend.rasterize(
vertices: type_alias.TensorLike,
triangles: type_alias.TensorLike,
view_projection_matrices: type_alias.TensorLike,
image_size: Tuple[int, int],
enable_cull_face: bool = True,
num_layers: int = 1,
backend: enum.Enum = tfg.rendering.rasterization_backend.RasterizationBackends.OPENGL
) -> tfg.rendering.framebuffer.Framebuffer
This rasterizer estimates which triangle is associated with each pixel.
Args |
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.
|
Raises |
KeyError
|
if backend is not part of supported rasterization backends.
|
Returns |
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.
|
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-10-28 UTC.
[null,null,["Last updated 2022-10-28 UTC."],[],[],null,["# tfg.rendering.rasterization_backend.rasterize\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/rendering/rasterization_backend.py#L30-L85) |\n\nRasterizes the scene. \n\n tfg.rendering.rasterization_backend.rasterize(\n vertices: type_alias.TensorLike,\n triangles: type_alias.TensorLike,\n view_projection_matrices: type_alias.TensorLike,\n image_size: Tuple[int, int],\n enable_cull_face: bool = True,\n num_layers: int = 1,\n backend: enum.Enum = ../../../tfg/rendering/rasterization_backend/RasterizationBackends#OPENGL\n ) -\u003e ../../../tfg/rendering/framebuffer/Framebuffer\n\nThis rasterizer estimates which triangle is associated with each pixel.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|----------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `vertices` | A tensor of shape `[batch, num_vertices, 3]` containing batches of vertices, each defined by a 3D point. |\n| `triangles` | A tensor of shape `[num_triangles, 3]` containing triangles, each associated with 3 vertices from `vertices`. |\n| `view_projection_matrices` | A tensor of shape `[batch, 4, 4]` containing batches of view projection matrices. |\n| `image_size` | A tuple of integers (width, height) containing the dimensions in pixels of the rasterized image. |\n| `enable_cull_face` | A boolean, which will enable BACK face culling when True and no face culling when False. |\n| `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. |\n| `backend` | An enum containing the backend method to use for rasterization. Supported options are defined in the RasterizationBackends enum. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|------------|-------------------------------------------------------------|\n| `KeyError` | if backend is not part of supported rasterization backends. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|--------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| A Framebuffer containing the rasterized values: barycentrics, triangle_id, foreground_mask, vertex_ids. Returned Tensors have shape \\[batch, num_layers, height, width, channels\\]. ||\n| `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. |\n\n\u003cbr /\u003e"]]