-
Notifications
You must be signed in to change notification settings - Fork 3
/
NTextureFormat.bt
265 lines (248 loc) · 7.25 KB
/
NTextureFormat.bt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
#ifndef _NTEXTUREFORMAT
#define _NTEXTUREFORMAT
struct STextureReadInfo
{
if (!isDKCTF)
{
byte index; //MP1R has this byte
}
uint32 offset <format=hex>;
uint32 size <format=hex>;
};
struct STextureCompressedBufferInfo(uint64 fileStart)
{
uint32 index;
uint32 offset <format=hex>; // Relative offset into associated STextureReadInfo
uint32 size <format=hex>; // Buffer size
uint32 destOffset <format=hex>; // Output offset when decompressed
uint32 destSize <format=hex>; // Output size when decompressed
// Compressed data
local uint64 pos <format=hex, hidden=true> = FTell();
FSeek(fileStart + info[index].offset + offset);
CompressionType compressionType;
byte pad[3] <hidden=true>;
byte data[size - 4] <bgcolor=cLtRed>;
FSeek(pos);
};
struct STextureMetaData(uint64 fileStart)
{
uint32 unk;
uint32 unk;
uint32 allocCategory;
uint32 gpuOffset <format=hex>;
uint32 align;
uint32 decompressedSize <format=hex>; // Total size decompressed
uint32 infoCount;
if (infoCount != 0) {
STextureReadInfo info[infoCount]<optimize=false>; //Do this so isDKCTF doesn't kill 010
}
uint32 bufferCount;
if (bufferCount != 0) {
STextureCompressedBufferInfo buffer(fileStart)[bufferCount] <optimize=false>;
}
};
enum <byte> ETextureWrap
{
TEXTURE_WRAP_CLAMP_TO_EDGE = 0,
TEXTURE_WRAP_REPEAT = 1,
TEXTURE_WRAP_MIRRORED_REPEAT = 2,
TEXTURE_WRAP_MIRROR_CLAMP = 3,
TEXTURE_WRAP_CLAMP_TO_BORDER = 4,
TEXTURE_WRAP_CLAMP = 5,
};
enum <byte> ETextureFilter
{
TEXTURE_FILTER_NEAREST = 0,
TEXTURE_FILTER_LINEAR = 1,
};
enum <byte> ETextureMipFilter
{
TEXTURE_MIP_FILTER_NEAREST = 0,
TEXTURE_MIP_FILTER_LINEAR = 1,
};
enum <byte> ETextureAnisotropicRatio
{
TEXTURE_ANISO_NONE = -1,
TEXTURE_ANISO_1 = 0,
TEXTURE_ANISO_2 = 1,
TEXTURE_ANISO_4 = 2,
TEXTURE_ANISO_8 = 3,
TEXTURE_ANISO_16 = 4,
};
enum /* where? */ ECompareFunction
{
TEXTURE_COMPARE_NONE = -1,
TEXTURE_COMPARE_NEVER = 0,
TEXTURE_COMPARE_ALWAYS = 1,
TEXTURE_COMPARE_NOTEQUAL = 2,
TEXTURE_COMPARE_LESS = 3,
TEXTURE_COMPARE_LEQUAL = 4,
TEXTURE_COMPARE_EQUAL = 5,
TEXTURE_COMPARE_GEQUAL = 6,
TEXTURE_COMPARE_GREATER = 7,
};
struct STextureSamplerData
{
uint32 unk;
ETextureFilter filter;
ETextureMipFilter mipFilter;
ETextureWrap wrapX;
ETextureWrap wrapY;
if (isDKCTF == 0)
{
ETextureWrap wrapZ;
ETextureAnisotropicRatio aniso;
}
};
enum <uint32> ETextureType
{
TEXTURE_1D = 0,
TEXTURE_2D = 1,
TEXTURE_3D = 2,
TEXTURE_CUBE = 3,
TEXTURE_1D_ARRAY = 4,
TEXTURE_2D_ARRAY = 5,
TEXTURE_2D_MULTISAMPLE = 6,
TEXTURE_2D_MULTISAMPLE_ARRAY = 7,
TEXTURE_CUBE_ARRAY = 8,
};
enum <uint32> ETextureFormat
{
TEXTURE_FORMAT_R8_UNORM = 0,
TEXTURE_FORMAT_R8_SNORM = 1,
TEXTURE_FORMAT_R8_UINT = 2,
TEXTURE_FORMAT_R8_SINT = 3,
TEXTURE_FORMAT_R16_UNORM = 4,
TEXTURE_FORMAT_R16_SNORM = 5,
TEXTURE_FORMAT_R16_UINT = 6,
TEXTURE_FORMAT_R16_SINT = 7,
TEXTURE_FORMAT_R16_FLOAT = 8,
TEXTURE_FORMAT_R32_UINT = 9,
TEXTURE_FORMAT_R32_SINT = 10,
TEXTURE_FORMAT_RGB8_UNORM = 11,
TEXTURE_FORMAT_RGBA8_UNORM = 12,
TEXTURE_FORMAT_RGBA8_SRGB = 13,
TEXTURE_FORMAT_RGBA16_FLOAT = 14,
TEXTURE_FORMAT_RGBA32_FLOAT = 15,
TEXTURE_FORMAT_DEPTH16_UNORM = 16,
TEXTURE_FORMAT_DEPTH16_UNORM_2 = 17, // ?
TEXTURE_FORMAT_DEPTH24_S8_UNORM = 18,
TEXTURE_FORMAT_DEPTH32_FLOAT = 19,
TEXTURE_FORMAT_RGBA_BC1_UNORM = 20, // DXT1
TEXTURE_FORMAT_RGBA_BC1_SRGB = 21, // DXT1
TEXTURE_FORMAT_RGBA_BC2_UNORM = 22, // DXT3
TEXTURE_FORMAT_RGBA_BC2_SRGB = 23, // DXT3
TEXTURE_FORMAT_RGBA_BC3_UNORM = 24, // DXT5
TEXTURE_FORMAT_RGBA_BC3_SRGB = 25, // DXT5
TEXTURE_FORMAT_RGBA_BC4_UNORM = 26, // RGTC1
TEXTURE_FORMAT_RGBA_BC4_SNORM = 27, // RGTC1
TEXTURE_FORMAT_RGBA_BC5_UNORM = 28, // RGTC2
TEXTURE_FORMAT_RGBA_BC5_SNORM = 29, // RGTC2
TEXTURE_FORMAT_RG11_B10_FLOAT = 30,
TEXTURE_FORMAT_R32_FLOAT = 31,
TEXTURE_FORMAT_RG8_UNORM = 32,
TEXTURE_FORMAT_RG8_SNORM = 33,
TEXTURE_FORMAT_RG8_UINT = 34,
TEXTURE_FORMAT_RG8_SINT = 35,
TEXTURE_FORMAT_RG16_FLOAT = 36,
TEXTURE_FORMAT_RG16_UNORM = 37,
TEXTURE_FORMAT_RG16_SNORM = 38,
TEXTURE_FORMAT_RG16_UINT = 39,
TEXTURE_FORMAT_RG16_SINT = 40,
TEXTURE_FORMAT_RGB10_A2_UNORM = 41,
TEXTURE_FORMAT_RGB10_A2_UINT = 42,
TEXTURE_FORMAT_RG32_UINT = 43,
TEXTURE_FORMAT_RG32_SINT = 44,
TEXTURE_FORMAT_RG32_FLOAT = 45,
TEXTURE_FORMAT_RGBA16_UNORM = 46,
TEXTURE_FORMAT_RGBA16_SNORM = 47,
TEXTURE_FORMAT_RGBA16_UINT = 48,
TEXTURE_FORMAT_RGBA16_SINT = 49,
TEXTURE_FORMAT_RGBA32_UINT = 50,
TEXTURE_FORMAT_RGBA32_SINT = 51,
TEXTURE_FORMAT_NONE = 52,
TEXTURE_FORMAT_RGBA_ASTC_4x4 = 53,
TEXTURE_FORMAT_RGBA_ASTC_5x4 = 54,
TEXTURE_FORMAT_RGBA_ASTC_5x5 = 55,
TEXTURE_FORMAT_RGBA_ASTC_6x5 = 56,
TEXTURE_FORMAT_RGBA_ASTC_6x6 = 57,
TEXTURE_FORMAT_RGBA_ASTC_8x5 = 58,
TEXTURE_FORMAT_RGBA_ASTC_8x6 = 59,
TEXTURE_FORMAT_RGBA_ASTC_8x8 = 60,
TEXTURE_FORMAT_RGBA_ASTC_10x5 = 61,
TEXTURE_FORMAT_RGBA_ASTC_10x6 = 62,
TEXTURE_FORMAT_RGBA_ASTC_10x8 = 63,
TEXTURE_FORMAT_RGBA_ASTC_10x10 = 64,
TEXTURE_FORMAT_RGBA_ASTC_12x10 = 65,
TEXTURE_FORMAT_RGBA_ASTC_12x12 = 66,
TEXTURE_FORMAT_RGBA_ASTC_4x4_SRGB = 67,
TEXTURE_FORMAT_RGBA_ASTC_5x4_SRGB = 68,
TEXTURE_FORMAT_RGBA_ASTC_5x5_SRGB = 69,
TEXTURE_FORMAT_RGBA_ASTC_6x5_SRGB = 70,
TEXTURE_FORMAT_RGBA_ASTC_6x6_SRGB = 71,
TEXTURE_FORMAT_RGBA_ASTC_8x5_SRGB = 72,
TEXTURE_FORMAT_RGBA_ASTC_8x6_SRGB = 73,
TEXTURE_FORMAT_RGBA_ASTC_8x8_SRGB = 74,
TEXTURE_FORMAT_RGBA_ASTC_10x5_SRGB = 75,
TEXTURE_FORMAT_RGBA_ASTC_10x6_SRGB = 76,
TEXTURE_FORMAT_RGBA_ASTC_10x8_SRGB = 77,
TEXTURE_FORMAT_RGBA_ASTC_10x10_SRGB = 78,
TEXTURE_FORMAT_RGBA_ASTC_12x10_SRGB = 79,
TEXTURE_FORMAT_RGBA_ASTC_12x12_SRGB = 80,
TEXTURE_FORMAT_BPTC_UFLOAT = 81,
TEXTURE_FORMAT_BPTC_SFLOAT = 82,
TEXTURE_FORMAT_BPTC_UNORM = 83,
TEXTURE_FORMAT_BPTC_UNORM_SRGB = 84,
};
enum <uint32> EMultiSample
{
MULTISAMPLE_NONE = 0,
MULTISAMPLE_2 = 1,
MULTISAMPLE_4 = 2,
MULTISAMPLE_8 = 3,
};
struct STextureHeader
{
ETextureType type;
ETextureFormat format;
uint32 width;
uint32 height;
uint32 layers;
uint32 tileMode; // ?
uint32 swizzle; // ?
uint32 mips;
uint32 mipSizes[mips] <format=hex>;
STextureSamplerData samplerData;
};
typedef struct
{
ChunkDescriptor chunk;
local uint64 start <format=hex, hidden=true> = FTell();
switch (chunk.id)
{
case "HEAD":
STextureHeader header;
break;
case "GPU ":
if (isDKCTF) {
CompressionType compressionType;
byte pad[3] <hidden=true>;
byte data[chunk.size - 4];
} else {
byte data[chunk.size];
}
break;
}
FSeek(start + chunk.size);
} TXTRChunk <
name=(Str("%s chunk", chunk.id))
>;
typedef struct(uint64 size)
{
local uint64 start <format=hex, hidden=true> = FTell();
while (FTell() < start + size)
{
TXTRChunk chunk;
}
} NTextureFormat <name="TXTR chunks">;
#endif// _NTEXTUREFORMAT