Skip to main content
gamedev.net
🔒 Locked

Alpha Blending

Started by quant 1 reply 400+ views
Original Post
quant
quant
hi Im quite new to direct3d, and im currently playing with alpha blending, i have a very simple scene with a textured building and very simple textured 3 vertex triangle floor. I wanted to make the building semi-transparent so i could see some of the texture of the grass through it, so i added the following lines to the code.
g_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,TRUE);
g_pd3dDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_SRCALPHA);
g_pd3dDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ZERO);
   
I was expecting to be able to see the grass texture through the building, but instead i got this.. (The scene is cleared to this blue color before rendering). So the question is, is it possible to make the grass visible through the building? what am i doing wrong.. [edited by - quant on November 25, 2003 11:42:17 AM]
-keyboard
IFooBar
IFooBar
well do you have an alpha channel in either your vertices or your texture?
you also need to set a few testure stage states. D3DTSS_ALPHAOP, D3DTSS_ALPHAARG1 and D3DTSS_ALPHAARG2.

Either tell d3d to take teh alpha from the tecture or from the diffuse component of your vertices. The diffuse would be ither teh color component of your vertex structure, or in teh case of lighting, it would be the material you use.


:::: [ Triple Buffer ] ::::
[size=2]aliak.net
quant
quant
The alpha channels were in my vertices, ive fixed the problem, just had to change the order in which i was drawing the primitive

-keyboard

Topic Locked

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

Sign in to reply to this topic.