Archived

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

Ro_Akira

D3D7 ..._DESTBLEND,D3DBLEND_SRCALPHA)

Recommended Posts

Hmmm, didn''t quite know what to call this post... I using D3D for alpha blending in 2D, and I''ve set up my render states like so...
  
lpD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,D3DBLEND_SRCALPHA);
		lpD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,D3DBLEND_INVSRCALPHA);
  
This is fine for alpha blending. But I want to do, I think, ''additive blending'', where if the dest pixel is white, it will stay white no matter what the src pixel is. A kind of ''burned out effect'' some call it. Anyways, this does it...
  
lpD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,D3DBLEND_SRCALPHA);
		lpD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,D3DBLEND_SRCALPHA);
  
...but, I''m using a texture with a palette, and the palette has alpha info in it, and I think that''s what messes things up. For example, I have a yellow circle texture, which gradually fades away from the centre, using normal alpha-blending. But it gradually fades to black using the additive blending. I hope somebody knows what the hell I''m talking about Ro_Akira

Share this post


Link to post
Share on other sites
I finally found a past post on additive blending, and it ended with Witchlord giving this solution:

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


He also mentioned : "Don''t forget to make sure that there is alpha values left after the texture blending stage"

I don''t know exactly what is meant by this(I''m new to D3D), but can only guess that this is what I''m doing wrong, as it''s not working...

The formula d=s+d*a was mentioned during the post.

Ro_Akira

Share this post


Link to post
Share on other sites