Premultiplied Alpha - How to implement in XNA?

September 5, 2008 by admin
Filed under: Xbox360 News 

I've finally found out what had been causing some graphical oddities, and now that I'm finally working on my game and using multiple rendertargets and blending, this "smaller" problem is effecting everything - so I need a fix.

After now knowing it has to do with using "premultiplied alpha", I still can't figure out how to get it to work in XNA… so could anyone tell me how the below code should look so as to use premultiplied alpha?

 

                    Sprite_Batch.Begin(SpriteBlendMode.AlphaBlend, SpriteSortMode.Immediate, SaveStateMode.None);  
 
                    RenderState.SourceBlend = Blend.One;  
                    RenderState.DestinationBlend = Blend.InverseSourceAlpha;  
 
                    Sprite_Batch.Draw();  
 
                    Sprite_Batch.End(); 

 

Thanks very much.

 

EDIT: Also, does my setting for SurfaceFormat when creating my render targets matter? Currently it's set to SurfaceFormat.Color…

Cheap wow gold

Comments

Feel free to leave a comment...
and oh, if you want a pic to show with your comment, go get a gravatar!