Adobe After Effects Forum
Far Vanish and Near Vanish AE Layers
Far Vanish and Near Vanish AE Layers
by Stephen Moore on Aug 13, 2019 at 8:37:45 am

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)...

...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);

...which works for the Far Fade.

Does anyone know how to combine the two? That would be brilliant!

Many thanks in advance...


Re: Far Vanish and Near Vanish AE Layers
by Cassius Marques on Aug 13, 2019 at 2:25:17 pm

Sure:startFadeNear = 300;
endFadeNear = 600;
startFadeFar = 800;
endFadeFar = 1500;

C = thisComp.activeCamera.toWorld([0,0,0]);
P = toWorld(anchorPoint);
e = length(C,P);

if (e<600)


Cassius Marques