Jump to content
  • Advertisement
Sign in to follow this  
acid2

Material alpha blending

This topic is 4886 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

Hey, I'm currently trying to rebuild Blitz myself - little by little. I have got texture and per vertex alpha blending working, but I can't get material alpha blending working (if thats possible). What I am trying to achieve is so I can just do something like meshCube.Material.Alpha = .5f to make all of the mesh half transparent. Surely I don't have to tweak the vertex alpha of all verts?

Share this post


Link to post
Share on other sites
Advertisement
In DirectX you'll have to setup RenderState flags for material blending, first of all enable the alpha blending then setup the source and dest blending flags, example of mixed blending:


D3DDevice->SetRenderState(D3DRS_ALPHABLENDENABLE,true);
D3DDevice->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
D3DDevice->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );

Share this post


Link to post
Share on other sites
I don't know about using materials in that manner. I have always assumed (but I could be wrong) that they only change how the light reflects off the object.

There are two ways to do it without using the material. With DX 9, you can use the D3DTA_CONSTANT value in the texture stage state. With older versions, you can use the TFACTOR render state.

Basically, in the texture stage state you would modulate the original vertex (or texture if you so choose, or you could go into texture stage state 1 and use the result from 0 say if you modulated texture and vertex in stage 0) alpha value with the D3DTSS_CONSTANT value, set by calling SetTextureStageState(0, D3DTSS_CONSTANT, SomeValue). SomeValue is the alpha intensity.

Share this post


Link to post
Share on other sites
I can confirm that light alpha will work in a vertex shader. But in that type of situation, DirectX has little control over what colors get output to the processed vertex. Are you using a vertex shader?

Anyway, I'm almost positive that I did manage to make objects transparent using materials or lights before I got into shaders. I set up a "matrix" type invironment where the walls were all see-through. I can't help much to explain how to do it, but I wanted to make sure you knew it was possible.

Share this post


Link to post
Share on other sites
I think it's same in vertex shaders do you use light alpha or material alpha, because it will blend the object either of em. Well with light alpha all objects are blended, if we are talking about the same thing. :)

Fixed-T&L lights in DirectX doesn't support alpha value, only materials do.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!