Archived

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

dave

Alpha Transparency...

Recommended Posts

Hi everyone, i hope someone can help me. I have loaded a texture using the following line: D3DXCreateTextureFromFileEx(g_pD3DDevice, node->FilePath,D3DX_DEFAULT,D3DX_DEFAULT,6,0,D3DFMT_A8R8G8B8,D3DPOOL_DEFAULT,D3DX_FILTER_LINEAR,D3DX_FILTER_LINEAR, 0xffff0000,NULL, NULL,&node->g_pTexture); I have then used the following code to make the texture transparent in the 100% red areas. g_pD3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCCOLOR); g_pD3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCCOLOR); The above code isnt working and i cant find any clear source examples. I have tried several combinations of everything to no avail. Please could someone help regards ace

Share this post


Link to post
Share on other sites
Also, I think you should be using the alpha channel of the source as opposed to the color channel, so SRCALPHA instead of SRCCOLOR and INVSRCALPHA instead of INVSRCCOLOR could work.

Besides, as Axiverse pointed out, you should enable alpha blending. Also, alpha testing could do what you want, since it discards 0-alpha pixels before even rendering them.

Victor Nicollet, INT13 game programmer

Share this post


Link to post
Share on other sites
Alpha testing is the best way to go, because it is faster. I think you want to turn alpha blending off and alpha testing on.

Chris

Share this post


Link to post
Share on other sites
thanx for teh help guys, i was using the equivilent to...

device -> setrenderstate( alphaenable, true);

i just didnt say,


thanks again

ace

Share this post


Link to post
Share on other sites
Im afraid that i still; cant get it to work since when i use the suggested SRCALPHA and INVSRCALPHA the texture goes completely transparent. Do i still have to specify the Color Key color when loading the texture?

Can anyone point me in teh right direction for Alpha testing tutorials in DirectX 9.

regtards

ace

Share this post


Link to post
Share on other sites
I found alpha testing easier to refine to what you need.

Are you using an alpha texture - a texture with an alpha channel?

You can create these with the D3DTex program in the SDK. It builds .tga files I think but I can''t remember. Maybe someone else can remember the tex utils filetype.

Share this post


Link to post
Share on other sites