Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions “Calculate Expression just once”-hack. Legit?

  • “Calculate Expression just once”-hack. Legit?

    Posted by Simon Heimbuchner on May 11, 2022 at 2:02 pm

    Hey gang,

    I was snooping around in a collegue’s After Effects Project and stumbled upon a weird expression idea. This is what he had, first line, on pretty much every property.

    posterizeTime(0) // calculate expression just once

    To be honest, this seems bollocks to me.
    From what I would assume, After Effects would still have to parse the property on every frame—and not just magically save on CPU.

    However, I did a little scientific diddly-doo experiment:

    posterizeTime(0)
    if(time<1) {
    "under one second"
    } else {
    banana // break expression with syntax error
    }

    And look at that, there’s no syntax error coming up. Even as I move the cursor over the 1 second mark. Without posterize, an error does show up immediately.

    So, what’s the deal here?

    Simon Heimbuchner replied 3 years, 11 months ago 3 Members · 3 Replies
  • 3 Replies
  • Nick Graves

    May 11, 2022 at 4:49 pm

    I’ve never heard of this so I have no idea how it works, but it does seem to work which is amazing. I used the new Render Time benchmark feature to compare what happens if you run your expression but remove the error code from the “else” section.

    It seems to drastically increase the render time than if you were to enable posterizeTime(0)

  • Filip Vandueren

    May 11, 2022 at 7:53 pm

    It’s legit and officially documented by Adobe that this should work.

    What it doesn’t do is actually “bake” the expression while you’re still working on the comp: anything – including changing the name of say an unused solid in the project panel – can in theory alter the outcome of an expression, so it keeps recalculating while you are tweaking and changing stuff, but it doesn’t recalculate on every frame while ram-previewing or rendering.

  • Simon Heimbuchner

    May 12, 2022 at 5:27 pm

    Dang, this is incredible. Thank you guys.

    On your notice, Filip, I went looking. Here’s the official documentation:

    In After Effects 16.0, posterizeTime(0) freezes the property value at time 0 in the composition. This applies to both the JavaScript and Legacy ExtendScript engines.

    Note, also:

    This is not backward-compatible and may cause unexpected results in After Effects versions prior to 16.0.

    The time difference Nick demonstrated is absolutely incredible. This is amazing for templating.

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