Jump to content
  • Advertisement
Sign in to follow this  
Binary1010

Changing the color of sprites

This topic is 4634 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

Is there any way in C++ DirectX to draw a sprite with a color different than the one shown in the bitmap file? For example, if a particular region of a sprite was red, could I draw that sprite with said region colored blue instead?

Share this post


Link to post
Share on other sites
Advertisement
I don't think there's a way to do exactly what you want. You CAN subtract colors from any image by using the diffuse component of the vertices. For instance, if you set the vertex colors to red and then render an American flag, you will only see the parts that have red in them.

The best way -I- know to do what you're asking is to use two passes. If you have a character that you want to have any color shirt, for instance, you could have two different images:

-The guy with no shirt, with all colored areas remaining black (or grayscale)
-The shirt itself, which is all white in your texture, and then use your vertices to determine the actual color of the shirt.

You might want to use additive blending, then you can get specular highlights and shading through from the first layer. It looks good, I've tried it!

Hope that helps...

Share this post


Link to post
Share on other sites
I assumed you were using D3D for sprites/2d stuff... are you using DirectDraw? If so, you're not going to find much hardware support for alpha blending.

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!