Posting a wild one out there...


Trp. Jed
04-14-2004, 02:49 AM
O.K, chance of anyone knowing the answer to this is slim but it never hurts to ask...

Had a request to add support for the models from the PS2 version of Half-Life. Seems the files are standard MDL's (with a DOL extension) but the textures are shown all screwed up.

Bit of hacking with the old hex editor reveals that the actual textures inside PS2 version are stored differently.

In regular Half-Life you just get the image data then the palette but in the PS2 version theres a 32 byte header, the palette then the image. Oh and the palette has 4 bytes per pixel instead of the normal 3.

Now from what I can seem the actually image data is fine, its not compressed or anything wierd but the palette, when extracted, is really rough! Its as if the textures as 16 colour, let alone 16 bit.

I've poured over it for hours but it's got me stumped this one. I know the PS2 uses a technique called "Texture Swizzling" to optimise textures to obtain maximum bandwidth throughput on the graphic bus but these don't appear to be Swizzled.

Anyone know anything a PS2 image formats and want to hazard a guess?! :confused: :confused: :confused:

- Jed

Cheeto
04-14-2004, 08:52 AM
Errr, well maybe it interpolates colors into the pallete via hardware just before it's rendered? So it takes the few colors on the pallette and adds some shades and blends between each one to up the color count?

Trp. Jed
04-14-2004, 12:55 PM
Hmm I thought about something like that. I've been pooring over the specs for swizzled image formats but so far nothings smacked me in the face as obvious. Ah well, trial and error I guess - have to go through all the formats and see which one works.

- Jed

Faceman
04-15-2004, 08:40 PM
Did you download the MDLs of the PS2 models or are you extracting them from the PS2 game disc?

Cheeto
04-15-2004, 08:41 PM
I think those models use the Blue Shift textures, Face.

Faceman
04-15-2004, 08:49 PM
I have no idea. They were on a website ages ago and said they were from the PS2 game. That's all I know.

Cheeto
04-15-2004, 08:49 PM
Well I'm pretty sure they are from the PS2 version, but I think the textures were nicked from the HD pack.

Faceman
04-15-2004, 09:01 PM
Could give this a shot: http://geocities.com/chrisplaystation/imagestudio/

Trp. Jed
04-15-2004, 10:28 PM
Apparently these models are from the PS2 CD. Their extracted from the .PAK files on the disk and the MDL files have the extension DOL.

They are MDL files, however the image format inside them is different hence, stock HLMV cant show the textures properly. I'm pretty sure the textures are swizzled, I just need to work out what factoring was used.

- Jed

Faceman
04-16-2004, 01:30 AM
Are they high res compared to HL now?

Podunkian
04-16-2004, 02:56 AM
Maybe the fourth byte is for Alpha. Probably not though, huh.

Maybe it'd be easier to decode if you uploaded a texture or so. It's a lot easier to understand than trying to explain it from text, don't you think?

Trp. Jed
04-16-2004, 11:40 AM
Face, compared to HL1 their not Hi-Res as far as the actual image data is concerned. The only difference is that all the textures are power-of-2 which some of the original HL1 arent. I'm assuming this is to maximise the efficiency of the 32-bit graphic pipeline in the PS2.

Pod, I'll post some files soon-ish. I just need to pull the relevant parts out.

Quick summary - the MDL files on both PC and PS2 are the same EXCEPT for the texture data.

It appears though that the textures themselves are the same size in many cases (width/height) but the palette (CLUT) data is different and there is a small header attached to the PS2 versions.

- Jed

Trp. Jed
04-17-2004, 09:23 AM
Solved it. :)

PS2 MDL files are stored as 8-bit with a CSM1 format palette. Normal PC files are CSM2. Basically CSM2 format lists the colours 00 - n, CSM1 uses data arranged in 16 byte blocks which goes something like:
00 - 07, 10 - 17
08 - 0f, 18 - 1F
20 - 27, 30 - 37
28 - 2F, 38 - 3F

and so on and so forth...

I had to write a small function to tell it how to find the correct colour in the palette to fix it in the end:


int StudioModel::UnCSM1CLUT (int idx)
{
int n = idx;

// move N to the correct pointer in the CSM1 format CLUT
if((n & 31)>=8) {
if((n & 31)<16) {
n += 8;
} else if((n & 31)<24) {
n -= 8;
}
}

return n;

}


Nothing very exciting but at least HLMV will support PS2 DOL models from Half-Life in the next version.

- Jed

Day of Defeat Forum Archive created by Neil Jedrzejewski.

This in an partial archive of the old Day of Defeat forums orignally hosted by Valve Software LLC.
Material has been archived for the purpose of creating a knowledge base from messages posted between 2003 and 2008.