How do they do it?
I know back then, a color was just a few pixels to change, now, there are massive bitmaps, ranging up to 512x512 in some modern RTS. I always wondered how they changed the team colors, obviously they arent using a seperate bitmap for each team. That would be so ineffecient. If anyone has any ideas please respond!
Probably render the armor as white and apply a light to it much like SpriteBatch drawing in XNA.
If we're talking OpenGL I think this could easily be done in a pixel shader.
Yes, I am trying to figure it out for my OpenGL game, do you know how?
I have a book about RTS game-development. Unfortunately for you, it's Direct3D. I haven't made it to shader programming yet, but I'm pretty sure you're looking for something like the following:
(but in GLSL rather)
Apparently they use the inverse alpha channel of the original texture, and fill it with a solid color (filling the empty places with the team color).
(but in GLSL rather)
float4 Main(float2 UV : TEXCOORD0, float shade : TEXCOORD1) : COLOR
{
float4 c0 = tex2D(unitTexture, UV);
float Inv = 1.0f - c0.a;
//Weigh pixel and team color using the alpha channel
float4 c1 = float4(c0.rgb * Inv + tmCol.rgb * c0.a, 1.0f);
//return Shaded pixel
return c1 * shade;
}
Apparently they use the inverse alpha channel of the original texture, and fill it with a solid color (filling the empty places with the team color).
[quote name='ileonte' timestamp='1303139653' post='4799919']
If we're talking OpenGL I think this could easily be done in a pixel shader.
Yes, I am trying to figure it out for my OpenGL game, do you know how?
[/quote]
Well, if you don't need anything translucent, then you could use the alpha channel and multiply it against the team colour in the pixel shader after disabling alpha blending
You could also do the team colors in fixed function by setting the polygon color to the team color and apply the texture as a decal. Where ever the texture is translucent, you will see the team color show thru
I'll tell you how we did it. Bind a "team color mask" texture which is zero where you don't want team color and 1 (or intermediary values if you want more control) where you do. In the pixel shaded read that texture value to determine team color contribution. The team color value is set as a uniform.
I'll tell you how we did it. Bind a "team color mask" texture which is zero where you don't want team color and 1 (or intermediary values if you want more control) where you do. In the pixel shaded read that texture value to determine team color contribution. The team color value is set as a uniform.
This is the same way we did it.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement