tfg.rendering.texture.mipmap.map_texture
Stay organized with collections
Save and categorize content based on your preferences.
Maps the texture texture_image using uv_map with mip-mapping.
tfg.rendering.texture.mipmap.map_texture(
uv_map: tfg_type.TensorLike,
texture_image: Optional[tfg_type.TensorLike] = None,
mipmap_images: Optional[Sequence[tfg_type.TensorLike]] = None,
num_mipmap_levels: Optional[int] = 5,
tiling: bool = False,
name: Text = 'mipmap_map_texture'
) -> tf.Tensor
The convention we use is that the origin in the uv-space is at (0, 0), u
corresponds to the x-axis, v corresponds to the y-axis, and the color for each
pixel is associated with the center of the corresponding pixel. E.g. if we
have a texture [[1, 2], [3, 4]], then the uv-coordinates that correspond to
the values 1, 2, 3, and 4 are (0.25, 0.75), (0.75, 0.75), (0.25, 0.25),
(0.75, 0.25), respectively. You can see that the v-axis starts from the bottom
of the texture image as would be in cartesian coordinates and that by
multiplying the uv-coordinates with the length of the texture image, 2, you
can recover the pixel centers in this case, e.g. (0.25, 0.25) * 2 = (0.5, 0.5)
corresponds to the bottom-left pixel color that is 3.
If the aspect ratio of the texture is not 1, the texture is compressed to fit
into a square.
Note that all shapes are assumed to be static.
Args |
uv_map
|
A tensor of shape [A1, ..., An, H, W, 2] containing the uv
coordinates with range [0, 1], height H and width W.
|
texture_image
|
An optional tensor of shape [H', W', C] containing the
texture to be mapped with height H', width W', and number of channels C of
the texture image.
|
mipmap_images
|
Optional list containing the original texture image at
multiple resolutions starting from the highest resolution. If not
provided, these are computed from texture_image and hence, texture_image
needs to be provided in that case. If both texture_image and mipmap_images
are provided, mipmap_images are used and texture_image is ignored.
|
num_mipmap_levels
|
An optional integer specifying the number of mipmap
levels. Each level is computed by downsampling by a factor of two. If
mipmap_images is provided, num_mipmap_levels is comptued as its length.
|
tiling
|
If enabled, the texture is tiled so that any uv value outside the
range [0, 1] will be mapped to the tiled texture. E.g. if uv-coordinate is
(0, 1.5), it is mapped to (0, 0.5). When tiling, the aspect ratio of the
texture image should be 1.
|
name
|
A name for this op that defaults to "mipmap_map_texture".
|
Returns |
A tensor of shape [A1, ..., An, H, W, C] containing the interpolated
values.
|
Raises |
ValueError
|
If texture_image is too small for the mipmap images to be
constructed.
|
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.texture.mipmap.map_texture\n\n\u003cbr /\u003e\n\n|--------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/graphics/blob/master/tensorflow_graphics/rendering/texture/mipmap.py#L45-L197) |\n\nMaps the texture texture_image using uv_map with mip-mapping. \n\n tfg.rendering.texture.mipmap.map_texture(\n uv_map: tfg_type.TensorLike,\n texture_image: Optional[tfg_type.TensorLike] = None,\n mipmap_images: Optional[Sequence[tfg_type.TensorLike]] = None,\n num_mipmap_levels: Optional[int] = 5,\n tiling: bool = False,\n name: Text = 'mipmap_map_texture'\n ) -\u003e tf.Tensor\n\nThe convention we use is that the origin in the uv-space is at (0, 0), u\ncorresponds to the x-axis, v corresponds to the y-axis, and the color for each\npixel is associated with the center of the corresponding pixel. E.g. if we\nhave a texture \\[\\[1, 2\\], \\[3, 4\\]\\], then the uv-coordinates that correspond to\nthe values 1, 2, 3, and 4 are (0.25, 0.75), (0.75, 0.75), (0.25, 0.25),\n(0.75, 0.25), respectively. You can see that the v-axis starts from the bottom\nof the texture image as would be in cartesian coordinates and that by\nmultiplying the uv-coordinates with the length of the texture image, 2, you\ncan recover the pixel centers in this case, e.g. (0.25, 0.25) \\* 2 = (0.5, 0.5)\ncorresponds to the bottom-left pixel color that is 3.\n\nIf the aspect ratio of the texture is not 1, the texture is compressed to fit\ninto a square.\n\nNote that all shapes are assumed to be static.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ---- ||\n|---------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `uv_map` | A tensor of shape `[A1, ..., An, H, W, 2]` containing the uv coordinates with range \\[0, 1\\], height H and width W. |\n| `texture_image` | An optional tensor of shape `[H', W', C]` containing the texture to be mapped with height H', width W', and number of channels C of the texture image. |\n| `mipmap_images` | Optional list containing the original texture image at multiple resolutions starting from the highest resolution. If not provided, these are computed from texture_image and hence, texture_image needs to be provided in that case. If both texture_image and mipmap_images are provided, mipmap_images are used and texture_image is ignored. |\n| `num_mipmap_levels` | An optional integer specifying the number of mipmap levels. Each level is computed by downsampling by a factor of two. If mipmap_images is provided, num_mipmap_levels is comptued as its length. |\n| `tiling` | If enabled, the texture is tiled so that any uv value outside the range \\[0, 1\\] will be mapped to the tiled texture. E.g. if uv-coordinate is (0, 1.5), it is mapped to (0, 0.5). When tiling, the aspect ratio of the texture image should be 1. |\n| `name` | A name for this op that defaults to \"mipmap_map_texture\". |\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 `[A1, ..., An, H, W, C]` containing the interpolated values. ||\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Raises ------ ||\n|--------------|------------------------------------------------------------------------|\n| `ValueError` | If texture_image is too small for the mipmap images to be constructed. |\n\n\u003cbr /\u003e"]]