Author Topic: 16 bit textures  (Read 19606 times)

fuchisasquatch

  • *
  • Posts: 111
    • View Profile
    • http://aa.1asphost.com/sasquatch/
16 bit textures
« on: 2004-08-16 09:10:05 »
I'm just mucking around and i put this TEX reader in my program and it works perfectly for 4/8 bit textures but i cant test it out on 16 bit textures cuz i cant find any.

So can anybody tell me if they know wheres some are..or even if there are any cuz im having a hard time finding any...

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
16 bit textures
« Reply #1 on: 2004-08-16 09:32:26 »
There were some, but where hmm ... maybe those FF8 opening screens, but they are in .lsz foromat so you have to unpack them first.

fuchisasquatch

  • *
  • Posts: 111
    • View Profile
    • http://aa.1asphost.com/sasquatch/
16 bit textures
« Reply #2 on: 2004-08-16 09:44:57 »
oh woops sorry...

i didnt specify which game i was talking about..i mean ff7..sorry bout that

Cyberman

  • *
  • Posts: 1572
    • View Profile
16 bit textures
« Reply #3 on: 2004-08-16 16:56:01 »
Quote from: fuchisasquatch
oh woops sorry...

i didnt specify which game i was talking about..i mean ff7..sorry bout that

Are you speaking of the PC or PS1 version.
For FF7 there are not 16 bit textures. There are 16bit TIMs that are the game change backgroundds.  I believe the intro ICON is also a 16 bit TIM as well.

Cyb

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
16 bit textures
« Reply #4 on: 2004-08-16 18:59:54 »
I can send you some 16 bit textures from FF8 if you want.

sfx1999

  • *
  • Posts: 1142
    • View Profile
16 bit textures
« Reply #5 on: 2004-08-16 22:21:37 »
FF7 uses 8-bit paletted textures, I think.

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
16 bit textures
« Reply #6 on: 2004-08-17 06:42:30 »
Can anyone help me with these 16 bit tex's ?
I know that they're in format BGR 5-5-5, but I don't really know how to read 5 bits from a word in Delphi. And I know it has something to do with shl operator :P. Can somebody help me ?

fuchisasquatch

  • *
  • Posts: 111
    • View Profile
    • http://aa.1asphost.com/sasquatch/
16 bit textures
« Reply #7 on: 2004-08-17 06:56:50 »
oh thanks..well i wouldnt have to worry about it then..

sfx1999

  • *
  • Posts: 1142
    • View Profile
16 bit textures
« Reply #8 on: 2004-08-17 17:25:48 »
Quote from: M4v3R
Can anyone help me with these 16 bit tex's ?
I know that they're in format BGR 5-5-5, but I don't really know how to read 5 bits from a word in Delphi. And I know it has something to do with shl operator :P. Can somebody help me ?


5-5-5 is 15-bit not 16-bit.

Anyway, you would use a bitshift. In C this would be done like this (if you use rgb and the last bit is empty):

Code: [Select]
Uint16 numberToBeRead
char r, g, b

r = (numberToBeRead & 1111100000000000) >> 11
g = (numberToBeRead & 0000011111000000) >> 6
b = (numberToBeRead & 0000000000111110) >> 1


What these lines do is this. Let's say your incoming value is this:

1110110110110010

(numberToBeRead & 1111100000000000) will turn it into this:

1110100000000000

When you bitshift that, you will get this:

0000000000011101

After everything, your result will be this:

r = 11101
g = 10110
b = 11001

This code may need to be modified on computers with a different endian format.

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
16 bit textures
« Reply #9 on: 2004-08-17 18:16:09 »
'>>' means bit shift ? In delphi, there's shr command for this I think. Thanks for responce, I'll try this.

Edit: Actually, the unused bit is last, but first one, so binary values must be diffrent, already got that trick.
But now, how to convert it to 16-bit BMP format, which uses 3 bytes to describe one pixel ? Each of these colors is an integer in range 0..31, and in BMP file each color has 0..255. How to convert it ? Multiplying by 8 gives a 248 max value (or 8 minimal value).

sfx1999

  • *
  • Posts: 1142
    • View Profile
16 bit textures
« Reply #10 on: 2004-08-17 20:44:17 »
Now that is going to be difficult. You might have to use a palette. I am unsure about how to do that.

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
16 bit textures
« Reply #11 on: 2004-08-17 20:46:17 »
In files that Texture Beast creates, there's no pallete. And for example, colors represented in tex as:
Code: [Select]
FF 7F

In BMP file that the program creates are:
Code: [Select]
FF FF FF

And so on...

sfx1999

  • *
  • Posts: 1142
    • View Profile
16 bit textures
« Reply #12 on: 2004-08-17 20:52:28 »
I mean a palette look-up system. You would have a table of the correct values for each 5-bit color and use them.

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
16 bit textures
« Reply #13 on: 2004-08-17 20:56:03 »
Nope, there's only raw data there. Here are example files: TEX file, BMP File

sfx1999

  • *
  • Posts: 1142
    • View Profile
16 bit textures
« Reply #14 on: 2004-08-17 21:00:10 »
I mean you could make a table of the right values manually.

Oh and I think the PSX uses BGR and not RGB.

Try multiplying the colors by 8. You are just going to have to accept the error for now.

Cyberman

  • *
  • Posts: 1572
    • View Profile
16 bit textures
« Reply #15 on: 2004-08-17 21:00:44 »
Quote from: sfx1999

5-5-5 is 15-bit not 16-bit.

Well actually it fits within 16 bits on a computer, unless the format is bit packed (which in this case would be plane silly and not all that useful). Hence it's 16bits even if only 15 bits are used.

Quote from: sfx1999
Anyway, you would use a bitshift. In C this would be done like this (if you use rgb and the last bit is empty):

Excessive Quoting Removed

What these lines do is this. Let's say your incoming value is this:

1110110110110010

(numberToBeRead & 1111100000000000) will turn it into this:

1110100000000000

When you bitshift that, you will get this:

0000000000011101

After everything, your result will be this:

r = 11101
g = 10110
b = 11001

This code may need to be modified on computers with a different endian format.

That's assuming if the data was MSB justified. If it's LSB justified all your shifts are wrong. Also if it's the playstation version then it's 1:5:5:5  Alpha:Blue:Green:Red. If not then one has to be sure what the format is.  Either way, it's data dependant isn't it?

Anyhow on subject in Delphi it's shr more importantly it depends on what the original data is. If it's the playstation data you will end up creating 32 bit pixels (RGBA or ABGR depending on how your system is).

In C++ I use this
Code: [Select]

RGBA TMain::BGRTORGBA(UINT16 Clr)
{
   RGBA Return;


   Return.Red =   (Clr & 0x1F) <<3;
   Return.Green = (Clr & 0x3E0) >>2;
   Return.Blue =  (Clr & 0x7C00)>>10;
   Return.Alpha =
      (((Clr & 0x8000)|| (Clr == 0))>0)?0xFF:0x00;
   return Return;
}


Cyb - Good fortune!

sfx1999

  • *
  • Posts: 1142
    • View Profile
16 bit textures
« Reply #16 on: 2004-08-17 21:03:24 »
I just said I was wrong. There textures are arranged 5 bits blue, 5 bits green, 5 bits red, and the extra bit.

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
16 bit textures
« Reply #17 on: 2004-08-17 21:04:00 »
I think Alhexx would help here, he writed Texture Beast so he knows this for sure. Alhexx, where are you ? :).

Cyberman

  • *
  • Posts: 1572
    • View Profile
16 bit textures
« Reply #18 on: 2004-08-18 02:09:45 »
Quote from: M4v3R
I think Alhexx would help here, he writed Texture Beast so he knows this for sure. Alhexx, where are you ? :).

What is Texture Beast?
Are you speaking of Ultima per chance?

sfx1999:
not really that big of a deal I wasn't beating on you or at least I wasn't trying to (needs to be qualified I suppose :D ).

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
16 bit textures
« Reply #19 on: 2004-08-18 07:01:26 »
I can help too, Biturn supports all the .TEX files aswell, and conversion to BMP too :)

if texture is in ARGB 1555 format it means that there is also alpha (transparency) information available; recalculation of the pixels into the RGBA 8888 format ( 4 bytes for a pixel ) would go like this:
Code: [Select]

alpha = original & 1;  //extract alpha bit
original >>= 1;        // remove bit from pixel, move all pixels to the right
red = original & 5;    // extract 5 bits for red
red = red * 8;         // 5 bits store value 0 - 31, so we multiply it to keep value 0 - 255  ( 0 - 248 )
original >>= 5;       // shift red out of the pixel
green = ( original & 5 ) * 8;
original >>= 5;       // shift green out of the pixel
blue = ( original & 5 ) * 8;


and there you have it. Sometimes alpha information is useless, so you can just ignore it. If the pixel is stored in reverse order ( RGBA 5551 ) then you have to reverse order of the actions in the code.

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
16 bit textures
« Reply #20 on: 2004-08-18 07:15:09 »
And what about white colour ?
31 * 8 = 248 = F8.
So with this type of conversion you can't get pure white ? But I saw FF FF FF pixels in bmp that Texture Beast created :).
Your program creates good files too.

Cyb: Texture Beast is a program to convert some formats to others, made by Alhexx. You can find it on his site.

mirex

  • *
  • Posts: 1645
    • View Profile
    • http://mirex.mypage.sk
16 bit textures
« Reply #21 on: 2004-08-18 08:39:56 »
well it depends ... if you want to make it to FF then multiply it by (255 / 31 ) = 8,2258 and then round it.
But maybe 248 is right value and it should be that way.

fuchisasquatch

  • *
  • Posts: 111
    • View Profile
    • http://aa.1asphost.com/sasquatch/
16 bit textures
« Reply #22 on: 2004-08-18 08:47:32 »
Nuh 248 is a greyish color. To see your self go into paint and put 248 in each R,G,B box. So it would surely screw up the colors of some images.

mav

  • *
  • Posts: 239
  • The Sauce team
    • View Profile
16 bit textures
« Reply #23 on: 2004-08-18 08:51:38 »
In Biturn, when you preview TEX file and then BMP file, you can notice brightness change. It's weird because Biturn produces files with GOOD colors, only in preview mode you can see that issue.

Links: TEX file under Biturn, BMP file under Biturn

fuchisasquatch

  • *
  • Posts: 111
    • View Profile
    • http://aa.1asphost.com/sasquatch/
16 bit textures
« Reply #24 on: 2004-08-18 08:56:40 »
hmm i was think of something like

(originalcolorval + 1) * 8

that would work for white..but yeah maybe itd screw up the other colors