tfg.rendering.splat.splat_at_pixel_centers
Stay organized with collections
Save and categorize content based on your preferences.
Splat a buffer of XYZ, RGBA samples onto a pixel grid of the same size.
tfg.rendering.splat.splat_at_pixel_centers(
xyz_rgba: Tuple[tf.Tensor, tf.Tensor]
) -> Tuple[tf.Tensor, tf.Tensor, tf.Tensor]
This is a specialized splatting function that takes a multi-layer buffer of
screen-space XYZ positions and RGBA colors and splats each sample into
a buffer of the same size, using a 3x3 Gaussian kernel of variance 0.25.
The accumulated layers are then composited back-to-front.
The specialized part is that the 3x3 kernel is always centered on the
pixel-coordinates of the sample in the input buffer, not the XY position
stored at that sample, but the weights are defined by using the XY position.
Computing weights w.r.t. the XY positions, rather than the pixel-centers,
allows gradients to flow from the output RGBA back to the XY positions. When
used in rasterize-then-splat, XY positions will always coincide with the pixel
centers, so the forward computation is the same as if the XY positions defined
the position of the splat.
When splatting, the Z of the splat is compared with the Z of the layers under
the splat sample. The sample is accumulated into the layer with the Z closest
to the Z of the splat itself.
Args |
xyz_rgba
|
a tuple of a float32 tensor of rasterized XYZ positions with shape
[num_layers, height, width, 3] and a tensor of RGBA colors [num_layers,
height, width, 4]. Passed as a tuple to support tf.vectorized_map.
|
Returns |
A tensor of shape [height, width, 4] with RGBA values, as well as
[num_layers, height, width, 4] tensor of accumulated and normalized colors
for visualization and debugging.
|
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.splat_at_pixel_centers\n\n\u003cbr /\u003e\n\n|-----------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/rendering/splat.py#L29-L180) |\n\nSplat a buffer of XYZ, RGBA samples onto a pixel grid of the same size. \n\n tfg.rendering.splat.splat_at_pixel_centers(\n xyz_rgba: Tuple[tf.Tensor, tf.Tensor]\n ) -\u003e Tuple[tf.Tensor, tf.Tensor, tf.Tensor]\n\nThis is a specialized splatting function that takes a multi-layer buffer of\nscreen-space XYZ positions and RGBA colors and splats each sample into\na buffer of the same size, using a 3x3 Gaussian kernel of variance 0.25.\nThe accumulated layers are then composited back-to-front.\n\nThe specialized part is that the 3x3 kernel is always centered on the\npixel-coordinates of the sample in the input buffer, *not* the XY position\nstored at that sample, but the weights are defined by using the XY position.\nComputing weights w.r.t. the XY positions, rather than the pixel-centers,\nallows gradients to flow from the output RGBA back to the XY positions. When\nused in rasterize-then-splat, XY positions will always coincide with the pixel\ncenters, so the forward computation is the same as if the XY positions defined\nthe position of the splat.\n\nWhen splatting, the Z of the splat is compared with the Z of the layers under\nthe splat sample. The sample is accumulated into the layer with the Z closest\nto the Z of the splat itself.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `xyz_rgba` | a tuple of a float32 tensor of rasterized XYZ positions with shape \\[num_layers, height, width, 3\\] and a tensor of RGBA colors \\[num_layers, height, width, 4\\]. Passed as a tuple to support tf.vectorized_map. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ------- ||\n|---|---|\n| A tensor of shape \\[height, width, 4\\] with RGBA values, as well as \\[num_layers, height, width, 4\\] tensor of accumulated and normalized colors for visualization and debugging. ||\n\n\u003cbr /\u003e"]]