#### Archived

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

# Additive alpha blending in D3D

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

## Recommended Posts

Okay, first of all I really don''t know shit about Direct3D so no flames, please. Well I managed to whip together some textures and mapping them onto a polygon and then onto the screen. The purpose of this, of course, was to be able to use the (possible) hardware acceleration Direct3D offers for certain effects. The normal transculent alpha blending went just fine but I got stuck when I tried to do the additive counterpart. Quickly I managed to get what I wanted but it wasn''t using my alpha values! It just added the source and destination colors up. Hmm. So the question is; what SetRenderState(...) and SetTextureStageState(...) would I have to call to attain this certain effect? "Paranoia is the belief in a hidden order behind the visible." - Anonymous

##### Share on other sites
Additive blending doesn't use the alpha channel. You set it up like this:

  // Texture color and screen color will be added to each other to produce the new colorm_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);m_pD3DDev->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);m_pD3DDev->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);

- WitchLord

Edited by - WitchLord on June 25, 2000 10:24:30 AM

##### Share on other sites
That was exactly what I was doing all the time >. Are you sure there is absoutley no way of having it use the alpha channel? I stuck some alpha values into the vertices...can''t it just use them dammit! All I was looking for was something like d = s + d * a. Well, thanks alot for the help. I guess I''ll have to do without the alpha channel.

"Paranoia is the belief in a hidden order behind the visible." - Anonymous

##### Share on other sites
The formula you're describing can be achieved by setting DESTBLEND to D3DBLEND_SRCALPHA. Don't forget to make sure that there is alpha values left after the texture blending stage:

  m_pD3DDev->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);m_pD3DDev->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);m_pD3DDev->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_SRCALPHA);m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);m_pD3DDev->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);

- WitchLord

Edited by - WitchLord on June 25, 2000 5:00:33 PM

• 39
• 15
• 9
• 23
• 10