Create Custom Blending Mode Using SDK
I'm brand new to using the AE SDK, and it's quite intimidating coming from the scripting side.
Let's say I want to create my own custom blend mode between layers. For the sake of simplicity, suppose a is the base layer and b is the blend layer (b is on top of a). For example, in After Effects, Overlay and Subtract should be implemented something like this:
static overlay(a, b) {
if (a < 0.5) {
return 2 * a * b;
}
else {
return 1 - 2 * (1 - a) * (1 - b);
}
}
static subtract(a, b) {
return max(a - b, 0.0)
}
(these functions are applied to each RGB channel value separately (with pixel channel values that are normalized to be between 0 and 1))
Suppose I want to implement my own custom blend function between two layers, one that After Effects does not provide, such as:
static grain_merge(a, b) {
return min(max(a + b - 0.5, 0.0), 1.0)
}
Is this possible with the SDK? I imagine it would have to be applied as a custom effect, and that's no problem; any way is fine as long as it works. I know that the base layer (a) would have to be the composite of all the pixels underneath the layer the effect is applied to, and (b) would have to be the source pixels of the layer that the effect is applied to. But I really don't know how I can actually make this happen. If this is possible, can you provide an example?
