gbadev.org forum archive

This is a read-only mirror of the content originally found on forum.gbadev.org (now offline), salvaged from Wayback machine copies. A new forum can be found here.

DS development > Transparency with RGB256 textures

#142051 - NeX - Wed Oct 03, 2007 10:38 pm

Is there any? If so, how do I set it up?
If I can get texture pixels transparent in this mode, get ready for SandScape3D. I'm doing it using a 32x32x32 array, if you're interested, with a 32x32 texture on 32 quads, layered. Should look quite interesting and whilst I can't get anything much up on the screen yet, the particle numbers being returned by the console indicate that it is working within expectated parameters. A stream of sand dropped from the top of the cube is capable of getting 56-64 grains of sand in the block as they fall.
_________________
Strummer or Drummer?.
Or maybe you would rather play with sand? Sandscape is for you in that case.

#142052 - Corsix - Wed Oct 03, 2007 10:48 pm

For paletted images, palette index 0 is transparent. For 16 bit images, the most significant bit, BIT(15), is the transparency bit.

#142109 - NeX - Thu Oct 04, 2007 3:48 pm

I've tried colour 0 and setting bit 15 in the colour palette... neither resulted in anything other than solid black.
_________________
Strummer or Drummer?.
Or maybe you would rather play with sand? Sandscape is for you in that case.

#142162 - Sausage Boy - Fri Oct 05, 2007 3:08 pm

You need to set bit 29 in TEXIMAGE_PARAM. I quote GBATEK

Quote:
40004A8h - Cmd 2Ah - TEXIMAGE_PARAM - Set Texture Parameters (W)

...
29 Color 0 of 4/16/256-Color Palettes (0=Displayed, 1=Made Transparent)
...


To do this with libnds, add GL_TEXTURE_COLOR0_TRANSPARENT like this:

Code:
glTexImage2D(0, 0, GL_RGB256, TEXTURE_SIZE_32, TEXTURE_SIZE_32, 0, TEXGEN_TEXCOORD | GL_TEXTURE_COLOR0_TRANSPARENT, (u8*)texture_bin);

_________________
"no offense, but this is the gayest game ever"

#142168 - NeX - Fri Oct 05, 2007 6:00 pm

Thanks!
_________________
Strummer or Drummer?.
Or maybe you would rather play with sand? Sandscape is for you in that case.