Sign in to follow this  

Changing the color of sprites

Recommended Posts

Binary1010    103
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
MasterWorks    496
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this