Advertisement

RTS Unit Coloration

Started by November 08, 2000 09:03 PM
5 comments, last by Yanroy 24 years, 1 month ago
Maybe this one should go in the tile based forum Maybe all my recent threads should. But anyway, I was wondering what the best way to colorize the different units in my RTS would be. You know, each team has a different color but the same general units? I was thinking of doing it real-time, but if I perform an if on every pixel of every image to change certain colors to the team color, it will probably have about 10fps... My next idea was to render (yes, I mean render as in 3D - Bryce 3D ) each image in all the possible colors... Thats a lot of images! Then I came up with bltting the image to a temporary surface, then doing a destination colorkey of the team color and bltting the whole surface with the actual team color (confused yet?). That is the best I have come up with yet, short of storing a copy of the images for each team. Which would use memory. I would like to hear some other ideas. If you type something wrong, its a typo. If you say something wrong, why isn''t it a speako? --------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming

You are unique. Just like everybody else.

Yanroy@usa.com

Visit the ROAD Programming Website for more programming help.

--------------------

You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
"Sensitivity is adjustable, so you can set it to detect elephants and other small creatures." -- Product Description for a vibration sensor

Yanroy@usa.com

Maybe you could calculate/manipulate the texture colors once at start-up at run time?

A different set of textures for each player then... hum
well you might be able to use only one solid color texture for each player and reference it for all the model polys that are player colored. That way its only like 8 (32 tops!) new textures. they should be small too being one color (if you use texture compression).

Abuse multitexturing?

If they''re 3D models, twiddle the textures, not the blitted image.

If you''re rendering the bryce models to create a tile set of 2d sprites, then create one for each color as you suggested.


...
you don''t want to blit, pixel twiddle, & reblit each guy every frame, that''d take forever!
- The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Advertisement
I am not sure if this is exactly what you mean, but you could store the units in one base color, called the "remapable" color. Let''s say you have 10 possible colors, your remap color could be an odd color like a pink or a bright green color, one you would never use again. Then that remap color changes based on whatever team color you have. So if one team is the blue color, and one is the red color, and your remap color is an odd red shade (253, 7, 3), when the GFX are loaded, the remap color is switched for the team color. Only that part of the unit changes to the team color from the actual GFX files color. I hope that helps and is even what you meant in asking that.

=====
Khaos
=====
One way to do it, if you''re using sprites, is to have for each frame, a base image and two alpha masks. The first alpha mask would control how the base image is combined with the team color. The second alpha mask would control how the image is combined with the surface that the unit is being blitted to. An advantage this has over simple color keying is that you can get more complex shading within the unit color.
The DigitalFX library by FAST Projects can do colorization on the fly. The library does not come free, but it is very fast and does a lot more than just colorizing.


Steve ''Sly'' Williams
Tools Developer
Krome Studios
Steve 'Sly' Williams  Monkey Wrangler  Krome Studios
turbo game development with Borland compilers
Check out this thread:

http://www.xgames3d.com/ubb/Forum15/HTML/000011.html
Advertisement
Hi

i do it like this:

1.lock the sprit surface
2.chech the colors for the "player''s color range" (a range of magenta in my case)
3.replace the "magent color" with the "curent player color"

....

i also do the blit and some other ops. (loke alpha shadow and glow) in the same loop in order to gain speed

I get about 25fps on average machines (800x600x16 P2/400)

But i do it all in ASM, dont know for C or other HLL

using sepparated bitmaps crossed my mind but its too much of a load for the RAM because i can have 8 players in my multiplayer game ...3D will not help a lot here but hardware accel blits can only i cant hope for a 128M video ram...as i have a lots of units and animations also

Bogdan
obysoft

This topic is closed to new replies.

Advertisement