The big problem is that rgb value can not match its alpha value.I need some picture without black edge,so I must use rgb colors to divide its alpha value(Image manipulation software such as Photoshop can just deal with picture which alpha channel is nonpremultiplied.)
Unfortunally,the color is too light that some result value are cut off to 1.
So I turned to a technique called premultiplied alpha.(See more). Instead of using shaders,I just use separate alpha calculation.
RenderState.SourceBlend = Blend.SourceAlpha; RenderState.DestinationBlend = Blend.InverseSourceAlpha;Now I add some renderstate.
RenderState.SourceBlendAlpha = Blend.One; RenderState.DestinationBlendAlpha = Blend.InverseSourceAlpha;It works well.But when I try to handle following things:
RenderState.SourceBlend = Blend.SourceAlpha; RenderState.DestinationBlend = Blend.One; RenderState.SourceBlendAlpha = Blend.One; RenderState.DestinationBlendAlpha = Blend.One;The result is totally wrong.
Because when I use nonpremultiplied blend state,which is SourceAlpha and inverseSourceAlpha.The rgba value is definitely controlled within 0~1.But when I switch to additive state,which is SourceAlpha and 1,the rgb values might be over one,thus cause the incorrect value.
Now my problem is how to control the alpha value,to make sure it keep all details and do not overflow at the same time?
PS:If you don't understand what I am trying to do,there is a commercial software called "Particle Illusion".You can create various particles and then save the scene to texture,where you can choose to remove background of particles.
Edited by Tunisia hawker, 12 July 2012 - 08:16 PM.