Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Less expensive way to use Expression. e.g. sourceRectAtTime()…

  • Less expensive way to use Expression. e.g. sourceRectAtTime()…

  • Kyung Ko

    February 6, 2020 at 10:13 pm


    I’m building the MOGRT and in the AE project, and everything functions well but the only problem is that it’s a bit heavy.
    It gets slower than how it should be since the design is pretty simple.

    Here are a few things that I did that somewhat successfully reduce the render time…
    1. I reduced the repetitive layers to the one layer and used Expressions so it’s configurable.
    2. I changed the structure so there is no pre-comp. (I don’t know why but it got better a little bit)
    3. there were some shape layers with the gradient fills and I replaced it as png. (surprisingly, I got pretty good improvement by this)

    Here are a few things that might need to get optimized…
    1. Key-framed animation vs ease animation in Expression? Currently, there are no keyframes and all the animations are in the Expressions. Any idea which way is less expensive?
    2. sourceRectAtTime() vs sourceRectAtTime(inPoint,true)? Since “AtTime“is quite expensive, do you think including “inPoint” would help? I have lots of text layers with this, so I’m curious.
    3. The animation is happening only at the beginning for one second, and it stays still, but PPro seems like it’s reading every single frame.

    Any thoughts would be appreciated. Thanks a lot!

  • Tomas Bumbulevičius

    February 7, 2020 at 6:38 am

    Hey Kyung, interesting insights out there. Few ideas to share, along to your question points:

    1. Keyframed animation will be significantly less computation heavy than any of interpolated methods for animation. Simply because, every ‘expression related’ interpolation is recalculated every frame to inspect for changes.
    2. If you have any animation happening to sourceRects, then setting inPoint only won’t get you anywhere – at other times it won’t be relative to animation (which you need, or not, depending on the setup)
    3. Solution would be to trim down the comp as long as animation occurred. If it must stay as ‘on screen graphic’, then freezing frame after animation settles, could work out.


    Find out more:
    After Effects Tutorials: motion design, expressions, scripting.
    Boxer – Dynamic Text Boxes Template with a Live Preview

  • Kyung Ko

    February 7, 2020 at 5:18 pm

    Tomas, Thanks a lot for your input.

    I have a few more questions.
    1. Does it still calculate every single frame, even though you limit the loop or animation to happen only for one second at the beginning?
    2. Are there any benefits using inPoint when the value at 0 seconds is the only needed value?
    3. What if I use the if statement with time, so it outputs a fixed value after 1 second?
    Any thoughts would be appreciated. Thanks a lot!

  • Tomas Bumbulevičius

    February 21, 2020 at 9:15 am

    Hey Kyung, sorry for my late response.

    1. I would say yes!
    2. Not sure about this one – could you clarify?
    3. Having defined/fixed value is still better than re-calculating it to get the result (especially if its redundant). So yes, it should help.


    Find out more:
    After Effects Tutorials: motion design, expressions, scripting.
    Boxer – Dynamic Text Boxes Template with a Live Preview

  • Alex Printz

    February 21, 2020 at 3:46 pm

    Expressions will always be harder on the system than keyframed data since the math has to be calculated live to get the option. Also note that if one layer’s expression is referencing another layer’s property’s output value , that other layer has to be calculated first, and it can create long chains.

    So if layer A’s position is based on layer B’s opacity, and layer B’s opacity is based on a checkbox on layer C, and layer C is a precomp with master properties and has multiple iterations in the current comp, then when layer A’s position is
    calculated it has to do the single master property of layer of C with the checkbox, then B’s opacity, then it can do A’s position.

    I *believe* once B’s opacity is calculated it isn’t recalculated again for the current frame, but I’m not 100% sure on that. Be aware that precomps with master properties have to be recalculated multiple times for each instance with a master property that is different than it’s source comp.

    Another thing to mention is how AE render layers, which is always bottom to top in this order:
    1. Comp Background color
    2. Pre-Comp Layers
    3. Non-Comp (footage, vector, solids, etc.) Layers
    4. Lights
    5. Cameras
    6. Motion Blur
    7. Audio

    so depending on how your comps are structured you can get some heavy back-and-forth expression calculations.

    There’s been a potential workaround being developed a bit involving global variables. Note that these are kinda a hack at the moment, but depending on what you’re building it might be possible to push a lot of variables to global from a single element (null? text?) and then call those appropriately from other expressions so long as you’ve stacked your layers correctly (see my list above). This is a work in progress and being developed, and not be stable and may not be possible in later versions of AE.

    A small trick I do for heavy expression comps is limit the expression calculations to specific points. I stuck some code down below that I use to only run expressions when time is on the layer’s duration in the timeline, which can help isolate when expressions are run without getting into specific time callouts. See below in the quoted section.

    Adobe also has the new posterizeTime(0) available in CC 2020 that will only calculate once for the whole comp, also useful if you want to do the check only once.

    I’m sure there’s a lot more, but that’s all I have off the top of my head.

    //all other code here

    }//end bracket after other code

    Alex Printz
    Mograph Designer

  • Kyung Ko

    February 21, 2020 at 4:31 pm

    Hey Tomas, thanks so much for the clarification.
    I kinda figured the second question I asked. I was basically asking if I can avoid the recalculation bt using inPoint when the value is fixed, but I figured it didn’t help, but limiting the range with the if statement helped.
    I really appreciate your help!

  • Kyung Ko

    February 21, 2020 at 4:54 pm

    Thank. you very much Alex for sharing great information.
    I happened to lighten the functions by basically trying a bunch of different approaches but I didn’t know what exactly helped the situation. Your explanation helped me a lot to understand what could have been. I used to be a very design-oriented motion artist but recently I’ve been working on lots of customizable templates. I’m already taking your code and applying it to most of my functions. Learning every day! ☺ Thanks again!!

Viewing 1 - 7 of 7 posts

Log in to reply.

We use anonymous cookies to give you the best experience we can.
Our Privacy policy | GDPR Policy