Sign in to follow this  

ID3DXSprite and alpha blending

Recommended Posts

Hi I start my sprite like so:

d3dDevice->SetRenderState( D3DRS_SRCBLEND, D3DBLEND_ONE );
d3dDevice->SetRenderState( D3DRS_DESTBLEND, D3DBLEND_ONE );

sprite->Draw(..., color);

now, usually if destblend is set to zero (default state) and I reduce alpha in color by using the D3DCOLOR_ARGB macro, the sprite appears blende, but in one/one (additive blend mode) the alpha of the color is ignored (though the rgb color seems to be modulated), what am I doing wrong? How do I control the alpha of additively blended sprites (I assume color is passed on to the diffuse color of the vertices in the sprite quad)? thanks in adv.

Share this post

Link to post
Share on other sites
actually this is my bad, at not understanding the additive blend equation, the color modulation is enough to reduce the luminosity of rgb, so when the sprite texels are added to the frame buffer they are already lower in opacity, i.e.:

(texel_color * mod_color) + dest_color = final_color

So instead of weighting the texel color with alpha you just lower the mod_color to reduce the texel's overall luminosity (or in each component).

if opacity = 0.5f;

color = opacity * D3DCOLOR_XRGB(r,g,b);


sprite->Draw(..., color);

as normal. I hope this helps someone..

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this