Texture:getPixels
EditCreates and returns a new Image
object with the current pixels of the Texture. This function is very very slow because it stalls the CPU until the download is complete. It should only be used for debugging, non-interactive scripts, etc. For an asynchronous version that doesn't stall the CPU, see Texture:newReadback
.
image = Texture:getPixels(x, y, layer, mipmap, width, height)
Arguments
Name | Type | Default | Description |
x | number | 0 | The x offset of the region to download. |
y | number | 0 | The y offset of the region to download. |
layer | number | 1 | The index of the layer to download. |
mipmap | number | 1 | The index of the mipmap level to download. |
width | number | nil | The width of the pixel rectangle to download. If nil, the "rest" of the width will be used, based on the texture width and x offset. |
height | number | nil | The height of the pixel rectangle to download. If nil, the "rest" of the height will be used, based on the texture height and y offset. |
Returns
Name | Type | Description |
image | Image | The new image with the pixels. |
Notes
The texture must have been created with the transfer
usage.
Multisampled textures can not be read back.
It is not currently possible to read back a texture view.