Texture: Difference between revisions
Updated information on PS3 textures.
(Updated information on PS3 textures.) |
|||
Line 1:
Textures are images used in-game, generally either displayed directly or applied to a model. In Burnout Paradise, their format differs heavily between platforms. Despite this, they generally use variations of the same codecs—DXT1, DXT5 and A8R8G8B8. mipmaps are used systematically throughout the game as well.
== PlayStation 3 ==
The majority of this information is from the SCE PS3 SDK: CellGcmTexture datatype reference, though Burnout's debugging symbols were also referenced.
=== renderengine::Texture ===
{| class="wikitable"
! Offset !! Size !! Type !! Name !! Description
|-
| 0x0 || 0x1 || uint8_t || m_format || Texture format || See [[#Format | format]]
|-
| 0x1 || 0x1 || uint8_t || m_mipmap || Number of mipmap levels (1-13) || Sum of the maximum number of mipmap levels for the texture + 1
|-
| 0x2 || 0x1 || uint8_t || m_dimension || Texture dimension ||
|-
| 0x3 || 0x1 || uint8_t || m_cubemap || Enable
|-
| 0x4 || 0x4 || uint32_t || m_remap || Method of ||
|-
| 0x8 || 0x2 || uint16_t || m_width || Width
|-
| 0xA || 0x2 || uint16_t || m_height || Height
|-
| 0xC || 0x2 || uint16_t || m_depth || Depth of texture (1-512) ||
|-
| 0xE || 0x1 || uint8_t || m_location || Location
|-
| 0xF || 0x1 || uint8_t || m_padding ||
|-
| 0x10 || 0x4 || uint32_t || m_pitch || Pitch size of texture ||
|-
| 0x14 || 0x4 || uint32_t || m_offset || Offset
|-
| 0x18 || 0x4 || void
|-
| 0x1C || 0x4 || Type || m_storeType || Store type ||
|-
| 0x20 || 0x4 || uint32_t || m_storeFlags || Store flags ||
|}
=== Format ===
Swizzling and normalization is not used in Burnout, so these flags are unused.
Below is the bitwise structure for the format field.
{| class="wikitable"
|-
! Bit !! Size !! Comments
|-
| 0 || 5 || Color
|-
| 5 || 1 || Swizzle
|-
| 6 || 1 || Normalization
|-
| 7 || 1 ||
|}
=== Remap ===
The remap order is only used when one of the following color formats is specified:
* CELL_GCM_TEXTURE_COMPRESSED_HILO8
* CELL_GCM_TEXTURE_COMPRESSED_HILO_S8
* CELL_GCM_TEXTURE_X16
* CELL_GCM_TEXTURE_Y16_X16
* CELL_GCM_TEXTURE_Y16_X16_FLOAT
These are not used in Burnout, so the remap field is unused.
Below is the bitwise structure for the remap field.
{| class="wikitable"
|-
! Bit !! Size !! Comments
|-
| 0 || 16 || Remap
|-
| 16 || 2 || Output
|-
| 18 || 2 || Output green element
|-
| 20 || 2 || Output red element
|-
| 22 || 2 || Output alpha element
|-
| 24 || 2 || Input blue element
|-
| 26 || 2 || Input green element
|-
| 28 || 2 || Input red element
|-
| 30 || 2 || Input
|}
=== Pitch ===
Pitch is the texture width multiplied by the bytes per texel. It must be specified when using linear texture formats or DXT compression. If the texture is swizzled or the DXT texture width is a power of 2, pitch is ignored. Otherwise, it must be 16 or more.
Burnout only uses textures with widths at powers of 2, so pitch is unused. However, if it becomes necessary to calculate pitch, the following formula may be used for DXT textures:
<code>pitch = floor((width+3)/4)* block_size</code>
Where <code>block_size</code> is 8 for DXT1 and 16 for DXT2 through DXT5.
= Enumerations =
== PlayStation 3 ==
Much of this information is from the SCE PS3 SDK: GCM Method Macros Overview, section 6.4: TextureFormat. Some information is also from the CellGcmTexture datatype documentation. Various other sources are used.
=== Color format ===
{| class="wikitable"
! Name !! Value !! Comments
|-
| CELL_GCM_TEXTURE_B8 || 0x81 || One 8-bit unsigned integer
|-
| CELL_GCM_TEXTURE_A1R5G5B5 || 0x82 || One 1-bit value and three unsigned 5-bit integers
|-
| CELL_GCM_TEXTURE_A4R4G4B4 || 0x83 || Four unsigned 4-bit values
|-
| CELL_GCM_TEXTURE_R5G6B5 || 0x84 || 5-bit, 6-bit, and 5-bit unsigned integers
|-
| CELL_GCM_TEXTURE_A8R8G8B8 || 0x85 || Four 8-bit unsigned integers
|-
| CELL_GCM_TEXTURE_COMPRESSED_DXT1 || 0x86 || 4x4 pixels compressed to 8 bytes
|-
| CELL_GCM_TEXTURE_COMPRESSED_DXT23 || 0x87 || 4x4 pixels compressed to 16 bytes
|-
| CELL_GCM_TEXTURE_COMPRESSED_DXT45 || 0x88 || 4x4 pixels compressed to 16 bytes
|-
| CELL_GCM_TEXTURE_G8B8 || 0x8B || Two 8-bit unsigned integers
|-
| CELL_GCM_TEXTURE_R6G5B5 || 0x8F || 6-bit, 5-bit, and 5-bit unsigned integers
|-
| CELL_GCM_TEXTURE_DEPTH24_D8 || 0x90 || One 24-bit fixed, and 8-bit dummy data
|-
| CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT || 0x91 || One 24-bit float, and 8-bit dummy data
|-
| CELL_GCM_TEXTURE_DEPTH16 || 0x92 || One 16-bit fixed
|-
| CELL_GCM_TEXTURE_DEPTH16_FLOAT || 0x93 || One 16-bit float value
|-
| CELL_GCM_TEXTURE_X16 || 0x94 || One 16-bit integer
|-
| CELL_GCM_TEXTURE_Y16_X16 || 0x95 || Two 16-bit integer
|-
| CELL_GCM_TEXTURE_R5G5B5A1 || 0x97 || Three 5-bit unsigned integers, and one 1-bit value
|-
| CELL_GCM_TEXTURE_COMPRESSED_HILO8 || 0x98 || Two unsigned 16-bit values compressed to two 8-bit values
|-
| CELL_GCM_TEXTURE_COMPRESSED_HILO_S8 || 0x99 || Two signed 16-bit values compressed to two 8-bit values
|-
| CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT || 0x9A || Four 16-bit float values
|-
| CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT || 0x9B || Four 32-bit float values
|-
| CELL_GCM_TEXTURE_X32_FLOAT || 0x9C || One 32-bit float value
|-
| CELL_GCM_TEXTURE_D1R5G5B5 || 0x9D || 1-bit dummy data, and three 5-bit unsigned integers
|-
| CELL_GCM_TEXTURE_D8R8G8B8 || 0x9E || 8-bit dummy data, and three 8-bit unsigned integers
|-
| CELL_GCM_TEXTURE_Y16_X16_FLOAT || 0x9F || Two 16-bit float values
|-
| CELL_GCM_TEXTURE_COMPRESSED_B8R8_G8R8 || 0xAD || Two pixels compressed in the YUV format to 32 bits
|-
| CELL_GCM_TEXTURE_COMPRESSED_R8B8_R8G8 || 0xAE || Two pixels compressed in the YUV format to 32 bits
|}
=== Swizzle flag ===
Swizzle can only be used when the width is not a power of two. Pitch must be specified.
{| class="wikitable"
! Name !! Value !! Comments
|-
| CELL_GCM_TEXTURE_SZ || 0x0 || Use the swizzle format
|-
| CELL_GCM_TEXTURE_LN || 0x20 || Use the linear format
|}
=== Normalization flag ===
{| class="wikitable"
! Name !! Value !! Comments
|-
| CELL_GCM_TEXTURE_NR || 0x0 || Normalize texture coordinates
|-
| CELL_GCM_TEXTURE_UN || 0x40 || Do not normalize texture coordinates
|}
=== Dimension ===
Depth textures cannot be 3D.
{| class="wikitable"
! Name !! Value !! Comments
|-
| CELL_GCM_TEXTURE_DIMENSION_1 || 1 || 1D texture
|-
| CELL_GCM_TEXTURE_DIMENSION_2 || 2 || 2D texture
|-
| CELL_GCM_TEXTURE_DIMENSION_3 || 3 || 3D texture
|}
=== CubeMapEnable ===
{| class="wikitable"
! Name !! Value !! Comments
|-
| CELL_GCM_FALSE || 0 || Disable
|-
| CELL_GCM_TRUE || 1 || Enable
|}
=== Location ===
{| class="wikitable"
! Name !! Value !! Comments
|-
| CELL_GCM_LOCATION_LOCAL + 1 || 1 || Local memory
|-
| CELL_GCM_LOCATION_MAIN + 1 || 2 || Main memory
|}
=== renderengine::Texture::Type ===
{| class="wikitable"
|-
! Name !! Value !! Comments
|-
| TYPE_NA || -1 ||
|-
| TYPE_1D ||
|-
| TYPE_2D ||
|-
| TYPE_3D ||
|-
|
|-
| TYPE_FORCEENUMSIZEINT || 0x7FFFFFFF ||
|}
|