Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Forums Adobe After Effects Expressions Method to Combine seedRandom() and random()

  • Method to Combine seedRandom() and random()

  • Mark Walczak

    April 19, 2016 at 5:36 pm

    Hi everyone,

    I’m using Dan Ebbert’s expression for creating a sequence of random edits that can be found here:
    https://www.motionscript.com/mastering-expressions/random-3.html

    Here is my situation: I have two output comps that utilize this expression on two precomps (one precomp in each output comp). Those two precomps have the same footage with different color passes on them.

    How can I paste this expression on each precomp so that they start with the same frame for each precomp and follow the same random seed?

    From what I can deduce in the script, this would be a matter of locking the random seed of startVal, but I don’t know how to do this. I need to preserve the min/max value of “random()” but I need to lock the seed as in “seedRandom”.

    Another way to produce this result would be to simply option-replace the precomps in one of the output comps, but I want to try to do this with code and have multiple output comps for each precomp.

    I know this is a lot of info, but I really appreciate your help.

    Thanks in advance!

    https://vimeo.com/explosivegraffix

  • Dan Ebberts

    April 19, 2016 at 6:17 pm

    I think you’d have to do the random calculation somewhere that all precomp expressions have access to.

    For example, you could set up a special comp named “Control” with a layer named “Control” with a slider control that has an expression like this:

    segDur = .5;
    minVal = inPoint;
    maxVal = outPoint – segDur;
    seed = Math.floor(time/segDur);
    segStart = seed*segDur;
    seedRandom(seed,true);
    startVal = random(minVal,maxVal);

    This will publish startVal for all the other comps, which would have expressions like this:

    startVal = comp(“Control”).layer(“Control”).effect(“Slider Control”)(“Slider”);
    segDur = .5;// duration of each “segment” of random time
    segStart = Math.floor(time/segDur)*segDur;
    endVal = startVal + segDur;
    linear(time,segStart,segStart + segDur, startVal, endVal);

    That should sync all the comps using this expression. I haven’t tested this code, but hopefully it will get you headed in the right direction.

    Dan

  • Mark Walczak

    April 19, 2016 at 8:26 pm

    You nailed it, Dan! Thanks again!

    https://vimeo.com/explosivegraffix

Viewing 1 - 3 of 3 posts

Log in to reply.

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