-
Far Vanish and Near Vanish AE Layers
Hi All,
I have a camera moving along the Z axis through a series of AE layers and I’d dearly love to be able to Far Vanish/Far Start Fade and Near Start Fade/Near Vanish those layers like in the Visibility tab in Trapcode Form.
I’ve Googled around and found on (this essentially shows my scene)…
https://macprovideo.com/article/after-effects/using-distance-from-camera-to-animate-in-after-effects
…this code…
start = comp(“Fade”).layer(“Control”).effect(“FadeStart”)(“Slider”);
end = comp(“Fade”).layer(“Control”).effect(“FadeEnd”)(“Slider”);
CameraPos = thisComp.activeCamera.toWorld([0,0,0]);
LayerPos = toWorld(anchorPoint);
Difference = length(CameraPos, LayerPos);
linear(Difference, start, end,0,100);
…which works for the Near Fade and this code…
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)…which works for the Far Fade.
Does anyone know how to combine the two? That would be brilliant!
Many thanks in advance…
Stephen