BltShader: Correct algorithm as provided my /cremno

The color calculation is now actually 99% correct!
Fixes #14.
This commit is contained in:
Jonas Kulla 2014-01-31 10:08:05 +01:00
parent b6a299541f
commit 1b0eb2797d
1 changed files with 5 additions and 9 deletions

View File

@ -20,18 +20,14 @@ void main()
vec4 resFrag;
float ab = opacity;
float as = srcFrag.a;
float ad = dstFrag.a;
float co1 = srcFrag.a * opacity;
float co2 = dstFrag.a * (1.0 - co1);
resFrag.a = co1 + co2;
float at = ab*as;
resFrag.a = at + ad - ad*at;
// Sigh...
if (ad == 0.0)
if (resFrag.a == 0.0)
resFrag.rgb = srcFrag.rgb;
else
resFrag.rgb = as*srcFrag.rgb + (1.0-at) * ad * dstFrag.rgb;
resFrag.rgb = (co1*srcFrag.rgb + co2*dstFrag.rgb) / resFrag.a;
gl_FragColor = resFrag;
}