here is a 2 pass way you can try out:
pass 1 - normal alpha blend
pass 2 - invert the alpha channel and multiply by color, this should leave you with a soft edge from the texture, apply this additivly
It doesn't seems like magic and should run on really low level hardware. Basically it seems to be based on the two blending modes:
blend: a*t + (1-a)*f
add: t + f
where t=texture, f=on screen fragment/backbuffer, a = alpha of texture
If you take a premultiplied alpha texture with t'=t*a and use the standard blend mode, then you got:
blend: t' + (1-a)*f = t*a + (1-a)*f
You can now use the alpha value to increase the influence of the fragment by setting a=0
t'+(1-a)*f = t'+(1-0)*f = t'+f = additive mode
So, it is just a matter of the texture if using the standard blend function 1*t'+(1-a)*f
The trick is , to use separate alpha values for the premultiplied part of the texture and the alpha channel:
a = alpha value for premultiplication
b = beta value for shifting between standard blend (1) and additive mode (0)
The texture should be constructed like this.
t_base = base_texture = (color_base,alpha_base)
beta = 0..1
t_new = (color_base * alpha_base, alpha_base*beta)
A standard premulitplied texture would look like
t_premulti = (color_base * alpha_base, alpha_base)
Setting the beta value to 0 will result in pure additve mode.
Replies
pass 1 - normal alpha blend
pass 2 - invert the alpha channel and multiply by color, this should leave you with a soft edge from the texture, apply this additivly
blend: a*t + (1-a)*f
add: t + f
where t=texture, f=on screen fragment/backbuffer, a = alpha of texture
If you take a premultiplied alpha texture with t'=t*a and use the standard blend mode, then you got:
blend: t' + (1-a)*f = t*a + (1-a)*f
You can now use the alpha value to increase the influence of the fragment by setting a=0
t'+(1-a)*f = t'+(1-0)*f = t'+f = additive mode
So, it is just a matter of the texture if using the standard blend function 1*t'+(1-a)*f
The trick is , to use separate alpha values for the premultiplied part of the texture and the alpha channel:
a = alpha value for premultiplication
b = beta value for shifting between standard blend (1) and additive mode (0)
The texture should be constructed like this.
t_base = base_texture = (color_base,alpha_base)
beta = 0..1
t_new = (color_base * alpha_base, alpha_base*beta)
A standard premulitplied texture would look like
t_premulti = (color_base * alpha_base, alpha_base)
Setting the beta value to 0 will result in pure additve mode.