Fortunately, this is simple.
You need the ability to map a range of values proportionally into another range of values.
The most common range mapping methods in AE expressions are linear() and ease().
So, you would use something like this in Layer 2's opacity.
range = thisComp.layer("Layer 1").transform.opacity;
linear(range, 100, 0, 40, 0);
Obviously, "range" is a variable. It stores the value of layer 1's opacity.
And the linear method works as if it was saying "as range goes from 100 to 0, convert the range proprtionally to 40-0".
I hope it's clear.
Thank you very much, that certainly works!
I was just thinking that could it be possible to solve this also by multiplying/dividing the values in some manner? Or is it impossible to solve a problem like this with just basic maths?
1 person found this helpful
Of course you can do this by multiplying.
In your example:
L1 = 40 .... 0
L2 = 100 ...0
Layer 2's opacity = (100/40) x Layer1Opacity.
Your problem was you were trying to add, when you needed to multiply....
Thanks! What a simple solution!