tfg.rendering.splat.rasterize_then_splat
Stay organized with collections
Save and categorize content based on your preferences.
Rasterization with differentiable occlusion using rasterize-then-splat.
tfg.rendering.splat.rasterize_then_splat(
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],
shading_function: Callable[[Dict[str, tf.Tensor]], tf.Tensor],
num_layers=1,
return_extra_buffers=False,
backend: enum.Enum = tfg.rendering.rasterization_backend.RasterizationBackends.CPU
,
name='rasterize_then_splat'
)
Rasterizes the input triangles to produce surface point samples, applies
a user-specified shading function, then splats the shaded point
samples onto the pixel grid.
The attributes are arbitrary per-vertex quantities (colors, normals, texture
coordinates, etc.). The rasterization step interpolates these attributes
across triangles to produce a dictionary of per-pixel interpolated attributes
buffers with shapes [H, W, K]
where K
is the number of channels of the
input attribute. This dictionary is passed to the user-provided
shading_function
, which performs shading and outputs a [H, W, 4]
buffer of RGBA colors. The result of the shader is replaced with (0,0,0,0) for
background pixels.
In the common case that the attributes are RGBA vertex colors, the shading
function may just pass the rasterized attributes through (i.e.,
shading_function = lambda x: x['color']
where color
is an RGBA attribute).
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.
|
shading_function
|
a function that takes a dictionary of [H, W, K]
rasterized attribute tensors and returns a [H, W, 4] RGBA tensor.
|
num_layers
|
int specifying number of depth layers to composite.
|
return_extra_buffers
|
if True, the function will return raw accumulation
buffers for visualization.
|
backend
|
A rasterization_backend.RasterizationBackends enum containing the
backend method to use for rasterization.
|
name
|
A name for this op. Defaults to "rasterize_then_splat".
|
Returns |
a [A1, ..., An, H, W, 4] tensor of RGBA values.
|
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.splat.rasterize_then_splat\n\n\u003cbr /\u003e\n\n|------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/rendering/splat.py#L183-L311) |\n\nRasterization with differentiable occlusion using rasterize-then-splat. \n\n tfg.rendering.splat.rasterize_then_splat(\n vertices: type_alias.TensorLike,\n triangles: type_alias.TensorLike,\n attributes: Dict[str, type_alias.TensorLike],\n view_projection_matrix: type_alias.TensorLike,\n image_size: Tuple[int, int],\n shading_function: Callable[[Dict[str, tf.Tensor]], tf.Tensor],\n num_layers=1,\n return_extra_buffers=False,\n backend: enum.Enum = ../../../tfg/rendering/rasterization_backend/RasterizationBackends#CPU,\n name='rasterize_then_splat'\n )\n\nRasterizes the input triangles to produce surface point samples, applies\na user-specified shading function, then splats the shaded point\nsamples onto the pixel grid.\n\nThe attributes are arbitrary per-vertex quantities (colors, normals, texture\ncoordinates, etc.). The rasterization step interpolates these attributes\nacross triangles to produce a dictionary of per-pixel interpolated attributes\nbuffers with shapes `[H, W, K]` where `K` is the number of channels of the\ninput attribute. This dictionary is passed to the user-provided\n`shading_function`, which performs shading and outputs a `[H, W, 4]`\nbuffer of RGBA colors. The result of the shader is replaced with (0,0,0,0) for\nbackground pixels.\n\nIn the common case that the attributes are RGBA vertex colors, the shading\nfunction may just pass the rasterized attributes through (i.e.,\n`shading_function = lambda x: x['color']` where `color` is an RGBA attribute).\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|--------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `vertices` | A tensor of shape `[A1, ..., An, V, 3]` containing batches of `V` vertices, each defined by a 3D point. |\n| `triangles` | A tensor of shape `[T, 3]` containing `T` triangles, each associated with 3 vertices from `vertices`. |\n| `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. |\n| `view_projection_matrix` | A tensor of shape `[A1, ..., An, 4, 4]` containing batches of matrices used to transform vertices from model to clip coordinates. |\n| `image_size` | A tuple (height, width) containing the dimensions in pixels of the rasterized image. |\n| `shading_function` | a function that takes a dictionary of `[H, W, K]` rasterized attribute tensors and returns a `[H, W, 4]` RGBA tensor. |\n| `num_layers` | int specifying number of depth layers to composite. |\n| `return_extra_buffers` | if True, the function will return raw accumulation buffers for visualization. |\n| `backend` | A rasterization_backend.RasterizationBackends enum containing the backend method to use for rasterization. |\n| `name` | A name for this op. Defaults to \"rasterize_then_splat\". |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| a `[A1, ..., An, H, W, 4]` tensor of RGBA values. ||\n\n\u003cbr /\u003e"]]