You are fast! :D

Ok I think I can do this for the other operations.

Just to share another example for the blending mode "Screen",
whose formula is: f(a,b) = (a+b) - (a*b).

R = (1-alphaB)*A + alphaA*alphaB*Blend(B/alphaB,A/alphaA) +
       (1-alphaA)*B

Let's deal with Blend first:

Blend(B/alphaB,A/alphaA) = Screen(B/alphaB,A/alphaA) =
B/alphaB + A/alphaA - (B/alphaB) * (A/alphaA) =
(B*alphaA + A*alphaB - B*A) / (alphaA * alphaB)

And finally:

R = (1-alphaB)*A + (B*alphaA + A*alphaB - B*A) + (1-alphaA)*B

which can be further simplified to:

A + B - A*B

That was wicked!

I will write the full formulas as comments for the functions
but inside I will use reduced math for faster calculations.
_______________________________________________
Oiio-dev mailing list
[email protected]
http://lists.openimageio.org/listinfo.cgi/oiio-dev-openimageio.org

Reply via email to