Page 1 of 1

LithTech dtx and calculating pixeldata size

Posted: Sun Feb 19, 2012 5:50 am
by finale00
I think these are lithtech dtx images anyways.
I used texturefinder and it looks like r8g8b8a8 format, but I don't know how to determine the size of the pixel data.

There should be only one texture in the ones I uploaded.

There are tools that convert these files to tga, but I haven't found any source for them.
In general, is there a way to calculate the size of the pixeldata if I have some idea what the pixel format is, as well as the dimensions of the image?

Re: LithTech dtx and calculating pixeldata size

Posted: Tue Feb 21, 2012 5:14 am
by finale00
After searching around, it looks like there are actually two similar formats for dtx.

I've confirmed that the pixel format is RGBA32 (for the ones I'm looking at anyways) and am just doing a rough "seek to pixel data start offset and read everything in"

Which isn't the right way to do it.

But it looks like a single dtx file may contain multiple images.

Re: LithTech dtx and calculating pixeldata size

Posted: Tue Feb 21, 2012 5:58 am
by Acewell
It looks like the image dimensions are at 0x8 and 0xA
80 = 128
40 = 64

CHANDELIER2.DTX = 128x128
THRONE.DTX = 128x128
VIALS.DTX = 64x64

Re: LithTech dtx and calculating pixeldata size

Posted: Wed Feb 29, 2012 3:42 pm
by finale00
It looks like not all images are rgba32, cause 4*height*width doesn't produce anything.

Re: LithTech dtx and calculating pixeldata size

Posted: Fri Apr 06, 2012 10:43 am
by finale00
Hmm, it looks like one format of the dtx works, but the other format doesn't.
I don't see that much of a difference between the two. What's the problem?

http://db.tt/jVR8Q8kr

Re: LithTech dtx and calculating pixeldata size

Posted: Fri Apr 06, 2012 7:48 pm
by Acewell
dh_c007_xunyegui.dtx seems to have the image dimensions at 0x1 and 0x3 instead of 0x8 and 0xA and was the only sample that worked with your import script.

01 = 256

dh_c007_xunyegui.dtx = 256x256

I'm not a programmer so i don't know how or if this would affect your code.

Re: LithTech dtx and calculating pixeldata size

Posted: Fri Apr 06, 2012 7:56 pm
by finale00
Ya, I've handled the cases where the dimensions are stored in different places.

I think it is my pixel format.
I mean, it works for some of them, but it doesn't work for the rest. It's like if I'm lucky, I'll just happen to get something.

Guess I'll have to spend some time reading about image formats.

Re: LithTech dtx and calculating pixeldata size

Posted: Sat Apr 07, 2012 2:05 am
by Acewell
The dtx plugin for Photoshop can open all of your samples except for dh_c007_xunyegui.dtx

Re: LithTech dtx and calculating pixeldata size

Posted: Sat Apr 07, 2012 2:32 am
by finale00
Lol that's amusing, cause those are the only ones I can open more often. I think there are mipmaps in there as well, and but that shouldn't be my issue atm. I was reading about dtx and some people distinguish between lithtech and nexon format, but I don't think they are that different.

Re: LithTech dtx and calculating pixeldata size

Posted: Sat Apr 07, 2012 4:32 am
by finale00
Oh what, I think I see the problem.

I said that each pixel is 32-bits for the RGBA, and assuming it is RGBA, all of the A values are 0.
Reading about alpha channel, it looks like 0 means it's completely transparent.

.......So maybe if I just specified RGB24 with a 4-byte stride it will work out! There's probably a value that indicates whether the alpha channel is used or not.

The other textures that actually worked didn't have all 0's for their alpha value, so that's probably why they showed up.

EDIT:

AND......

It works! Sort of. Some of the textures are still messed up, but at least it shows up now.
I just need to make it more efficient now...

Image

Now the other problem is that some of the pixels are compressed it seems.
Like, you have a 256x256 image, which is 65536 pixels so there should be at least that many bytes of data...but the entire file is like 43520 bytes.

Re: LithTech dtx and calculating pixeldata size

Posted: Wed Apr 11, 2012 7:05 pm
by finale00
Turns out the pixel format was BGR(A) and not RGB(A)
Lol was wondering why everything was so blue.

And it looks like DTXView can read the files.
Damn it I want to figure out what the pixel data is but not sure how to do so.

Re: LithTech dtx and calculating pixeldata size

Posted: Sat Jun 09, 2012 1:44 am
by WRS
is this the same format used in combat arms??

Re: LithTech dtx and calculating pixeldata size

Posted: Sat Jun 16, 2012 1:00 am
by finale00
I'm assuming all dtx formats are standard to the engine.
There seems to be an odd dtx format as well, mainly used for wall/floor textures. Couldn't figure that one out.