RTS player color trouble

Started by
5 comments, last by JHL 22 years, 3 months ago
In the rts engine I''m trying to make I want to get the color teal to be replaced by a color representing the player so you can tell whos units are whos. The unit graphics are sprites rendered using the directx 8 sprite interface. I didn''t have any problem with this when I was uses directdraw I just wrote a custom blit routine. But now I need to do it with 3d hardware and hopefully with out using a ton of memory. I thank you for any thoughts you might have.
Advertisement
Is it a single RGB color you want replaced, or a range of colors?
Dirk =[Scarab]= Gerrits
A single rgb at least but a range if possible. actually the color
0xffff00 but if possible everything from 0x010100 up to that but I''ll take what I can get.
In the old days most games (Starcraft, Doom etc) used palette conversions.



-------homepage - email
One rather easy way to implement this is to have your program create the different texture images for each color and then load each as a texture.

Another way to do it would involve changing the colorkey pixels alpha to zero. Then when you draw a sprite, draw a colored quad first and the sprite over it. The only problem with this is if you already had any transparency going on.
Dirk =[Scarab]= Gerrits
The problem with copying textures is I could have like 8 copys of a texture. Add that up for every frame of every animation and thats a hell of a lot of memory. And your other method wouldn''t work ether cause I already use the transparentsy.
You're using sprites, right? Here's an idea.

For each unit, you draw three images:
1 - Base color map
2 - Grayscale team color map
3 - Shading map

The first one, the base color map, can be explained as follows. Let's say you have your unit drawn. Using some program, break it down into HSB channels. Color the entire B channel with "middle gray" and save the resulting image. This image contains only color and saturation information.

The second one, the grayscale team color map, is really the alpha channel. Let's say you have a footman with a shield, and on that shield you have a large "X" that you want to be colored according to the team that footman is on. In this image, you leave the entire image black except for a large white "X" in the spot that the shield would be.

The third one, the shading map, is grayscale as well. This is the "B" channel from the aforementioned unit graphic.

To draw the unit, first draw a quad using the the base color map as a texture. Use a color key or alpha channel. Then draw a single-color quad (with vertex colors corresponding to the team colors) using the team color map as an alpha channel. This is your second rendering pass. For the third pass, draw the shading map using a multiplicative blend mode the same way you would a lightmap.

Hopefully, you can see what I'm envisioning here.

I know this sounds like a lot of work, but almost all of it except the drawing of the team color map could be automated, so I think it shouldn't be too difficult.

If you are using 3d models instead of sprites, then you can use the same multipass technique but with UV mapped "skins" instead of sprites.

Edited by - TerranFury on December 30, 2001 4:14:04 PM

This topic is closed to new replies.

Advertisement