Random Expressions in Adobe After Effects

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello everyone this is evan abrams and in this video i'm going to show you some random expressions in adobe after effects not random like they're disconnected and disorganized but random as in these are expressions that we use to generate random numbers random numbers are important in expressions and any coding because they can be used to drive all kinds of procedural and organic results we're often using expressions so we don't have to do as much manual work to create motion or change in our animations being able to create random procedural organic movement or change with expressions is very useful so follow along as we look at some of these methods and some examples of their application and ways you can control or refine randomness to use it more effectively this video is brought to you by skillshare skillshare is an online learning community with thousands of inspiring classes for creative and curious people explore new skills deepen existing passions get lost in creativity if you're looking to learn about animation they've got plenty of courses on that as well as design photography illustration film all are great and taught by experts at the top of their craft experts like claudio salas who has a really great class called animating with purpose it's all about expression and intention and conveying feeling with your animation he shows how to trick the brain with movement to create feelings in your audience i think this is a really fundamental part of animation that can really elevate your work so definitely check him out skillshare is curated specifically for learning meaning there are no ads and they're always launching new premium classes so you can stay focused and follow wherever your creativity takes you the first 1000 my subscribers to click the link in the description will get a free trial premium membership so you can explore your creativity big thanks to skillshare for helping out the channel but now let's express ourselves with some expressions first is just the random used like this on every frame it will get you a random number between zero and one and as you can see out to a heap of decimal points if you want to get some more control over this you can specify a different range the arguments you might put here in the parentheses in this case are the range that that random number will fall in now for example we'll get a random number between 10 and 100 this could also be an array so we might deploy this on the position and get a random location somewhere between zero comma zero and a hundred comma a hundred but random and really any of these methods aren't used in a vacuum or on their own so let's look at some examples of how we might use and modify this the first and maybe most obvious use might be just generating a random number so let's say you have an fui kind of project and you need just a few random numbers hanging around i mean just hammering on your keyboard is nice and all but it's hard to animate that kind of thing and eventually there are human patterns that start to occur so we can automate this kind of element by simply using this expression on a text layer's source text you can do this by holding alt and clicking the stopwatch to enter the expression random 1000 comma 9999 for example will always get you a four digit number but ooh so many decimal places no worries we can use the classic math.round to sort that out we just put the randomness inside the math.round and scotch is sorted out there are heaps of math you might use but this is a common one just to round off a number but maybe you want a certain number of decimal places well then you could deploy the dot to fixed at the end and pick how many decimal places you might want and just a little bit of advice as you can see here when the numbers are changing the size of this text layer changes a lot it's bumping around so if this is for an fui project you can clean it up by using a mono width font and you may need to set the kerning over here to metric now it's always going to be in alignment nice and robotic and static and what's lovely about this is that it's also based on the layer index if you need a new one of these just go ahead and duplicate the layer and look at that you've got a fresh new also random layer as many of these elements as you want it's that easy duplicating is done by clicking command d or control d on your keyboard it's good shortcut to know now we know random can pick from inside an array colors are a four part array that shows how red green blue and alpha a given color is so what if we ask this random that we've placed on the fill effect here to get me a random color between two arrays and maybe those arrays are ones across the board two zeros across the board which would be all the colors possible as you can see that's pretty nice or let's get specific and replace those two arrays with colors that i've chosen using the color control effect just turn those into variables a and b then we put those into the random as the upper and lower bounds of randomness and now we have a new color every frame that is chosen from somewhere between those two other colors if you go about using this kind of thing just remember that the numerical transformation from one color to another may not be the same as you envision often there are muddy or sub-optimal colors in between that you may not be interested in seeing but because random is going to get you anything in between those values we don't really have that much control over avoiding these muddy values unless what if instead we use the random number to pick from a set of things like say we wanted this text here to say either the words one two or three we can set this up in a few ways but i've just made an array containing these three strings you can see inside these square brackets here we have each word in quotes separating them by commas this is essentially a three part array it could be any kind of data you wanted in any number of parts that you wanted and i would like to look at a random part of the array so i have variable r being math.floor and then a random number between 0 and 3. and of course you can do this many ways but this is going to net me a random number between 0 and 3. since i'm taking the floor if there's a decimal i'm going to get the lowest whole number which means 0 1 or 2. then i'm simply asking for the arth part of variable a which is the array so which r part of the array are we looking at well it's going to be picking a new word on each frame as it looks for part 0 part 1 part 2. but hey wait a minute maybe this is going too fast let's not look at every frame let's not evaluate this on every frame i'm going to add a posterize time and then in its argument 4 meaning 4 frames a second above everything here and that's to say hey slow it down stop working so hard don't run your expression on every frame just do it at 4 frames a second okay you could use this on any property to pick from any array of values colors numbers anything that you might put in there so if you have a specific list and you want to choose from that list randomly give this method a try here's a second kind of randomness you might think about using the gauss random works very similar to the random except that the distribution of numbers it's going to return will be different with random you have the same chance of seeing any value in the range come back to you but with gauss random the values are distributed in a bell curve around the mean that means that more value is going to be clustered towards the middle and tapering off towards the edges in this example we're looking at here on the left you have random dots appearing and i've used the echo effect so they stay on longer and on the right we have gauss random dots appearing and notice how they cluster in the middle less around the outside and a small percentage of them actually fall outside of that range as well you can see sometimes they're really outside the range this can provide a more natural feeling randomness because of this normalized distribution of results so let's look at some examples of where you might deploy gauss random over regular random here's a radar screen where we have a dot that randomly shows up in different places i'm using the regular random to change the rotation that this dot is going to be around but the position of this dot is being driven by a gauss random so the distribution of change to the anchor point is being chilled out a bit and it's been clustered around the middle that means that these blips will mostly be in the mid-range which will create a more visually pleasing composition instead of the true chaos of randomness i'm also reusing that posterized time to make sure that these changes only happen so often but wait a minute wait a minute remember in that last example where some of the dots were appearing outside of the range that wouldn't be super helpful because in an fui context you would probably want these things to stay inside of their prescribed screens we should probably clamp down on the values a little bit which we can do by using clamp clamp just takes everything below or above that range and clamps it in so if both ranges are the same nothing is going to be getting outside of the lines but most of the stuff will still be adhering to this bell curve distribution of a life hack for you here here's another example let's say we're going to fly through some asteroids and manually moving all of these lumps around might be unpleasant or more work than we want to do i don't want to actually choose where the asteroids are or maybe this needs to be generative for some reason we could use many methods but one that can help we've only got a few asteroids to kick around is the gauss random specifically i'm applying it to the position which is a three part array i'm specifying the two ends the two edges that i want this to be contained within which in this case is being defined by two variables a and b which are themselves full of variable v variable v is the amount that's being dialed in on a slider so variable a is all positive v's variable b is all negative v's this is more for illustration purposes than it is for clean coding but the point here is to show that the inputs of the randomness are one positive set of coordinates and then one negative set to the same degree creating a kind of cube in space that these things are going to appear inside and we can grow or shrink that cube using the slider and we now just by duplicating the layer have a nice cloud of asteroids hanging out but certainly we don't want the asteroids shifting about on every frame that's not useful or even every other frame maybe we don't want them to shift around at all so here's another little method to help you control your randomness it is the seed random expression seed random determines sort of what universe of randomness we're talking about since we're simulating randomness we can skip into other sets of randomness by simply picking a different seed so by setting the seed we can choose what kind of universe we're in if i set that seed to look at the slider control i can basically re-rack the simulation by simply sliding to a new value kind of like a late 90s science fiction show where they go to marginally different dimensions we can also choose to make this timeless or not meaning it will no longer evaluate on every frame by choosing true as in it is true that this is timeless we won't see any updates at all so now we have this static randomized but a little bit controlled asteroid field that we can shuffle around at a whim if we don't like the arrangement using that slider control now for something a little bit different also in the random family is noise but noise works a little bit differently noise has only one argument and needs exactly one argument in order to work if i just put in a number notice it's not updating or changing or giving us different values on every frame this form of randomness is deploying noise like you see with other noise effects like turbulent noise fractal noise purlin noise but it's being used as raw numbers in an expression i find it's helpful to think about this argument as where on a big image of noise we're looking to lift a value from as if we were looking at a big solid covered in fractal noise and we're sampling a part of that image in fact since noise can take one two or three part arrays you might think of it more like a cloud like we're looking at somewhere in the cloud and figuring out what's the value of this voxel in this cloud so where we're looking in the cloud is going to change what values can be returned to us and since this cloud is more of a soft but random transition from one value to the next as you navigate as you float through the cloud you get similar values as you go so what can we do with this kind of randomness well it's great for making anything that needs to smoothly change over time here we have some lovely dial elements that need to just be randomly rotating around i'm currently using time as the driver here so they're constantly changing and since the result of the noise is a number between negative one and one you'll want to multiply the result of the noise by an amplitude or a factor so that the numbers are creating enough of a change in the value of the property like in this case we want to make a large change in rotation but we could also use a slider as the driver instead so i could have one key frame that's moving from 1 to 10 that's going to create this random motion that's going to slow as we ease out of that change on the slider so we can have this nice kind of ramp up and ramp down feathering off the random movement have a look at this graph editor real quick and you can see the relationship between the keyframes and that random rotation how those things are intersecting pulling the handles kind of squishes this line of wackiness together or pulls it apart it's an interesting way to have more control over random motion than say the wiggle expression one of the first expressions that most people use having this ability to throttle the frequency smoothly is really interesting when it comes to feathering on and off randomness since we said that the noise can sample somewhere in a 2d or 3d array we can create something like a little rumble as something moves so if we take a look at this triangle here and it's going to go on a journey through space in this case it's changing its x and y position through space i can just link that to the rotation that means that the faster that this layer moves the faster the position changes the more quickly we're going to run through different patches of the noise to look at the more jostly the rotation is so it seems like it's encountering turbulence it's getting bumped around a little bit it's an easy way that you can use one property to then drive another but have that little bit of randomness in between it's not linear the way one thing drives another it's random thank you so much for watching i hope this gives you something to grow on as you continue your journey into after effects and expressions no matter how random it may get if learning about this kind of thing is for you then subscribe to this channel and check out some of the other videos on here i've got plenty of stuff on here about expressions other functions other operators you might use and i'm putting out new stuff all the time so make sure that you turn on notifications so you don't miss a single one of the new tutorials as they go up if you have any questions about this stuff anything you've seen on here get at me in the comments and i'll try to help you out when i can and please get at me if you have questions about after effects motion design expressions i'm at ec abrams everywhere on the internet twitter instagram behance twitch all the places but that'll do it for me thanks again so much for watching stay creative be kind to each other i'll see you all around the internet
Info
Channel: ECAbrams
Views: 30,525
Rating: undefined out of 5
Keywords: adobe after effects, after effects, adobe, after, effects, fx, mograph, motion graphics, motion, graphics, vfx, visual effects, instruction, tutorial, tut, how to, how, to, help, tips, tricks, after effects tutorial, motion graphics tutorial, vfx tutorial, random, expression, gaussrandom, ramdom, rando, random expressions, noise, shake, wobble, link, random motion, scripting, expressions, after effects expressions, random in after effects, randomness, randomness in after effects
Id: xrKMeeFrMxg
Channel Id: undefined
Length: 14min 38sec (878 seconds)
Published: Mon Jul 19 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.