Skip to main content
GameDev.net gamedev.net
🔒 Locked

Alpha Transparency...

Started by dave Apr 20, 2004 at 11:21 AM 5 replies 400+ views
Original Post
dave
dave
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
Axiverse
Axiverse
device -> setrenderstate( alphaenable, true)

i don''t used c, but it''s something along those lines.
ToohrVyk
ToohrVyk
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

Supernat02
Supernat02
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
Chris ByersMicrosoft DirectX MVP - 2005
dave
dave
thanx for teh help guys, i was using the equivilent to...

device -> setrenderstate( alphaenable, true);

i just didnt say,


thanks again

ace
dave
dave
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
de_matt
de_matt
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.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.