-
Opacity based on distance to camera redux
There’s this standard opacity expression. It’s great for getting things to fade off into the distance.
But what if I wanted it to also fade as layers moves toward the camera also? So there’s this sweet spot zone of where layers are at full opacity — the things behind are fading into the distance, the things in front fade off too, but have a more rapid falloff
startFade = 500; // Start fade 500 pixels from camera.
endFade = 1500; // End fade 1500 pixels from camera.
try{ // Check whether there’s a camera.
C = thisComp.activeCamera.toWorld([0,0,0]);
}catch(err){ // No camera, so assume 50mm.
w = thisComp.width * thisComp.pixelAspect;
z = (w/2)/Math.tan(degreesToRadians(19.799));
C = [0,0,-z];
}
P = toWorld(anchorPoint);
d = length(C,P);
linear(d,startFade,endFade,100,0)