Skip to content

Commit

Permalink
Add documentation for raw texture
Browse files Browse the repository at this point in the history
  • Loading branch information
Xeeynamo committed Dec 7, 2019
1 parent f0f8514 commit 0c82a23
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 1 deletion.
99 changes: 99 additions & 0 deletions docs/kh2/file/raw-texture.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# [Kingdom Hearts II](../../index) - Raw Texture

This is used by 3D models of Kingdom Hearts II to give them a texture.

The format holds low-level data to instruct the Playstation 2 where to store the texture in the VRAM and how the GPU should use it for rendering.

When GS is read, it refers to the Playstation 2 GPU.

## Header

| Offset | Type | Description
|--------|--------|-------------
| 0 | uint32 | Magic code. Always 0.
| 4 | int32 | Color count. How many individual colors are stored in the CLUT.
| 8 | int32 | [Texture info](#texture-info) count. 16 bytes aligned.
| 12 | int32 | [GS Info](#gs-info) count.
| 16 | int32 | [Offset data](#offset-data) count.
| 20 | int32 | [Texture info](#texture-info) offset.
| 24 | int32 | [GS Info](#gs-info) offset.
| 28 | int32 | Picture offset, where all the pixels are located. 128 bytes aligned.
| 32 | int32 | Palette offset, where the whole palette is located.

## Offset data

The offset data is tells what is the Texture Info associated to a specific GS Info.

The algorithm is `textureInfo = textureInfoTable[OffsetData[gsInfoIndex]]`.

## Texture info

This table is mostly unknown, but most of the data does not change anyway between textures. It is supposed to be used to interpret picture information on the process to upload them to the GS VRAM.

All the fields in the table are for unknown purpose unless specified.

| Offset | Type | Descriptor
|--------|--------|------------
| 0 | int32 | Always 0x10000006
| 4 | int32 | Always 0
| 8 | int32 | Always 0x13000000
| 12 | int32 | Always 0x50000006
| 16 | int32 | Always 4
| 20 | int32 | Always 0x10000000
| 24 | int32 | Always 14
| 28 | int32 | Always 0
| 32 | int32 | Always 0
| 36 | int32 |
| 40 | int32 |
| 44 | int32 | Always 0
| 48 | int32 | Always 0
| 52 | int32 | Always 0
| 56 | int32 | Always 0x51
| 60 | int32 | Always 0
| 64 | int32 |
| 68 | int32 |
| 72 | int32 | Always 0x52
| 76 | int32 | Always 0
| 80 | int32 | Always 0
| 84 | int32 | Always 0
| 88 | int32 | Always 0x53
| 92 | int32 | Always 0
| 96 | int32 |
| 100 | int32 | Always 0
| 104 | int32 | Always 0
| 108 | int32 | Always 0
| 112 | int32 |
| 116 | int32 | Picture offset, where the texture is stored
| 120 | int32 | Always 0
| 124 | int32 |
| 128 | int32 |
| 132 | int32 | Always 0
| 136 | int32 | Always 0x13000000
| 140 | int32 | Always 0

## GS info

This table is also unknown, but the few information found points to describe how the pictures stored into GS VRAM are supposed to be used by GS.

| Offset | Type | Descriptor
|--------|--------|------------
| 0 | int64 | Always 0x0000000010000008
| 8 | int64 | Always 0x5000000813000000
| 16 | int64 | Always 0x1000000000008007
| 24 | int64 | Always 14
| 32 | int64 | Always 0
| 40 | int64 | Always 0x3f
| 48 | int64 |
| 56 | int64 | Always 0x34
| 64 | int64 |
| 72 | int64 | Always 0x36
| 80 | int64 |
| 88 | int64 | Always 0x16
| 96 | int64 |
| 104 | int64 | Always 0x14
| 112 | int64 | [GS TEX0 register](../../common/tm2#gstex)
| 120 | int64 |
| 128 | int64 |
| 136 | int64 | Always 8
| 144 | int64 | Always 0x0000000060000000
| 152 | int64 | Always 0x0000000013000000
4 changes: 3 additions & 1 deletion docs/kh2/file/type/bar.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# [Kingdom Hearts II](../../index) - BAR (Binary ARchives)

Most of the game's information is stored within these files in order to keep everything organized and easily accessable by the game. These files are kind of like ZIP files, with certain limitations.

Those limitations include the file's limitations, like the 4 character file names, file types having to be declared within the header, not all file types being declareable, but it also includes PS2's limitations, like the offsets of the files within having to be divisible by 16, even though the size of the previous file is not, file names being unable to contain some characters, etc.

## BAR Structure

BARs can come in all shapes and sizes and forms. Some have the ".bin" extension, meaning it is a system file. Some have the ".mset" extension, meaning it is a moveset file. Some have the ".mdlx" extension, meaning it is a model file. However, no matter the type, it still follows the basic file structure of the BAR.

In this structure, the names do not matter. They can be whatever as long as the PS2 is OK with it. They are just there in order to identify what file it is. This may or may not be the case in 03system, however.
Expand Down Expand Up @@ -89,7 +91,7 @@ Keep in mind that this list is still incomplete and will be changed over the cou
| 4 | 3D Model data (Encapsulated VIF packets containing Vertices, Skinning, Bones for MDLX, etc.) | MDLX - MAP
| 5 | Mesh Occlusion/Obstruction (Probably Culling) | MAP
| 6 | Map Collision Data | MAP
| 7 | RAW(TIM2) Texture Data | MDLX - MAP
| 7 | [RAW Texture](../raw-texture) | MDLX - MAP
| 8 | DPX (A bit unknown) | PAX
| 9 | Animation Data | ANB
| 10 | Texture Data | MAP - minigame/xxx.bar
Expand Down

0 comments on commit 0c82a23

Please sign in to comment.