Additive alpha blending in D3D

Started by
2 comments, last by Staffan 23 years, 9 months ago
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
Advertisement
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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

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
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

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

This topic is closed to new replies.

Advertisement