Sign in to follow this  

Sprite masking

Recommended Posts

I have been working with sprites and directX. I understand that the sprite works with the keyColor that becomes transparent and that is how you get the sprite. My question is does anyone know of another format or way to process these sprites without having to use .bmp format? As the game grows so does the number of sprites and in the .bmp format the space neccessary is growing to fast. I tried switching over to .jpg and the code works fine but when you save a .bmp into a .jpg format you loose some quality. Normally its unnoticable by the human eye but for sprites and masking you see it right away. The .jpg format tries to blend the background color to the sprites main image so thus you don't get the crisp sprite you want. Any ideas? The game is 2D isometric so upgrading to 3D models and more advanced DirectX I am hoping to avoid.

Share this post

Link to post
Share on other sites
Most modern applications dont use colorkeys but alpha channels. Also, JPG is a bad thing, instead try using the DDS format which is designed to be decompressed on the hardware...also it can maintain much crisper alpha channel masks which mean better looking sprites.

To use the alpha channel properly you should set some render states :


normally you would sett texture filtering to POINT but setting filtering on the texture is possible, but then for a crisp edge you will need to use :

device->SetRenderState(D3DRS_ALPHAREF, (DWORD)128);

Also, have you tried to make sure that you pack as many sprite frames on to single textures as possible?

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