API

Function GetTextureDataAsync

  • Gets the pixel data of the specified texture, either by reading it directly or by rendering it to an intermediate RGBA texture and retrieving the bytes from it. This is convenient to get 8-bit RGBA values for a texture in a GPU compressed format. When direct readback returns non-RGBA channel layouts, the result is normalized to RGBA8.

    Parameters

    • texture: BaseTexture

      the source texture

    • Optionalwidth: number

      the target width of the result, which does not have to match the source texture width

    • Optionalheight: number

      the target height of the result, which does not have to match the source texture height

    • face: number = 0

      if the texture has multiple faces, the face index to use for the source

    • lod: number = 0

      if the texture has multiple LODs, the lod index to use for the source

    • forceRTT: boolean = false

      if true, forces the use of the RTT path for reading pixels (useful for cube maps to ensure correct orientation and gamma)

    • slice: number = 0

      if the texture is 3D, the depth slice index to use for the source

    Returns Promise<Uint8Array<ArrayBufferLike>>

    the 8-bit texture data