The Mathematics of Blend Modes

An overview of blend modes (unfortunately specific to proprietary software). It is interesting though and has some good examples.


Here’s a good source of mathematics of blending mode - imblend.txt (100.7 KB)

I actually used that to create Krita blending modes. Modulo is entirely made up by me. They actually exist as a function for gmic. I created modf long before the creation of modulo blending modes. If you use gmic, update gmic, and then look into the gmic file, and see what modf do, then experiment and you’d see what modf is about. I do wish those blending modes are part of standard gmic. Maybe I’ll get to that later.

That’s another source you can use to find functions for blending mode. Modulo base code in Krita:

inline static dst_compositetype modulus(_T a, _Tdst b) {
    return (dst_compositetype(a) - floor(dst_compositetype(a)/((b != (KoColorSpaceMathsTraits<_T>::zeroValue - traits::epsilon) ? b : KoColorSpaceMathsTraits<_T>::zeroValue)  + traits::epsilon))*(b + traits::epsilon));

And an overview of the g’mic blend modes is here:

One more thing, there is lch modes in gimp. Krita, GIMP both together covers all the relevant modes. Krita has a much larger set of mode including modulo modes which is exclusive to Krita. Affinity software has contrast negate, but it is garbage compared to what Krita offers in it place.