Archived

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

ALPHA BLENDING in DX8?

This topic is 5982 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have made a couple of really cool 3d demos in Direct3D and I want to add transperincy to them. How to I do this? For example How would make a bitmap transparent? Thanks in advance.

Share this post


Link to post
Share on other sites
Firstly, you''ll need to enable alpha blending ("device" is your LPDIRECT3DDEVICE8):

device->SetRenderState(D3DRS_ALPHABLENDENABLE, true);

That turns alpha blending on. Then set up your blend states:

device->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);

this tells Direct3D how the alpha values are combined into the final rendered pixel. If you want to know more specificly how this works, read the DirectX 8 SDK, but the above values are the most commonly used.

The transparency is then defined as the alpha value of the diffuse color at any given pixel. This could be the alpha component of the diffuse color of your current material(if you''re using materials) or the alpha component of the diffuse color defined at each vertex(if you''re using color values hard-coded in your FVF). 0 is invisible, 1 is completely solid, and anything in between is various levels of translucency.

If you want to do anything fancier (like using the alpha channel of a texture surface to do per-pixel translucency) you''ll have to set some more states, but that should get you started... I think. it''s been a while since I''ve actually done this myself. if it doesn''t work, read the SDK. if it does work, read the SDK anyways. Never hurts to know exactly what''s going on! :-)

Share this post


Link to post
Share on other sites
Once you figure out the alpha blending write a tut on how you did it and submit it to NeXe I am interested in alpha blending and a tutorial on it would really help me out for when I get around to messing around with it.

Eric Wright o0Programmer0o
AcidRain Productions
http://www.acidrainproductions.com

Share this post


Link to post
Share on other sites