# ID3DXSprite and alpha blending

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

## Recommended Posts

Hi I start my sprite like so:
sprite->Begin (D3DXSPRITE_ALPHABLEND | D3DXSPRITE_OBJECTSPACE)

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

So:
if opacity = 0.5f;

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

and:

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

as normal. I hope this helps someone..

• 38
• 12
• 10
• 10
• 9
• ### Forum Statistics

• Total Topics
631365
• Total Posts
2999585
×

## Important Information

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!