Change color of a bitmap for several players

Started by
4 comments, last by ms291052 18 years, 9 months ago
Hi, I am currently thinking about how to change the color of a part of a bitmap, so that (for example) one player has a red and another one a blue head without making two bitmaps on my harddrive. So i know how to change the color, if it is exactly one, but i'd like to have some kind of a "smooth" color area, so not "hardcore" red, more like red to orange and same with blue (blue to grey or something like that). How could i achieve this? Sorry, if this question has been asked before (it has, surely ;)), but forum search is disabled. Thx in advance! Metzler
Advertisement
I would personally go with some sort of weighting map that determines how the colours are blended.

For example, if you were to draw your regular "player skin" bitmap without any red/blue highlights... but then, either as a seperate image or in the alpha channel, place a value saying "how much player colour appears here" you could use that as a replacement multiplier.

So, if you had a solid stripe around the players neck (for example) that would have a "weight" of 1.0 (or 255) to indicate it appears completely red/blue. The few pixels that run alongside this stripe might have a "weight" of 0.75 (192) meaning that you get a slightly darker shade of red/blue.

The advantage of doing it this way is you would easily be able to put this into a pixel shader and have it generate any number of player colours "on the fly" and if you only generate the texture at load-time then it's also a fairly simple algorithm to implement.

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

Try indexed (palette) colors, and change palette entries when needed.
Is it DirectDraw? Because with Direct3D you can have a separate material for head (in a mesh).
I don't know how to do it with Direct3D.
You could modify the alpha value across the image. It may go from 25% to 80% transparency for instance, and you could draw the red or blue square behind the image first, then draw the image on top of it.
Chris ByersMicrosoft DirectX MVP - 2005
I like the idea with the alpha value. Do not need it anyway (until now ;)).

Thx for the replies!
One other idea is to use a grayscale image to determine the intensity of each color, then just render it using a MODULATE with TFACTOR. Or better yet, make life easier and use a shader.

This topic is closed to new replies.

Advertisement