Hello, everyone, this is Evan Abrams and in this After Effects tutorial,
we're going to examine methods for creating and animating random shapes.
Sometimes we just want to drop in some procedural changing undulating shapes,
but to make them all manually would be a bore
and not an effective use of your time, talent or energy.
So we're going to look at methods that will give us controlled randomness
in our shapes so you can focus more on making compelling choices, less on labor.
And yes, this does mean using expressions in after effects.
This is a follow up to my video on random expressions in after effects.
So if you want to give that a watch, it might help you out.
But if you have any questions about anything you see,
please get at me in the comments and I'll try to help you through.
And if you enjoy learning this kind of thing,
make sure you subscribe and turn on notifications
so you don't miss any new tutorials when they come around.
Before we get into it, I'd like to thank this video sponsor: Yellow Images.
Yellow Images is the number one
marketplace for high quality premium mock ups, creative fonts, images
360 and a creative store full of amazing graphical assets like brushes, presets,
lettering, illustration, pattern textures, UI, UX kits and much, much more.
I'm really enjoying their graphical asset kits.
These packs of assets, textures, graphics, sometimes fonts and brushes
can really help you create stunning and cohesive pieces
much faster than going out and grabbing all these bits piecemeal.
And while you can buy anything off their site a la carte.
The best value is becoming, a yellow ticket holder.
Think of this like a Costco or Price Club membership
that'll get you the lowest prices. If you're a power user of stock assets.
I also appreciate the yellow image.
They're hooking up with a discount for anything you might want from their site.
The first 100 people to use coupon code ECAbrams20.
We'll get 20 percent off when they use the link in the description.
Pick up some excellent assets from yellow images or a membership.
Big thanks to yellow images for hooking up. Now let's get on with the tutorial.
Let's get the first elephant out of the room, the wiggle expression.
Generally, if you want some randomness in your life, the first thing we do is
drop an expression on a property and roll the dice on what results we might get.
This is most often done with the wiggle expression, but here's the limitation.
The wiggle cannot be deployed on shapes themselves.
Here, I'll draw a random shape with the pen tool
and see what happens when we drop this wiggle
on the path property that defines that shape.
No joy to be had.
The output of the wiggle
simply doesn't make sense with the data that is contained within a path property.
So now that I've shown you the problem, we can move on to a solution.
We can wiggle a path and even a parametric path.
Simply go a little add button, select the wiggle paths option.
And now you can see how Wigley we can be when we play it through.
We can control this just like the wiggle expression.
Size is just like the amplitude argument you would put in the wiggle
expression, pushing the points further away from their baseline.
Detail is how many new points we're actually adding onto that path.
If we have a detail of zero,
we are only modifying the existing points we've already drawn.
Then we can change those points to be corners or smooth.
This can greatly impact artwork
that has sharp corners to begin with. As you can see.
But now we get into the area I'm most interested in how this moves and changes.
Wiggles per second is just like the frequency of a wiggle expression.
How often are we at a new arrangement?
But notice we smoothly move between those states.
So right now, it's an undulating kind of movement.
The correlation number here is how similar each of these points
is moving to each other.
So a hundred percent, all the points are moving in the same way.
At zero it's totally wacky. Everyone's doing their thing.
So if we want random shapes that will not update at all,
we can do zero wiggles per second.
But if we wanted them to snap between random shapes
like they're being hand drawn or maybe we're doing the frame by frame thing,
how do you make that happen if it's not wiggling any times per second?
Well, the answer here is in these phases, we could use an expression
to jump between different temporal or spatial phases.
Maybe we use hold key frames on them or we could modify the random seed down here.
So we're reracking the calculations every time.
An expression like this one posterize time, say maybe four frames a second
and random multiplied by 10 means we're going to be getting the path updated
four times a second
by picking a new random seed that will be in number
between zero and ten, for example.
And as you can see, it looks pretty good. It's updating to new shapes.
You might also consider adding a few of these wigglers in here
with different levels of detail, different speeds.
Combining multiple random methods at once can get you a much less predictable
feeling result as two operators
will have a much lower chance of having similar results back to back.
But maybe this is too random for you if you want control of what
the shape is in a more granular way we need to try something else.
Maybe when you think about random shapes, you imagine like a list of shapes,
like a circle, a square triangle,
diamond, elbow, macaroni, starburst, all the lucky charms are in here.
And you want to randomly, every so many frames change from one shape
to another from this list of shapes To start, I'm going to make a comp
that holds all these shapes.
I've gone ahead and made them all on shape layers.
Each one has a single frame duration.
So this is lasting six frames. The frame numbers, though.
And remember this for later, are frame zero, one, two, three, four and five.
That's the number of each frame.
This is going to be useful when making use of this,
when we drop it into a composition, turn on time remapping,
and then we're going to use this
expression to change which frame of that comp we're looking at.
There are many ways to do this. But here's what I've got for you.
We're going to start with that posterized time.
We only want this to update four frames per second.
Then Variable R is finding the floor, the lowest whole number rounded down
of a random number between zero and six, which is going to be zero,
one , two, three, four or five.
Then we're going to take that number and convert it from frames to time
so that we're looking at those specific frames in the way
that the time remapped property understands, which is in seconds.
If you get some less than ideal changing of frames, like things
don't seem to be updating every four frames a second, I recommend
you purge your cache going edit, purge all memory and disk cache.
Sometimes expressions get cached and stick in the buffer.
It happens, but now this makes unique objects on every frame.
So really, you could be filling that comp that's changing with just about anything.
The same technique might show a random photo, a random layer, a random anything.
It's really just a random frame, which for us in this case is full of shapes.
But maybe you don't like using time remapping.
What if we wanted the actual vector path to change between
prescribed shapes that we want to specifically determine?
To start Let's use the old pen tool to draw a shape.
Then we're going to set a key frame for a new arrangement
of the points and handles, and then a couple more.
And we'd like to
randomly be seeing one of them and then have that change every so often.
Basically, we want to be choosing randomly which of these key frames
we're looking at.
So we can use an expression to help us choose one of those key frames for us.
If we type key and then in parentheses one, we're going to be looking
at the first keyframe.
Whatever value that is key to, that's going to be the second
the number in this argument tells us which key's index number we're looking at.
So let's say we want to look at key X and we're going to make X
the ceiling math.ceil of a random number between zero
and the number of key frames
that we've placed somewhere on this property, or Numkeys,
as we can call it, The math dot
ceiling ensures were always taking the highest whole number
when we're on a decimal.
Then maybe we posterize the time with our posterize time buddy that never gets old.
So now we're switching between a random keyframe's value that we can
manually populate with specific shapes that we're interested in seeing.
If you want to add more.
I would recommend just disabling the expression
that little equals sign here and moving the points, turning it back on.
What's really fun about this method
is that anything based on that path will also update.
I'm talking about repeaters, maybe another layer tracing around that path, whatever
it is, whatever you like, the data that is this path is updating to the new shape.
This also allows us to keep all the stuff on one layer of the comp,
if that's important to you.
Now, these flat shapes are nice, but maybe you want a randomized texture
like I have on here
in many of the examples and in the title cards you've been seeing.
I'm just using the shapes as a matte layer for a jpeg of a texture.
There's nothing more complex going on than that.
And if I want that texture to be randomly changing as well,
we might deploy the same method
that we've used when picking random shapes from a composition full of them.
Or if you don't have many textures
available, you need to squeeze more from a single file,
you may want to make many frames
of looking at a unique rotation, scale or position of that layer.
That's going to give us a texture
that we can put behind the shape that the shape layer is revealing,
because it's being used as an alpha matte.
Now, to make use of this,
we can just plonk this element around wherever we'd like it.
As a composition, we know that it'll just randomly bounce around forever
so we can just extend the duration of such a comp to a very long span
and then just use it like any footage element.
Then we might drop a few duplicates around to make the title card all that fancy
or fill out the space here, vary the size, vary the time by sliding them around.
But hey, if you use a few of these things,
if you put them out there, eventually you might see a pattern emerge.
So someone might notice, oh, these are actually just all copies of things.
We want many random things.
So anywhere that we've used that random expression,
we can use the seed random expression to change
that random number by basically reracking the randomness calculation.
We can then link that random seed to a slider
to get external control of the property, and then we can throw that slider
into the essential properties for this random shape composition.
We may also want to get rid of that posterized time expression and instead
make use of a posterized time
effect, place that over everything on an adjustment layer.
And then maybe we want to take that frame
rate of the posterized time effect into the essential graphics as well,
in case you want to have some instances update faster or slower.
More often, less often.
Basically, anything that you want to
change about the instances of this little thing, we want to put that
into the essential properties and look at this.
We can now deploy these comps out here in space, make them all unique by changing
that slider in their essential properties, creating unique random instances.
You might also use this composition as a particle system
so that you can enjoy a swarm of these things out here.
In this example, I'm using trap code form by Red Giant.
This is a third party plug that makes arrays of persistent particles.
Using this composition as the texture of the particle,
we can quickly make arrays of them in the space if we need to fill in a
big background with them.
By asking the plug in to sample a random frame or by dialing in
many of the options, we can create all kinds of random arrays of random things.
And there are many, many particle systems or array plug ins you might deploy.
You don't need me to go into them here.
I think we've driven home the point enough for one video.
Well, I hope you've enjoyed this follow up to the Random Methods
tutorial if you need more randomness in your life definitely check that out.
If you enjoyed learning this kind of thing,
please subscribe and turn on notifications
so you don't miss out on any new tutorials around here.
Should you have any questions?
Please do get me in the comments and I'll try to help you out.
You can find more of me at SC. Abram's all around the Internet.
My DMS are usually open, so please reach out if you have any troubles at all.
Thank you so much for watching.
Be kind to each other and I'll see you around the Internet.