Changing the color of sprites

Started by
2 comments, last by MasterWorks 18 years, 5 months ago
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?
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...
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!
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.

This topic is closed to new replies.

Advertisement