Dynamic alpha textures

Is it possible to load an RGB texture and attach an alpha channel without recreating the texture?

I’ve got 500 source textures which all have to be drawn with an alpha channel, for transitions, and generally, every texture is drawn with almost every mask. Storing them statically would require 4000 textures. Creating them on-the-fly would require a lot of cpu cycles & texture bandwith as well as system memory.

Do you need to have the alpha of individual textures vary over the texture? It sounds like maybe you don’t, but I’m not quite sure from your description. If for instance, you need to have a single texture where the alpha value over the whole texture is the same and can be easily changed, you can just use GL_MODULATE for glTexEnv, and then give an alpha to the polys you are putting the texture on.

I’ve got a set of terrain textures (RGB) and a set of masking textures (8-bit, only alphas).

I need to use texture X with mask A in such a way that if they were combined as a single RGBA texture, texture X would define the color and mask A would become the alpha channel.

However, the next tile could use texture X with mask B. I want to be able to easily swap out mask A and have B take it’s place without having to have 2 pregenerated copies in memory or having to manually combine them & upload them when used.

Ahh… I see. My suggestion won’t work for you then. Perhaps you could use multi-texturing extensions. I have to admit, that is one thing I haven’t worked with much yet, so I’m not sure if that would help you or not.

Yep, multitexturing is what is needed here. A combine or crossbar extension is perfectly suited for this.

Thanks, I think I know what to do now.