Direct x8 Transparency
I am trying to draw a texture which uses the color white as the transparent color. I am not sure if this is the correct approach though, am I supposed to be setting the alpha channel? Do I need to set the alpha channel, can it be done by setting a color as the transparent color?
i''m using vb if that helps.
any thoughts would be greatly appreciated.
The way i would do it, is create/modify the image in an art program that supports layers(Adobe photoshop 7.0). Create the image with the alpha layer already in it, then load it, first setting the blending properties like this:
lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
I hope that helps
lpD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
lpD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
lpD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
I hope that helps
Yes you need to encode an alpha channel into the bitmap, for example R8G8B8A8 format. You might have to write your own importer to arrange the data how you want. Personally I use 2 bitmaps, one for colour and the other a mask/alpha image. This of course used more HD space for the game but the same texture/image memory because the alpha channel is there either way.
You could check you pic pixel by pixel for white and set the alpha if you want too. It depends how you''re populating your surface.
Mark
Cornutopia Games
http://www.cornutopia.net
Bytten Independent Games Magazine
http://www.bytten.com
You could check you pic pixel by pixel for white and set the alpha if you want too. It depends how you''re populating your surface.
Mark
Cornutopia Games
http://www.cornutopia.net
Bytten Independent Games Magazine
http://www.bytten.com
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement