• Advertisement
Sign in to follow this  

ID3DXSprite and alpha blending

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

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


Link to post
Share on other sites
Advertisement
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..

Share this post


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

  • Advertisement