Jump to content
  • Advertisement
Sign in to follow this  
Metzler

Change color of a bitmap for several players

This topic is 4863 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I like the idea with the alpha value. Do not need it anyway (until now ;)).

Thx for the replies!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!