Layer Mode Algorithm?

Hi.

We use Aseprite extensively for all our art needs. Such an excellent program!

We need to know how the layer mode’s blending functionality works per pixel wise so we can simulate its effect in the game looking the same as in the Aseprite.

We are particularly looking for Saturation, Hue, Difference options. Applying to RGB (not using indexed or grey images)

I tried to look at the source code, but it will be really helpful for the community to be able to check it all in one place. We need to know how mathematically the resulting pixel is being drawn on the screen.

So given one layer below a pixel RGBA value, if I have Saturation layer how does its RGBA value effects the layer below to produce the final result?

Thanks!

Here’s the code for the Saturation blending mode. The same file contains the other blending mode math as well.

1 Like