Jump to content
  • Advertisement
Sign in to follow this  
Tanish1

Sprite masking

This topic is 3560 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

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
Advertisement
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 :

device->SetRenderState(D3DRS_ZWRITEENABLE,TRUE);
device->SetRenderState(D3DRS_ALPHATESTENABLE,TRUE);
device->SetRenderState(D3DRS_ALPHABLENDENABLE,FALSE);

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_ALPHAFUNC, D3DCMP_GREATEREQUAL);
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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!