So, here's a way of using the same texture object for fullbrights as you use for the main texture. Neat for saving on texture memory, faster loading times, and may run faster if your hardware is able to figure out that it can cache the result of a texture lookup and reuse it rather than needing to do a second texture lookup.
I'm assuming that you've got multitexture and a minimum of 3 TMUs available. If neither of these apply you can still get the texture memory saving but you'll need to figure out the blend modes for yourself.
You'll also need to do more work yourself if you've got external textures or a legit use for BSP or MDL textures with an alpha channel.
On to the info.
First thing is that we build a second copy of d_8to24table; this one has an alpha channel of 0 for entries below 224 but it keeps the same r, g and b. Entries 224 and above are the same as your regular d_8to24table.
Then we use that as the palette when uploading a texture that has fullbright colours in it.
Finally when rendering, we set up our texture environment for these textures like so:
Code: Select all
// diffuse - regular texture
glActiveTexture (GL_TEXTURE0);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
// lightmap - optionally use GL_RGB_SCALE for overbrighting
glActiveTexture (GL_TEXTURE1);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
// fullbright
glActiveTexture (GL_TEXTURE2);
glTexEnvi (GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL);
Code: Select all
(tex * lm) * (1.0f - tex.a) + (fb.a * tex.rgb)