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.

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 on other sites
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 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 ^^

1. 1
2. 2
3. 3
Rutin
22
4. 4
5. 5

• 11
• 18
• 14
• 9
• 9
• Forum Statistics

• Total Topics
632929
• Total Posts
3009279
• Who's Online (See full list)

There are no registered users currently online

×