#92119 - wickedtrickster - Tue Jul 11, 2006 6:02 pm
Hi everyone,
I searched the forum (and the web) on texture compression for the DS without success.
The only "working" example I found is from masscat:
http://forum.gbadev.org/viewtopic.php?t=8940
Does anyone has new information about texture compression ?
The problem seems to be that the texel data always refer to the first 4 index of the palette, with the last one always transparent. I would guess that somewhere else in VRAM there's data specifying which palette/offset to use for each 4x4 block of texel. Since memory seems to be always zeroed, it is normal that only the first 4 palette entry are used. If anyone has an "educated" guess where this information would be, I'll test it. In the mean time I will randomly search in VRAM :)
Thank you,
Ben.
(And sorry for the odd english, it's not my native language :)
#92156 - Sausage Boy - Tue Jul 11, 2006 9:29 pm
I believe in your theory, it makes lots of sense.
I wrote a compressor, tested it on masscat's code, and got output that at least resembled the image visible on the DS. I'll look into it tomorrow if I have the time.
_________________
"no offense, but this is the gayest game ever"
#92220 - wickedtrickster - Wed Jul 12, 2006 3:18 am
Okay, I was able to make a working example which use compressed texture. It is not final, but at least it display more than 4 colors :)
I don't know all the specification, I'll continue to work on this tomorrow. Currently, my compressed texture has texel information in VRAM_A, palette information in VRAM_E, and the palette offset information in VRAM_B (everything is at the start of each VRAM).
I'll post full source code later this week when I'll have a better understanding of the system.
#92275 - silent_code - Wed Jul 12, 2006 1:40 pm
maybe you ask the guy that makes quakeDS, he's made some experiments with texture compression (also on this forum - with images).
#92293 - masscat - Wed Jul 12, 2006 5:18 pm
Following wickedtrickster comments and some playing around, this is my understanding of how compressed textures work.
A compressed texture comprises the texels information (2bits per texel as described here), palette index information (a 16bit value per 4x4 texel block) and the palette (a number of 16bit colour values).
The palette index information gives the 4 palette entries that will be used for a 4x4 texel block. The palette is indexed as sets of four colour values and the index addresses pairs of colour values, i.e. colour values 1, 2, 3 and 4 have index 0, colour values 3, 4, 5 and 6 have index 1 etc. Therefore sets of colour values overlap (index 0 and index 1 share two colour values).
Since each texel block has a corresponding index value they can use the same set of four colour values.
Things I do not understand:
How to specify the location of the palette index information. With the texel data at the start of Texture Bank 0 the index information appears to be required at the start of Texture Bank 1.
The 2bit texel value of 11 is always transparent. So it appears that a texel block can only have 3 colour plus transparent.
#92303 - wickedtrickster - Wed Jul 12, 2006 6:21 pm
masscat wrote: |
Things I do not understand:
How to specify the location of the palette index information. With the texel data at the start of Texture Bank 0 the index information appears to be required at the start of Texture Bank 1.
The 2bit texel value of 11 is always transparent. So it appears that a texel block can only have 3 colour plus transparent. |
I'm still searching how to change the address of the palette index (if that's even possible).
As for the 11 being transparent, set bit 15 to 1 when setting the palette index if you don't want transparency:
palette_index = index | (1 << 15);
#92332 - masscat - Wed Jul 12, 2006 9:21 pm
Been moving the texel information around in memory and the palette index info is always 128K further in the the texture memory.
#92534 - Sausage Boy - Thu Jul 13, 2006 8:39 pm
Ok, my decompression tool is up and running! It converts masscat's demo thing properly, including alpha. I havn't tested with a proper image with palette index yet, but I think it'll work.
Download it at:
http://www.gasp.boxgamex.net/?p=4
_________________
"no offense, but this is the gayest game ever"