Jump to content
  • Advertisement
Sign in to follow this  
Halsafar

Alpha blend problem

This topic is 4773 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 a quad which needs returning based on the alpha in the diffuse and the color key black. I know how to do one or the other -- I have have the alpha come from the diffuse, thus per-vertex alpha. I also can load a texture with 0xFF000000 as the colorkey and have all black be transparent. I cannot figure out the states to combine the two. Is it not possible?

Share this post


Link to post
Share on other sites
Advertisement
You need to both enable alpha blending and alpha testing. Set your colorop to modulate and the colorargs to diffuse and texture. Same with alphaop.
Don't forget to set the alpharef value (8 is a good value) and the alpha compare func to greaterequal.

Set srcblend to SRCALPHA and destblend to INVSRCALPHA.

Share this post


Link to post
Share on other sites
Okay I attempted that just as you explained and i'm getting diffuse alpha but the black isn't not transparent.

Edit: Okay my fault, forgot to modulate the alpha values... Anyway, works fine now :) Thanks a ton.


//Set up the alpha and texture stage states
::Graphics()->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
::Graphics()->SetRenderState(D3DRS_ALPHATESTENABLE, TRUE);
::Graphics()->SetRenderState(D3DRS_SRCBLEND,D3DBLEND_SRCALPHA);
::Graphics()->SetRenderState(D3DRS_DESTBLEND,D3DBLEND_INVSRCALPHA);
::Graphics()->SetRenderState(D3DRS_ALPHAREF, 0x08);
::Graphics()->SetRenderState(D3DRS_ALPHAFUNC, D3DCMP_GREATEREQUAL);

::Graphics()->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
::Graphics()->SetTextureStageState(0,D3DTSS_COLORARG1,D3DTA_DIFFUSE);
::Graphics()->SetTextureStageState(0,D3DTSS_COLORARG2,D3DTA_TEXTURE);

//Set the alpha to come completely from the diffuse
::Graphics()->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE);
::Graphics()->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);
::Graphics()->SetTextureStageState(0,D3DTSS_ALPHAARG2,D3DTA_TEXTURE);


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!