Texture: Difference between revisions

3,993 bytes added ,  1 year ago
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.
== PS3 ==
 
=== TextureLayout ===
== 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 !! More Information !! Comments
|-
| 0x0 || 0x1 || uint8_t || m_format || Texture format || See [[#Format | format]]
| 0x0 || 0x1 || uint8 || format || "Texture format Refer to Table 30-3" || 0x81 = B8 || "Derived from enum renderengine::PixelFormat in pixelformat.h 0xA1-BF are the same but prefixed with LIN_ Bits 0-4 = Color Format Bit 5 = IsSwizzled (0 = swizzled, 1=linear) Bit 6 = IsNormalized (0 = normalized, 1=not normalized)"
|-
| 0x1 || 0x1 || uint8_t || m_mipmap || Number of mipmap levels (1-13) || Sum of the maximum number of mipmap levels for the texture + 1
| || || || || || 0x82 = A1R5G5B5 ||
|-
| 0x2 || 0x1 || uint8_t || m_dimension || Texture dimension || 0x83See =[[#Dimension A4R4G4B4 || dimension]]
|-
| 0x3 || 0x1 || uint8_t || m_cubemap || Enable ||or 0x84disable =cube R5G6B5mapping || See [[#CubeMapEnable | CubeMapEnable]]
|-
| 0x4 || 0x4 || uint32_t || m_remap || Method of || 0x85See =[[#Remap A8R8G8B8 || remap]]
|-
| 0x8 || 0x2 || uint16_t || m_width || Width || 0x86of =texture COMPRESSED_DXT1(1-4096) ||
|-
| 0xA || 0x2 || uint16_t || m_height || Height || 0x86of =texture DXT1(1-4096) ||
|-
| 0xC || 0x2 || uint16_t || m_depth || Depth of texture (1-512) || 0x87Always =1 COMPRESSED_DXT23in ||Burnout as 3D textures are not used
|-
| 0xE || 0x1 || uint8_t || m_location || Location ||of 0x87texture =data DXT3(main memory or local memory) || See [[#Location | location]]
|-
| 0xF || 0x1 || uint8_t || m_padding || || 0x88 = COMPRESSED_DXT45 ||
|-
| 0x10 || 0x4 || uint32_t || m_pitch || Pitch size of texture || 0x88See =[[#Pitch DXT5 || pitch]]
|-
| 0x14 || 0x4 || uint32_t || m_offset || Offset ||value from the base address of the 0x8Btexture =data G8B8location ||
|-
| 0x18 || 0x4 || void || * || m_buffer || 0x8F = R6G5B5 || Texture
|-
| 0x1C || 0x4 || Type || m_storeType || Store type || 0x90See =[[#renderengine::Texture::Type D24S8 || type]]
|-
| 0x20 || 0x4 || uint32_t || m_storeFlags || Store flags || 0x91 = D24S8F ||Seemingly unused
|}
 
=== 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
| || || || || || 0x91 = D24FS8 ||
|-
| 0 || 5 || Color ||format. See ||[[#Color format || 0x92 = D16 ||color format]]
|-
| 5 || 1 || Swizzle ||flag. See ||[[#Swizzle flag || 0x93 = D16F ||swizzle flag]]
|-
| 6 || 1 || Normalization ||flag. See ||[[#Normalization flag || 0x94 = R16 ||normalization flag]]
|-
| 7 || 1 || || || || 0x94 = X16 || Unused
|}
 
=== 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
| || || || || || 0x95 = G16R16 ||
|-
| 0 || 16 || Remap || || || 0x95 = Y16_X16 || order
|-
| 16 || 2 || Output || || || 0x97 = R5G5B5A1 ||blue element
|-
| 18 || 2 || Output green element
| || || || || || 0x98 = COMPRESSED_HILO8 ||
|-
| 20 || 2 || Output red element
| || || || || || 0x99 = COMPRESSED_HILO_S8 ||
|-
| 22 || 2 || Output alpha element
| || || || || || 0x9A = W16_Z16_Y16_X16_FLOAT ||
|-
| 24 || 2 || Input blue element
| || || || || || 0x9A = A16B16G16R16F ||
|-
| 26 || 2 || Input green element
| || || || || || 0x9B = W32_Z32_Y32_X32_FLOAT ||
|-
| 28 || 2 || Input red element
| || || || || || 0x9B = A32B32G32R32F ||
|-
| 30 || 2 || Input || || || 0x9C = R32F ||alpha element
|}
 
=== 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
| || || || || || 0x9C = X32_FLOAT ||
|-
| CELL_GCM_TEXTURE_A1R5G5B5 || 0x82 || One 1-bit value and three unsigned 5-bit integers
| || || || || || 0x9D = D1R5G5B5 ||
|-
| CELL_GCM_TEXTURE_A4R4G4B4 || 0x83 || Four unsigned 4-bit values
| || || || || || 0x9D = X1R5G5B5 ||
|-
| CELL_GCM_TEXTURE_R5G6B5 || 0x84 || 5-bit, 6-bit, and 5-bit unsigned integers
| || || || || || 0x9E = X8R8G8B8 ||
|-
| CELL_GCM_TEXTURE_A8R8G8B8 || 0x85 || Four 8-bit unsigned integers
| || || || || || 0x9E = D8R8G8B8 ||
|-
| CELL_GCM_TEXTURE_COMPRESSED_DXT1 || 0x86 || 4x4 pixels compressed to 8 bytes
| || || || || || 0x9F = Y16_X16_FLOAT ||
|-
| CELL_GCM_TEXTURE_COMPRESSED_DXT23 || 0x87 || 4x4 pixels compressed to 16 bytes
| || || || || || 0x9F = G16R16F ||
|-
| CELL_GCM_TEXTURE_COMPRESSED_DXT45 || 0x88 || 4x4 pixels compressed to 16 bytes
| || || || || || 0xFF = NA ||
|-
| CELL_GCM_TEXTURE_G8B8 || 0x8B || Two 8-bit unsigned integers
| 0x1 || 0x1 || uint8 || mipmap || Number of mipmap levels (1-13) || ||
|-
| CELL_GCM_TEXTURE_R6G5B5 || 0x8F || 6-bit, 5-bit, and 5-bit unsigned integers
| 0x2 || 0x1 || uint8 || dimension || Texture type || 0x1 = 1D texture ||
|-
| CELL_GCM_TEXTURE_DEPTH24_D8 || 0x90 || One 24-bit fixed, and 8-bit dummy data
| || || || || || 0x2 = 2D texture ||
|-
| CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT || 0x91 || One 24-bit float, and 8-bit dummy data
| || || || || || 0x3 = 3D texture ||
|-
| CELL_GCM_TEXTURE_DEPTH16 || 0x92 || One 16-bit fixed
| 0x3 || 0x1 || uint8 || cubemap || Cube map or not || || Effectively a bool
|-
| CELL_GCM_TEXTURE_DEPTH16_FLOAT || 0x93 || One 16-bit float value
| 0x4 || 0x4 || uint32 || remap || Remap of the color value || || Not described here as Burnout doesn't really remap
|-
| CELL_GCM_TEXTURE_X16 || 0x94 || One 16-bit integer
| 0x8 || 0x2 || uint16 || width || Width of texture (1-4096) || ||
|-
| CELL_GCM_TEXTURE_Y16_X16 || 0x95 || Two 16-bit integer
| 0xA || 0x2 || uint16 || height || Height of texture (1-4096) || ||
|-
| CELL_GCM_TEXTURE_R5G5B5A1 || 0x97 || Three 5-bit unsigned integers, and one 1-bit value
| 0xC || 0x2 || uint16 || depth || Depth of texture (1-512) || ||
|-
| CELL_GCM_TEXTURE_COMPRESSED_HILO8 || 0x98 || Two unsigned 16-bit values compressed to two 8-bit values
| 0xE || 0x1 || uint8 || location || Location of texture data (main memory or local memory) || 0x1 = local memory ||
|-
| CELL_GCM_TEXTURE_COMPRESSED_HILO_S8 || 0x99 || Two signed 16-bit values compressed to two 8-bit values
| || || || || || 0x2 = main memory ||
|-
| CELL_GCM_TEXTURE_W16_Z16_Y16_X16_FLOAT || 0x9A || Four 16-bit float values
| 0xF || 0x1 || uint8 || padding || || ||
|-
| CELL_GCM_TEXTURE_W32_Z32_Y32_X32_FLOAT || 0x9B || Four 32-bit float values
| 0x10 || 0x4 || uint32 || pitch || Pitch size of texture || || Width always seems to be a power of 2 in Burnout, so pitch is not described here
|-
| CELL_GCM_TEXTURE_X32_FLOAT || 0x9C || One 32-bit float value
| 0x14 || 0x4 || uint32 || offset || Offset value from the base address of the texture data location || ||
|-
| 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
| 0x18 || 0x4 || void * || buffer || || || PixelBuffer?
|-
| TYPE_NA || -1 ||
| 0x1C || 0x4 || Type || storeType || || 0xFFFFFFFF = NA ||
|-
| TYPE_1D || || || || || 0x1 = 1D1 ||
|-
| TYPE_2D || || || || || 0x2 = 2D2 ||
|-
| TYPE_3D || || || || || 0x3 = 3D3 ||
|-
| || || || || TYPE_CUBE || 0x10002 = CUBE ||
|-
| TYPE_FORCEENUMSIZEINT || 0x7FFFFFFF ||
| 0x20 || 0x4 || uint32 || storeFlags || || ||
|}