Skip to main content
gamedev.net
🔒 Locked

Alpha blending

Started by szevvy May 13, 2003 at 11:17 AM 1 replies 300+ views
Original Post
szevvy
szevvy
Thanks in advance for any help! I''m using DirectX 8.1 Say I have a bitmap that I''m loading into a texture, with a colorkey, so I use LoadFromTextureEx. Now, how would I draw that texture at say 50% transparency while preserving the color key? Michael
DrunkenHyena
DrunkenHyena
G''day!

SetTextureStageState = SetTSS

SetTSS(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE)
SetTSS(0,D3DTSS_ALPHAARG1,D3DTA_TFACTOR)
SetTSS(0,D3DTSS_ALPHAARG2,D3DTA_TEXTURE)

Use SetRenderState to set the TEXTUREFACTOR to have an alpha component equal to what you want (0x7F in this case) and you''re set.

Alternately, you can use D3DTA_DIFFUSE (instead of TFACTOR) and change the alpha in your vertices.

Usng DIFFUSE can be a pain since if the value changes a lot, you have to lock the vertex buffer each time. On the other hand, older cards have poor support for TFACTOR.

Other options:
-Materials can store alpha info (only works if you''re using lighting)
-VertexShader. You can pass the blend amount in as a shader constant. (I keep meaning to try this)


Stay Casual,

Ken
Drunken Hyena
Stay Casual,KenDrunken Hyena</FON

Topic Locked

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

Sign in to reply to this topic.