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 > Transparent textures

#155178 - ZeroSum - Sat Apr 26, 2008 1:25 am

I'm having some trouble using transparent textures. I searched around a bit and found out about the GL_TEXTURE_COLOR0_TRANSPARENT option but now I have a slightly different problem as described below. I've uploaded a few pictures to help my probably crappy explanation: :)

Without GL_TEXTURE_COLOR0_TRANSPARENT:
Link

With GL_TEXTURE_COLOR0_TRANSPARENT:
Link

The scene is just three quads. One untextured at the back which covers the screen, one textured with a building on the left and one textured with ground on the right. As you can see the building texture is transparent on the "inside" as well as around it. The transparent areas on the inside of the building are supposed to be black.

All of my textures are 16 colour with palettes with magenta (FF00FF) as the wanted transparent areas. I used Nomad NDS Texture Converter to convert the images. When exporting I ticked the option for a transparent colour and selected magenta.

I have a feeling that when I do this Nomad is just turning on the "this pixel is transparent bit". When loading the textures without the GL_TEXTURE_COLOR0_TRANSPARENT flag the wanted area is "transparent" as in there is no magenta, but of course it's not see through. I then found I needed to set that flag and it has worked for the right hand texture but not the left.

I'm guessing that for the building on the left black is the first colour (in position 0) in the palette so its making this transparent as well as the pixels marked with the transparent bit.

If this is the case can anyone recommend a texture converting tool where I can choose the palette order myself or one that will put a chosen colour as the first in the palette? I have gfx2gba but I'm unsure if this can do textures or what options to use.

Thanks for reading.

PS. If someone could provide a link about or a brief explanation on how textures are formatted for the DS I would like to try writing my own converter for the experience.

#155206 - Sausage Boy - Sat Apr 26, 2008 4:14 pm

Gbatek is _the_ texture format reference:
http://nocash.emubase.de/gbatek.htm#ds3dtextureformats

texmex does transparency automagically with the image alpha channel, so all palette stuff is handled internally.
http://blog.dev-scene.com/gaspcubed/2007/10/06/texmex-004/
_________________
"no offense, but this is the gayest game ever"

#155237 - TwentySeven - Sun Apr 27, 2008 1:03 am

If you're going to write your own, microsoft has a really nice open-source octree palette and quantizer that I use in my current project.

Having palette code that can natively work with 6 bit colours produces WAAAAY better results then stuff that does the 8bit to 6bit conversion as a final step.