-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathRE_Engine_TEX.bt
More file actions
239 lines (231 loc) · 5.75 KB
/
RE_Engine_TEX.bt
File metadata and controls
239 lines (231 loc) · 5.75 KB
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
//------------------------------------------------
//--- 010 Editor v9.0 Binary Template
//
// File: RE_Engine_TEX.bt
// Authors: Che, alphaZomega
// Version: 0.1.1
// Purpose: Parsing RE Engine textures
// Category: Modding
// File Mask: *.*
// ID Bytes: 54 45 58 00 // TEX
// History: from RE2_tex.bt
//------------------------------------------------
LittleEndian();
local uint32 i <hidden=true>, j <hidden=true>, mipWidth <hidden=true>, mipHeight <hidden=true>, mipSize <hidden=true>;
local float divisor <hidden=true> = 1;
local ubyte isNewVersion <hidden=1> = false;
typedef enum <UINT> {
UNKNOWN = 0,
R32G32B32A32_TYPELESS = 1,
R32G32B32A32_FLOAT = 2,
R32G32B32A32_UINT = 3,
R32G32B32A32_SINT = 4,
R32G32B32_TYPELESS = 5,
R32G32B32_FLOAT = 6,
R32G32B32_UINT = 7,
R32G32B32_SINT = 8,
R16G16B16A16_TYPELESS = 9,
R16G16B16A16_FLOAT = 10,
R16G16B16A16_UNORM = 11,
R16G16B16A16_UINT = 12,
R16G16B16A16_SNORM = 13,
R16G16B16A16_SINT = 14,
R32G32_TYPELESS = 15,
R32G32_FLOAT = 16,
R32G32_UINT = 17,
R32G32_SINT = 18,
R32G8X24_TYPELESS = 19,
D32_FLOAT_S8X24_UINT = 20,
R32_FLOAT_X8X24_TYPELESS = 21,
X32_TYPELESS_G8X24_UINT = 22,
R10G10B10A2_TYPELESS = 23,
R10G10B10A2_UNORM = 24,
R10G10B10A2_UINT = 25,
R11G11B10_FLOAT = 26,
R8G8B8A8_TYPELESS = 27,
R8G8B8A8_UNORM = 28,
R8G8B8A8_UNORM_SRGB = 29,
R8G8B8A8_UINT = 30,
R8G8B8A8_SNORM = 31,
R8G8B8A8_SINT = 32,
R16G16_TYPELESS = 33,
R16G16_FLOAT = 34,
R16G16_UNORM = 35,
R16G16_UINT = 36,
R16G16_SNORM = 37,
R16G16_SINT = 38,
R32_TYPELESS = 39,
D32_FLOAT = 40,
R32_FLOAT = 41,
R32_UINT = 42,
R32_SINT = 43,
R24G8_TYPELESS = 44,
D24_UNORM_S8_UINT = 45,
R24_UNORM_X8_TYPELESS = 46,
X24_TYPELESS_G8_UINT = 47,
R8G8_TYPELESS = 48,
R8G8_UNORM = 49,
R8G8_UINT = 50,
R8G8_SNORM = 51,
R8G8_SINT = 52,
R16_TYPELESS = 53,
R16_FLOAT = 54,
D16_UNORM = 55,
R16_UNORM = 56,
R16_UINT = 57,
R16_SNORM = 58,
R16_SINT = 59,
R8_TYPELESS = 60,
R8_UNORM = 61,
R8_UINT = 62,
R8_SNORM = 63,
R8_SINT = 64,
A8_UNORM = 65,
R1_UNORM = 66,
R9G9B9E5_SHAREDEXP = 67,
R8G8_B8G8_UNORM = 68,
G8R8_G8B8_UNORM = 69,
BC1_TYPELESS = 70,
BC1_UNORM = 71,
BC1_UNORM_SRGB = 72,
BC2_TYPELESS = 73,
BC2_UNORM = 74,
BC2_UNORM_SRGB = 75,
BC3_TYPELESS = 76,
BC3_UNORM = 77,
BC3_UNORM_SRGB = 78,
BC4_TYPELESS = 79,
BC4_UNORM = 80,
BC4_SNORM = 81,
BC5_TYPELESS = 82,
BC5_UNORM = 83,
BC5_SNORM = 84,
B5G6R5_UNORM = 85,
B5G5R5A1_UNORM = 86,
B8G8R8A8_UNORM = 87,
B8G8R8X8_UNORM = 88,
R10G10B10_XR_BIAS_A2_UNORM = 89,
B8G8R8A8_TYPELESS = 90,
B8G8R8A8_UNORM_SRGB = 91,
B8G8R8X8_TYPELESS = 92,
B8G8R8X8_UNORM_SRGB = 93,
BC6H_TYPELESS = 94,
BC6H_UF16 = 95,
BC6H_SF16 = 96,
BC7_TYPELESS = 97,
BC7_UNORM = 98,
BC7_UNORM_SRGB = 99,
AYUV = 100,
Y410 = 101,
Y416 = 102,
NV12 = 103,
P010 = 104,
P016 = 105,
_420_OPAQUE = 106,
YUY2 = 107,
Y210 = 108,
Y216 = 109,
NV11 = 110,
AI44 = 111,
IA44 = 112,
P8 = 113,
A8P8 = 114,
B4G4R4A4_UNORM = 115,
P208 = 130,
V208 = 131,
V408 = 132,
FORCE_UINT = 0xffffffff
} DXGI_FORMAT;
typedef struct {
for (j = 0; j < Header.numMips; j++) {
struct {
if (i+j < (int)Header.numImages * (int)Header.numMips - 1)
FSeek(Header.MipHeaders.MipHeader[i+j+1].mipOffs);
else
FSeek(FileSize());
} Mip;
}
} IMG;
typedef struct {
mipWidth = Header.width;
mipHeight = Header.height;
mipSize = (mipWidth * mipHeight) / divisor;
local uint mipsCounter <hidden=true> = 0;
while ((mipWidth > 4 || mipHeight > 4) && mipsCounter < Header.numMips) {
struct {
local int MipWidth = mipWidth;
local int MipHeight = mipHeight;
local uint MipPitch = mipWidth * 4 / divisor;
local uint MipSize = mipSize;
for (i=0; i<Header.slices; i++)
FSkip(mipSize);
if (mipWidth > 4)
mipWidth = (int)(mipWidth / 2 + 0.5);
if (mipHeight > 4)
mipHeight = (int)(mipHeight / 2 + 0.5);
mipSize = (mipWidth * mipHeight) / divisor;
mipsCounter++;
counter++;
} Mip;
}
} CALCIMG;
struct{
char FourCC[4];
uint32 version;
isNewVersion = (version != 10 && version != 11 && version != 6 && version != 190820018);
uint16 width;
uint16 height;
ubyte slices;
ubyte uknByte;
if (isNewVersion) {
ubyte numImages;
ubyte mipHeaderSize <name="mipHeaderSize", bgcolor=0x000AF>;
local uint numMips = (int)(mipHeaderSize / 16);
} else {
ubyte numMips <bgcolor=0x000AF>;
ubyte numImages; //used by special textures like Stamp_00.tex and some cubemaps
}
DXGI_FORMAT format <bgcolor=0x00AF00>;
uint64 ukn;
ubyte streamingTexture;
ubyte uknByte, uknByte, uknByte; //base texture?
if (isNewVersion) {
uint32 uknInt;
ushort uknShort, uknShort;
}
struct {
for (i = 0; i < (int)numImages * (int)numMips; i++){
struct{
uint64 mipOffs <format=hex>;
uint32 pitch; //size/(2 to the power of mip's reverse order index) ACTUALLY WRONG
uint32 size;
} MipHeader;
}
} MipHeaders;
} Header;
if (Header.format == 28 || Header.format == 29 || Header.format == 80 || Header.format == 71 || Header.format == 72) //
divisor = 2;
FSeek(Header.MipHeaders.MipHeader[0].mipOffs);
struct {
for (i = 0; i < (int)Header.numImages * (int)Header.numMips; i += Header.numMips) {
if (i % Header.numMips == 0) {
if (i == 0)
IMG Image <open=true>;
else
IMG Image;
}
}
local int totalMips = (int)Header.numMips * (int)Header.numImages;
} ImageData;
//The same image data as above, but calculated:
FSeek(Header.MipHeaders.MipHeader[0].mipOffs);
local int counter <hidden=true> = 0;
struct {
for (j = 0; j < (int)Header.numImages; j++){
if (j == 0)
CALCIMG Calculated_Image <open=true>;
else
CALCIMG Calculated_Image;
}
local int totalMips = counter;
} Calculated_ImageData;