ADOBE AFTER EFFECTS: Forum Expressions Tutorials Creative Cloud

# Fading opacity when a layer gets too small OR too big

FAQ   •   VIEW ALL
 Fading opacity when a layer gets too small OR too big on Dec 14, 2011 at 6:12:15 am

I'm rigging up an Earth zoom effect, in which a bunch of layers are all parented together so they scale up in sync. To help cut down the rendering time, I want to use expressions to make each layer fade out when it gets smaller than 3%, and ALSO to fade out when it gets larger than 1000%. So basically, I want to apply BOTH these expressions to the opacity property:
linear(scale[0],1,3,0,100)
linear(scale[0],900,1000,100,0)

As far as I can tell, After Effects won't let me use more than one linear expression at a time on the same property. Any idea how I can get the behavior I want? I COULD just adjust the opacity of each layer manually, but where's the fun in that?

 Re: Fading opacity when a layer gets too small OR too bigon Dec 14, 2011 at 4:35:00 pm

you could try a if statement to tell ae to use one function when the scale is small, and the other when the scale is large. something like this should work:

if (scale[0] > 100)
linear(scale[0],900,1000,100,0);
else
linear(scale[0],1,3,0,100);

essentially it just telling ae when the scale is greater than 100 do one thing, if not do another. you could set that scale threshold to any value that was between the min scale value of the top function (900) and the max scale value of the bottom function (3).

Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW

 Re: Fading opacity when a layer gets too small OR too bigon Dec 14, 2011 at 5:16:05 pm

Thanks for the tip! But this is trickier than I thought; let me explain a little. I'm using the basic map zoom technique demoed by Andrew Kramer:
http://www.videocopilot.net/tutorials/earth_zoom/
You get a bunch of maps at various scales, parent them all to the first layer, and then scale that one layer up logarithmically. Works great, but it means that you've got 10 or so layers, and most of them are either too small to see, or giant (and therefore completely covered up by the next layer). It can get very processor intensive, and I thought that the expression you recommended would dramatically reduce rendering time by turning off the layers that couldn't be seen.

The problem is that because every layer is parented to the first, their scales don't change at all! So what I really want to do is make After Effects apply the expression to each layer's "true" scale (the scale it would be if it weren't parented) but still keep it parented. I know I've seen expressions that can use a layer's "true" POSITION in the comp even if it's parented, but can the same thing be done with scale?

Thanks!

 Re: Fading opacity when a layer gets too small OR too bigon Dec 14, 2011 at 7:09:51 pm

if you are only trying to speed up render time, then changing the opacity won't help too much. trimming the layers' in and out points could help quite a bit...

however, you could change the expression to include the parent's scale like this:

```s = scale[0]*parent.scale[0]*.01; if (s > 100) linear(s,900,1000,100,0); else linear(s,1,3,0,100);```

Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW

 Re: Fading opacity when a layer gets too small OR too bigon Dec 14, 2011 at 11:13:38 pm

Thanks a lot! Your expression had the desired effect – layers that were either very small or very large were automatically faded to 0% opacity. It didn’t look any different, and it actually DID render much faster. Without the script, the comp took 3 hours. With it, it took just over 1 hour!

To improve it even more, I found a script that automatically does what you suggest: it trims each layer that begins or ends with 0% opacity.
http://www.aenhancers.com/viewtopic.php?f=11&t=1096

However, I found that it did NOT reduce render time further. The version with the trimmed layers finished within a minute of the version that just had the opacity adjustment. So in this case, for whatever reason, adjusting the opacity to 0% IS just as good as trimming the layer.

Anyway, for anyone who is doing an earth zoom in the future, sticking this expression on all your layers (BESIDES the one parent layer) is a great way to reduce rendering time without impacting quality.

 Re: Fading opacity when a layer gets too small OR too bigon Dec 15, 2011 at 6:08:35 pm

i am surprised that the opacity change helped performance, it had been my experience that ae still did calculations for those layers and still cached them regardless of actually seeing them, and i had found that trimming the layers was the way to get ae to 'ignore' them.

it sounds like they may have optimized the render process since then -- it was many years ago that i had noticed this... good to know, thanks for reporting back.

Kevin Camp
Senior Designer
KCPQ, KMYQ & KRCW