RTS Team Colour

Started by
7 comments, last by The Frugal Gourmet 17 years, 4 months ago
Hi, I'm just wondering what methods are used to do the team colour that you see on units and buildings in real-time strategy games? I'm working on a simply strategy game in DirectX and I'm just looking for different ways to do this. Does anyone have any pointers, or know any articles that talk about this? Thanks.
Advertisement
From what I remember of Warcraft 2, I think they did the team colours through palette colour shifting. Basically you use a palette, define a range of colours to be your "team colour" range, draw your sprites using those palette values only for what you want to change, and then modify what those colours are when you plot the sprites in software. I think the drawback is you may need to have a custom sprite drawing algorithm for that to work properly - I don't work with palettes anymore and I'm not that clued in on good methods for doing that in hardware.

The way I'd do this today using non-paletted sprites is to split the sprite up into two components - the team colour part and the non team colour part - and render those separately to the same point on the screen using the coloured part as a sort of overlay. You can use colour effect to tint the team colour parts to whatever colour you wish.
Hey, thanks for the reply, but I should have mentioned that I'm working in 3D. So I'm looking for ways to do this with meshes in 3D using a pixelshader or something like that. I know one common method is to use an alpha channel in the mesh's texture and then have a pixelshader blend the alpha component with the team colour component. I haven't tried this method, but I think a drawback is that you cannot then use the alpha channel for anything else like alpha-blending. Hence the reason why I'm looking into other methods.
A former roomate of mine used something similar to the alpha method you've described in the RTS he worked on. Instead of using the entire alpha-channel for transparancy he split it in two: 4 bits for team color, 4 bits for transparancy.

I'm not sure they were using Shaders for the run-time effect, I know they were using OpenGL however.

throw table_exception("(? ???)? ? ???");

I suppose what I would do is create my models in a way that they used two textures: one that is for the regions of the model that don't change depending on the team, and one that is for the colored region. Then, create a bunch of colored textures that all fit nicely, and then have the program choose the appropriate one at runtime.
Ah, reminds me of the good old days... I think I used a separate alpha texture to mark where the colour should be applied. Then I used that alpha to blend the object's colour with the texture factor. Far as I remember.
Hmmm... Yes, I've already thought of splitting the alpha channel, so I might investigate this further. I want to avoid multiple textures as it just consumes more resources. Thanks for all the comments so far.
If you don't use alpha for the objects, you can use it for that, with no need for another texture. It's still no big deal if you use it, IMO, since you should be able to use A8 for the format.
I've done this before using a Hue-Saturation-Intensity conversion in a pixel shader. I first convert from RGB to HSV. Then, I look for a particular hue range (the team color) to replace (eg. default is blue). If the pixel matches, I shift the hue to a particular destination hue (if not shader does no conversion). I then convert results back to RGB. With this method, I've been able to look for a team color range in any texture and replace with a destination color range.

The alpha channel idea actually sounds simpler, though. I only picked this method because I already had a hue-saturation-intensity shader for a few other color effects. It's a bit tricky because you must first recognize the hue shift necessary say to convert a series of blue shades to red, orange, green, etc.
Co-creator of Star Bandits -- a graphical Science Fiction multiplayer online game, in the style of "Trade Wars'.

This topic is closed to new replies.

Advertisement