This started as a REPL session to try to understand why our Goodbeast.com colors look so much better when a friendly designer used them than when I did (other than his exceptional sense of color). I realized that he was "overlaying" them on top of themselves, effectively increasing both brightness and saturation.
This all came together as a shader, forked to start and mostly credited. https://www.shadertoy.com/view/DtKyRc
The overlay function in the javascript version can be thought of more as an "S curve" in a design program - it increases
intensity via a Sigmoid function. The one below is what Wikipedia believes Photoshop uses. Most
of the rest of this is just utility functions for dealing with different types of color notation.
I think the shader style vec3()
notation is the easiest to do math with. Hence the convention
of passing colors like {r, g, b}
.
A real overlay function would take two different colors. This would be trivial, and is left to an exercise for the reader.
Try something like toHex(overlay(hex('#57166B')))
to get started.