Skip to main content
gamedev.net
🔒 Locked

Transparency

Started by vmware Apr 1, 2009 at 2:50 AM 3 replies 1k views
Original Post
vmware
vmware
Hi, I am trying to enable transparency. My vertices are defined in CUSTOMVERTEX structs. I guess that the first byte should stand for transparency, but even if I use that value, my vertices will remain opaque. How can I enable transparency? Thanks.
vmware
vmware
I am using Direct3D with C++.

I had also tried this before that is mentioned in the tutorial,
but it doesn't work.

g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
g_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_SELECTARG1);
g_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE); g_pd3dDevice->SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_TEXTURE);

What am I doing wrong?
vmware
vmware
Okay, for the first time it works now,
after adding these three lines of code.
Hope I am doing the proper way.

g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
g_pd3dDevice->SetRenderState(D3DRS_BLENDOP,D3DBLENDOP_ADD);
dmatter
dmatter
Quote:
Original post by vmware
Hope I am doing the proper way.
Your are doing it correctly, although as you might have guessed there is more than one 'proper way' to configure blending.

Topic Locked

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

Sign in to reply to this topic.