Creative Communities of the World Forums

The peer to peer support community for media production professionals.

Activity Forums Adobe After Effects Expressions seedrandom vs random

  • Dan Ebberts

    January 16, 2019 at 6:13 pm

    seedRandom() doesn’t produce a random number, it just seeds the random number generator, which will cause subsequent calls to random() to generate a different sequence of random numbers.

    It’s like there’s a big book of random numbers, and each call to random() retrieves the next number from the book. seedRandom() lets you change to a different page in the book.

    Dan

  • Jeff Kay

    January 16, 2019 at 6:49 pm

    An effect of this is that with a set seedRandom, random() will always generate the same [randomly generated] results, while random() absent of a seedRandom being set will generate different results every time you preview, render, or move your playhead.

    This means that any previewing you do will necessarily be different than your export unless a seedRandom value is set. I might not always use the offset or timeless modifiers for seedRandom, but I honestly don’t know of a situation that I wouldn’t set seedRandom if I’m using random().

  • Nitai Lev-oren

    January 16, 2019 at 7:33 pm

    I don’t get it…

    do you have examples of seedrandom?

  • Dan Ebberts

    January 16, 2019 at 7:46 pm

    This will generate a different random number between 0 and 100 every frame, and the numbers will be different, depending on where the layer is in the layer stack of the timeline:

    random(100);

    This will generate a different random number every frame, but the numbers won’t change if you move the layer around in the layer stack:

    seedRandom(index);
    random(100)

    This will generate the same random number on every frame:

    seedRandom(index,true);
    random(100);

    Dan

  • Nitai Lev-oren

    January 17, 2019 at 7:42 am

    so seedRandom refers to the number of the layer in the layer stack?

    and what is the parameter “timeless” means.

    if it is true it will not randomize the numbers and if it is false it will randomize the numbers?

  • Dan Ebberts

    January 17, 2019 at 9:35 am

    >so seedRandom refers to the number of the layer in the layer stack?

    No, you can use any number as the seed. Each unique seed will give you a different sequence of random numbers when you call random().

    >and what is the parameter “timeless” means. if it is true it will not randomize the numbers and if it is false it will randomize the numbers?

    No, true means you get the same random numbers at each frame, false means you get different random numbers at each frame.

    Dan

  • Steve Roberts

    March 6, 2022 at 8:46 pm

    I think I have an application that might illustrate this.

    You have two stars floating in the scene. Each star has a stroke and a fill. But for project-specific reasons, each star’s fill and stroke must be on a separate layer. So you have four layers: fill 1, and stroke 1 for star 1; fill 2, and stroke 2 for star 2.

    Now, you want each star to be floating about with a wiggle expression, but you want each fill to be locked to its respective stroke: no shifting of fill and stroke within a star. But you also want each star to be floating independently of its partner. How to control the wiggles, knowing that wiggle is set by the layer’s position in the stack and we have four layers here?

    My solution was to use Seed Random ahead of the wiggle expression for each layer.

    • Stroke 1 used seedRandom(1, true);
    • Fill 1 used seedRandom(1, true);
    • Stroke 2 used seedRandom(2, true);
    • Fill 2 used seedRandom(2, true);

    (Yes, there are other solutions such as parenting and precomping, but that’s not the point.)

  • Puranjay Chauhan

    February 28, 2024 at 2:45 pm

    What is the relevance of the seed value we put in the seedRandom expression?

    Like, everytime ae picks up a random number from the range we provide in the Random() expression. But the seed value determines how it will pick up a random number. So whatever I understood vaguely is that seed value determines the process of choosing a random number through the Random() expression. So like every different seed value will count for different process of choosing a random number. Right?

    Please correct me if I am wrong. And shed some light on the significance of the seed value and it’s working.

  • Dan Ebberts

    February 28, 2024 at 6:24 pm

    See if this helps:

    https://ae-expressions.docsforadobe.dev/random-numbers.html

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