Textures with color key transparency

I am working with a set of textures that uses Black (0,0,0) as transparent (color keyed). Is there any way I can get panda to recognize that color 0 is transparent? I’m trying to avoid adding alpha channels to all these textures.

No, sorry, black is black, and transparent is transparent. If you want to have transparency in your textures, you will have to write an alpha channel.

It’s not difficult to write a program that will add an alpha channel automatically, making the texture transparent where the RGB is (0, 0, 0). For instance, you could write a program like this:

from pandac.PandaModules import *

def chromakey(filename, key_r = 0, key_g = 0, key_b = 0):
    image = PNMImage(Filename(filename))
    image.addAlpha()
    
    for y in range(image.getYSize()):
        for x in range(image.getXSize()):
            if image.getRedVal(x, y) == key_r and \
               image.getGreenVal(x, y) == key_g and \
               image.getGreenVal(x, y) == key_b:
                # Transparent
                image.setAlpha(x, y, 0.0)
            else:
                # Opaque
                image.setAlpha(x, y, 1.0)
                
    image.write(Filename(filename))

chromakey('myImage.png')

David