• Advertisement
Sign in to follow this  

Changing the color of sprites

This topic is 4450 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'm going to look into alpha blending (I'm working in 2D mind you), I think that's what I'm looking for. Thanks for the help!

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