PDA

View Full Version : Masking to show player color....problem.


madmax
12-28-2006, 12:50 AM
OpenGL,Ortho,2D game:

Ok i have these units in my 2d game i want to display using various player colors.However the unit image is just 1 image.The pixels where player color should appear are known/marked out by a specific color.The unit image is displayed as a textured quad. I want to use only the unit image & say some mask to display any player color in the unit image.

So i thought the mask could be white only where player color should be present(black otherwise) & of same dimension as the unit image.

Now if i multiply a texture of dimensions=unit image but color=player color with mask, i will get a black image with the player color present in the exact positions i want them in the unit image. Now how to superimpose this image on the unit image to get the player colors there as well?.

Anyone has a better idea on how to do this whole thing? i want masks of 1 bit depth only.How to store such masks in video memory so they occupy 1 bit depth only...textures have to be 8bpp at least i think

Jare
12-28-2006, 04:25 AM
You have the right idea. Forget about bits and just make it work.

Reedbeta
12-28-2006, 11:59 AM
Just ensure that the unit image has black pixels in all the places where you want the player color to appear, and superimpose the (mask * color) using additive blending.

In fact, you could expand this, letting the mask be full grayscale rather than just black and white, which would let you make different lighter/darker shades of the player color. That could improve the appearance of things.