Jump to content
  • Advertisement
Sign in to follow this  
paic

Alpha blending weird problem

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

Hi, I've implemented a "squid track" system (the tracks left by the wheels on the ground when we are a little too heavy on the brake. I don't know if "squid track" is the correct term) in an old project, and I'm integrating it on a newer one. Now, the details : - I display a long triangle strip. It has texcoords, diffuse color and position. The texture is RGBA. - The diffuse color at each vertex is to make certain segment "invisible" with an alpha value of 0. Here's the render states :
m_pd3dDevice->SetRenderState(D3DRS_LIGHTING,         false);
m_pd3dDevice->SetRenderState(D3DRS_ZWRITEENABLE,     false);
m_pd3dDevice->SetRenderState(D3DRS_ALPHABLENDENABLE, true);
m_pd3dDevice->SetRenderState(D3DRS_SRCBLEND,         D3DBLEND_SRCALPHA);
m_pd3dDevice->SetRenderState(D3DRS_DESTBLEND,        D3DBLEND_INVSRCALPHA);
And the problem now : I see the alpha blending working for the texture (at some places, my texture is transparent, and I see through, so alpha blending works for the texture) The diffuse color is taken into account (if I set the vertices to red, it's red ^^) BUT when I set the alpha value of the vertex colors to 0, my vertices are still visible !!!!!!!! So, I assume there's another render state somewhere in my app that screw the rendering, but I really don't know which one. Anybody have an idea of what could cause this strange behavior ??? Thx in advance.

Share this post


Link to post
Share on other sites
Advertisement
From the sounds of it, it'll be your texture stage configuration.

You need to configure the blending to modulate the diffuse/alpha as well as the texture.

Off the top of my head, so no guarantees [wink]:

device->SetTextureStageState( 0, D3DTSS_ALPHAOP, D3DTOP_MODULATE );
device->SetTextureStageState( 0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE );
device->SetTextureStageState( 0, D3DTSS_ALPHAARG2, D3DTA_TEXTURE );


hth
Jack

Share this post


Link to post
Share on other sites
Yep, I thought about this one, but the problem is : only the alpha value of the vertex color is not taken into account ! The RGB values are correctly blended with the color of the texture !

Edit : forget it, I didn't see the ALPHA ^^ You're right, it works now, thanks a lot ^^

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!