Archived

This topic is now archived and is closed to further replies.

Creating alpha textures

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

Hi, i''ve been reading a lot of articles on Alpha and color keying but i don''t seem to get how to make textures with one color transparent. Can I create a TGA texture in Photoshop with a some sections transparent? and how? And will these show up in DirectX as transparent, so i can create like a tree with leafs and some transparent areas? Is there another way, maybe use a colorkey and assign one color that should be transparent, i tried this but all i got was that the color i choose as transparent became black.

Share this post


Link to post
Share on other sites
Hi - yes - there are a lot of web-based tutorials on using photoshop to create an alpha channel for an image. Here is one:

http://tiemdesign.com/howto/2000/Mar/PSTut1/default.htm

But googling for "photoshop" and "alpha channel" will find many, many more.

Once you''ve added an alpha channel to an image, save it as a 32- bit tga file, and it should be ready to use in directx.

Hope this helps-

BM

Share this post


Link to post
Share on other sites
Hi thanks for the tip on alpha channel tutorial but i can''t get it to work. DirectX just handles the TGA as a normal texture it ignores the Alpha channel completly. Do i have to activate it or set some render state to enable the Alpha channel in the texture

Share this post


Link to post
Share on other sites
There are some flags you need to set when you''re initializing Direct3D in order for it to recognize alpha channels. My .tga files didn''t show transparency in Direct3D until I set these flags.

In my code, my D3D Device object is called mD3DDevice.

mD3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
mD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
mD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
mD3DDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);

Share this post


Link to post
Share on other sites
quote:
Original post by Dreamcatcher


Is there another way, maybe use a colorkey and assign one color that should be transparent, i tried this but all i got was that the color i choose as transparent became black.





Also you need to set these parms to get the texture color actually transparent.

Device->SetRenderState(D3DRS_ALPHAREF,255);
Device->SetRenderState(D3DRS_ALPHAFUNC,D3DCMP_GREATEREQUAL);

Share this post


Link to post
Share on other sites