MW2 textures

Binary formats and related hacking.

Moderator: Skyfaller

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

MW2 textures

Post by Skyfaller » Wed Jan 14, 2009 1:39 am

We have speculated on how textures are used in MW2. We are looking forward to making mods that involve textures. MechVM needs MW2 textures to look good. We have found hints on how it might work. Not knowing this hinders our progress.

Let this thread show how texturing works in MW2, at least for DOS!

Previous threads/posts dealing with this topic: 1, 2, 3, 4, 5
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
Col.Kell
House Steiner Archon
House Steiner Archon
Posts: 868
Joined: Sat Sep 27, 2008 7:44 am
Location: An Isolated Tennessee Valley.

Re: MW2 textures

Post by Col.Kell » Wed Jan 14, 2009 7:10 am

Okay, I do have a lead; specific XEL files that go on mechs and vehicles, are declared in the file "MW2_MAP2".
Vent_Texture.gif
Vent_Texture.gif (53.83 KiB) Viewed 5052 times
Similar to what the INCL command looks like inside the PRJ, there seems to be a list of "BMPJ" and "BMID" commands in the MW2_MAP2 file. BMPJ tells the sim what XEL file is used as the texture.
BMID, I'm not sure. I believe it may declare a shape that is used to paste or wrap the XEL file around n a mech. But that may not be the case, as these "shapes" are not found in the .WTB or mech .BWD file. I'll need to experemint with it some more.
MechWarrior 2: 31stCC
Image

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 textures

Post by Skyfaller » Wed Jan 14, 2009 7:32 am

Thanks!

I have stumbled upon the BMID and BMPJ tags before, but did not understand their potential importance. I'll investigate ...
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 textures

Post by Skyfaller » Sun Jan 18, 2009 2:02 am

The screenshot below proves that the same mech type can be in a single mission with different textures.
Attachments
mw2_002.png
mw2_002.png (22.27 KiB) Viewed 5031 times
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: MW2 textures

Post by quota4stupid » Sun Jan 18, 2009 2:32 am

It's not much, but this is what I've got to contribute:
* MW2_MAP1.BWD, MW2_MAP2.BWD and MW2_MAP3.BWD define the default texture associations. These can be overriden with mission specific map files - xxxxMAP1.BWD.
* The tag sequence in these files seems to be:
- One or more BMPJ tags (that identify the XEL files in MW2.PRJ, as Col Kell said)
- One of more sets of BMID BSEC & BMEN tags (gives the preceeding list of BMPJ tags an ID and other attributes)

* Tag formats:
0 - 3 : "BMPJ"
4 - 7 : Record size (always 20?)
8 - 9 : ID of a XEL file in the MW2.PRJ CEL folder.
10 + : Name of a XEL file (sans extension) in the MW2.PRJ CEL folder. Appears to be zero-terminated/padded??

0 - 3 : "BMID"
4 - 7 : Record size (always 12?)
8 - 9 : List ID?
10 - 11 : Always 0xffff?

0 - 3 : "BSEC"
4 - 7 : Record size.
8 - 9 : Associated BMID ID.
10 - 11 : Time, in 1/180th seconds?

0 - 3 : "BMEN"
4 - 7 : Record size
8 - 9 : Associated BMID ID.
10 - 11 : Type
Where type can be:
0 - Disable
1 - Enable
2 - One shot

* Respectively, these represent the 3dbitmap_prj, 3dbitmap_idlist, 3dbitmap_sec & 3dbitmap_enable WASM commands.
* Pretty sure that BSEC gives the delay in 1/180th seconds between multiple BMPJ tags (animation - ie: fire/explosions).
* Somehow the ID value maps the texture to specific geometry, but I'm not sure how (if at all) these relate to any values in the WTB files, though I suspect that they might actually
be hardcoded (checkout the DEM1MAP1.WLD file in the Mercs tools directory). There might be another level of indirection in here (ie: checking DEM1MAP.WLD, each mech camo
has a series of textures assigned to different ID ranges - somehow these ranges are then mapped to the geometry??).

All of this (like the rest of the work I've done decoding stuff) is based on hexdumps, the Merc tools doco and playing with WASM - I haven't tried changing any values and then
running the actual sim yet. I haven't been able to give this as much time as I would like to (since just after New Years I've been doing a programming project for my missus -
damn it! ;-))

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 textures

Post by Skyfaller » Sun Jan 18, 2009 2:57 am

Thanks, you are very helpful!

I confirm that every tag I've seen has a four-byte name, followed by the DWORD size. The file number in the BMPJ tags seems to be off by one.
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 textures

Post by Skyfaller » Sun Jan 18, 2009 3:49 am

Current theory:
  • The texture to be used must be defined for each polygon, which could be the unused marker stored at the start of each polygon. Using the BMPJ and BMID tags, this value could be mapped to a texture.
  • In addition to selecting a texture, texture coordinates are needed to define how to "wrap" the texture around the mesh. This Information could be stored in the vertices, and indeed there are two WORDs with previously unknown function.
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
quota4stupid
House Steiner Private First Class
House Steiner Private First Class
Posts: 81
Joined: Mon Dec 29, 2008 7:40 am
Location: Australia

Re: MW2 textures

Post by quota4stupid » Sun Jan 18, 2009 4:06 am

Additional:
* Yup, best I can tell *EVERY* BWD record/tag starts with FourCC type tag followed by DWORD size. In some cases tags are nested inside other tags (ie: the "CPGN" tag that defines mercs campaign parameters).
I believe that the main header ("BWD\0") follows this rule too - all other tags are nested inside it (this includes "REV\0" [the WASM version?] and "DTBL").
* I don't believe the file number is off by one - I believe that the "INDX" tables in MW2.PRJ start with an initial NULL record (all zeros). I believe this is why the record count fields in corresponding "SYMB" and
"INDX" sections are out by one (since the "INDX" record count includes the NULL record).
* As far as your texturing theory goes: yeah, that was pretty well what I've been assuming, but I'm not sure of the exact relationship between the poly field 0 and the BMID values, though I don't believe they'll
match directly (as I mentioned in my previous post, and which I think would be confirmed by the last screen cap you posted, I think there is an extra level of indirection inbetween somehow - otherwise you
couldn't have different camo patterns & insignias on the same mech chassis).

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 textures

Post by Skyfaller » Sun Jan 18, 2009 4:29 am

I don't know yet, but I think the BWD tags BMPJ and BMID would be sufficient as a level of abstraction, for exchanging mech insignias and camos, but it would mean that before every mech with a different set of textures, there would have to be BMID/BMPJ tags, and I don't recall seeing them, so you may be right.

(Edit: I don't think these are different camos - the seemingly different textures in the image above may be no more than a palette trick)
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

User avatar
Skyfaller
Clan 2nd MechWarrior
Clan 2nd MechWarrior
Posts: 991
Joined: Sat Apr 12, 2008 2:58 am
Location: Germany
Contact:

Re: MW2 textures

Post by Skyfaller » Sun Jan 18, 2009 7:05 am

In all cases, textures are stored in the CEL directory in the PRJ. But the format used by the textures differs:

31stCC, GBL, Mercenaries (DOS & Pentium editions): .XEL format
31stCC Macintosh: .XEL format
Titanium Trilogy: .TEX format and .XEL format
31stCC (3DFX, Matrox, ATI): .555 format

.XEL files are uncompressed images using 8-bit indexed colors. The header consists of only two WORDs giving horizontal and vertical texture size. There is no signature. The palette is stored in a separate file. Since this file is used in the sim, which uses 8-bit color index mode, the texture uses the level's current palette.

.TEX files have signature 1.22 at offset 0 and is an uncompressed image. Offset 6 and 8 store the horizontal and vertical image size in words. Offset Ah stores the number of color entries. These follow at offset Ch as tuples of four bytes. Decoding as BGRA with 8 Bit shows the logos in correct colors, but many other textures still look implausible. After the table, the texels follow as indices into the color table.

For offset 4, the values 0, 3, and 7 have been observed. It may be a bit mask, but so far its values escape explanation. While many images show wrong colors, others are flipped horizontally, for example, the Draconis Combine insignias, though that may be true for the Draconis Combine XEL files, too. The formula for the file size appears to be unaffected.

The .555 textures, like the .XEL files, have a header consisting of only horizontal and vertical size. Judging from the size, the file contains 16-bit for each pixel, red, blue, green and alpha channels. MW3 uses a different format with the same name.

(Currently working out the exact format for the .555 files, will update post after that)
Download MechVM

If you have problems with MechVM, please attach the files MechVM.cfg and install-report.txt from the folder where MechVM installed your game.

Post Reply