• Advertisement
Sign in to follow this  

How to fade in/out a SRCBLEND->SRCALPHA, DESTBLEND->ONE sprite render

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

Hello,

I'm trying to use a particly effect to create a nice colored glow, and I found the perfect combination:
d3ddevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
d3ddevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
particle image has no alpha (black background, white/grey particle.

The problem is that I can't get it to fade in/out. It seems to ignore the alpha value I pass in the last parameter of D3DXSprite::Draw().


I've tried numerous other combinations, and I can get the following combination to work with fade in/out:
d3ddevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR );
d3ddevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );
particle image has alpha (transparent background, white particle with semi transparancy)

But it just doesn't look as good.

Does anyone know how to get the alpha (fading) to work with my first setup?

Ps:
The alpha (fading) code works fine for everything else, meaning my normal draws using:
d3ddevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_SRCALPHA );
d3ddevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA );
Work fine with the alpha stored in the final paramater of the D3DXSprite::Draw() function.

Many thanks in advance for any help/tips.

Kind regards,
Michaël

Share this post


Link to post
Share on other sites
Advertisement
You say the second combination does work fine:

d3ddevice()->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_DESTCOLOR );
d3ddevice()->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );

...but here the alpha value isn't even used in the blending operation.

My take is you have the color and alpha values swapped in the D3DCOLOR struct (the one you pass as the last argument to the Draw method).

Edit: my mistake, D3DBLEND_DESTCOLOR does use the alpha value, but only multiplied with the src-blend's alpha value. Edited by eppo

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement