You NEED to understand spaces in After Effects | After Effects Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
this video is made possible by envato elements stick around to learn how you can save 50 on an annual subscription hey it's jake and today i want to talk about some weird stuff that happens in after effects when you apply certain types of effects to certain types of layers and we're going to talk about layer space and comp space and even parent space and what all these spaces mean and how you can manage it all using simple expressions so you never have to think about it again let's get started [Music] if you've ever applied a gradient to say a text layer and then move that text layer around you'll see that those two points that start and end the ramp don't stick with that text layer and maybe you've used a distortion effect like cc bend it and applied it to a shape layer and those again those two distortion points don't stick with the shape well this is all because of the way that after effects is actually looking at those types of layers so let's actually just jump straight into after effects and i'll show you what i mean here i have my logo which was designed in illustrator and i brought it in as footage so currently it's not being continuously rasterized so if i went ahead and applied a ramp to that layer and then move that layer around the ramp is actually going to move with it the start of the ramp is up here at the top or wherever i put it the end of the ramp is at the bottom of the layer or again wherever i put it and it's going to stick with the layer and move around with it those two points will always be right where i left them but as soon as i continuously rasterize it by clicking on that switch both the start and end of the ramp points have moved and if i move my layer around they are no longer stuck with it it's like they were unparented and this is because of a thing called layer space versus screen space and at their most basic those are both just ways of mapping out the pixels on your screen or within a layer so layer space is the coordinate system used in a specific layer so if i turn off collapse transformations for a second and move the start of my ramp to the top left corner and then we take a look at the actual controls for the effect the start of the ramp that i move to the top left is very close to zero zero so if i just set it to 0 that's actually the origin of my layer space the top left corner of any layer in after effects is always a value of 0 for the x and 0 for the y that is the origin of the layer space moving this point control to the right increases the x value and moving it downwards increases the y value so this is just a simple x y graph for the pixels of the layer for any standard layer like this that's not vector meaning basically anything that's not a shape or a text layer that coordinate system moves around with the layer wherever you put it which is why effects with point controls like a gradient ramp stick with the layer when you move them around it's because that whole coordinate system is parented basically to that layer but as soon as i make this vector layer continuously rasterized with this switch right here then after effects is no longer looking at this layer in the same way instead of mapping those pixels in that coordinate system to the bounding box of the layer it expands it to be the size of the comp after effects is now looking at this layer that's continuously rasterized in comp space so what is comp space it's actually really similar to layer space but instead of being in relationship to the layer it's in relationship to your comp but if i bring up the transform controls for this layer even though it's continuously rasterized the position value is relative to the comp and just like the top left corner of every layer is the origin of the layer space the top left corner of the comp is the origin of the cop space so if i were to move my layer which the position is based on where the anchor point of the layer is so right in the center of the layer if i move that towards the top left of the comp then this value is going to get very close to zero so again if i make this zero comma zero on the position then my anchor point is lined up perfectly with the top left corner of my comp again moving it downwards is going to increase that y value moving it to the right is going to increase the x value so it's the exact same pixel coordinate system as layer space it's just in relationship to the comp instead of to the layer but that's not the case when it comes to the anchor point of a layer the anchor point is always in relationship to the layer space so if i move this around it's going to shift the contents of the layer and if i just set it to 0 0 then it's going to be in the top left corner the origin of the layer space but the position value is always in relationship to the comp space as long as it's not parented to something else i know that that's just making it even more complicated but we'll get to that in a little bit i'm going to undo so my anchor point is back in the center of my comp and then point out that this applies to any vector layer so whether it's an illustrator file that you're continuously rasterizing it could be a text layer or a shape layer all of these layers are interpreted by after effects in the exact same way with comp space instead of layer space so that's why when you apply an effect like cc bend it to a shape layer those point controls are going to give you a headache because they're never going to stick with the contents of your layer unless we use a handy little expression called 2 comp but first i want to tell you about this video's sponsor envato elements envato elements delivers unlimited access to over 55 million assets like fonts photos video templates wordpress themes and even adobe templates and it's all provided with a very simple license that lasts even after your subscription to envato elements has ended my favorite part about envato elements is that you have access to all of these assets with one subscription price which is a lifesaver for any freelance gig where time is money for both you and the client being able to quickly find high quality assets that i can plug into any project without having to create them myself is such a time saver like this character illustration along with the scene elements that lets me jump straight into rigging and animating instead of having to design my own characters or being able to download literally thousands of high quality textures that are just ready to use and that's just the tip of the iceberg because remember you literally get access to over 55 million assets with your subscription to envato elements and if you sign up for an annual subscription to envato elements using the link in the description you'll get 50 off meaning that you'll get everything in their library for less than 20 a month which is an insane value and an absolute no-brainer for doing your own client work so make sure to check out the link in the description and thanks to envato elements for sponsoring this video all right now how do we use the expression to comp well you start by writing out two comp with a capital c and then two parentheses and in between those two parentheses we're going to put an argument so this can either be an array that holds a position value so multiple numbers either two dimensions or three dimensions and what this expression is going to return is basically the distance between what we're applying the expression to and what we're targeting within this argument and the reason this is valuable is because even though after effects is looking at these vector layers as if they were existing in comp space we can take the position value basically ignoring wherever i place my layer in the composition and calculate the distance between the actual position of the layer and the top left corner of our comp and this will allow us to actually stick those point controls wherever we want them on our layer even if they're vector layers and they'll always stay right where we left them so let me show you exactly how to do that and i'm going to go ahead and delete my logo and i'll just type out some text we'll just say point and i'm going to apply that gradient ramp to it again so just to show you again what's going on my start and end of my ramp are set up here and down here and if i move my text layer around the effect does not move with it even though the transform position is moving around and it is in relationship to that comp space of the top left corner as the origin of our coordinate system these two point controls are being placed by after effects as if the layer is the size of the comp and it's not moving around at all it's weird but that's just what's happening so let's say that i want this point to start at the top of the text and this point start at the bottom and for it to stay with it no matter where i move the layer well that's where we're going to use to comp so let me go into the effect by pressing e and then i'm going to add an expression on the end of ramp property by alt or option clicking on the stopwatch and i'm just going to close these up so we have a little bit more room to see the expression and what i want to type in here is first what we're targeting because two comp is actually in relationship to whatever you apply it to or whatever you select to apply it to so what i want to know is what the distance between the position of this layer is and the top left corner of my comp so i actually need to just start by typing in this layer to target the actual layer that this effect is applied to and then put a period and then type two comp with a capital c i'll use auto fill to add those parentheses and between these parentheses is what we're basically measuring to so what do we want to know the relationship between well it's going to be this layer to the top left corner of the comp so to comp and within those parentheses i'll start an array and type in zero comma zero comma zero now i'll be honest i don't have to put this third zero in here because this is being applied to an array that will always be two dimensions and the only reason you would ever need three parts of this array is if it was an effect that used either two or three dimensions so if you were applying this expression to maybe the position property that's where you would want this third dimension because a position property can have either two or three dimensions so that array could be different and if you only use two zeros for the first two dimensions then it would give you an error when you make it a 3d layer so i just do this out of habit out of good practice to make sure that there's always a third dimension accounted for it's not really going to slow anything down and even though it's not needed it's just kind of a force of habit so that's why i'm using three dimensions so what we're saying with this expression is what is the distance between this layer and the comps coordinates of zero comma zero comma zero which is the top left corner remember the origin of that comp space i'll just click off to apply that and my gradient has updated so if i click on my gradient ramp effect the end of the ramp is now tied right here to the bottom left corner of my layer if i click and drag this around that point is always going to be attached to the origin of my text layer and right now that happens to be where the anchor point is but if i were to move my anchor point using the pan behind tool or the anchor point tool that's y on the keyboard then the gradient's not moving it's looking at where that origin point was which is separate from the actual anchor point now i could tie it to the anchor point if i go back into this expression and change zero comma zero comma zero to this layer dot anchor point and now the end of the ramp is tied to my anchor point so wherever i move it that's where the point is going to be i didn't actually want to do that but i just wanted to show it as an example that you can tie it to the actual anchor point let me undo and get back to where my anchor point was already at my text layer's origin and then point out that i can no longer adjust the end of the ramp i can't click and drag it and i can't move this around and that's because it's just overriding it with the expression that we wrote which again is just telling that point to be wherever the origin of my layer is wherever this layer is in relationship to the comp's origin of zero comma zero comma zero and that's not exactly what i want i want to be able to align this point to the top of my layer so what i need to do is just add a simple little expression at the end which is just a plus sign and then value and i'll finish it all off with a semicolon click off now what's going to happen is it's going to take whatever value i put into this array and add it on top of the expression that i wrote to get it to align to the origin of the layer so if i just zero this out then it's going to go back to the origin of my layer the bottom left corner but now i can offset this value because we're adding the value of whatever we applied here so i'll just move it to the top center of my layer and now if i move my layer around that gradient point is staying with it now we still have the issue of the start of the ramp not sticking with the layers so i'm just going to select this expression copy it and then go to the start of the ramp value alt or option click on the stopwatch to add an expression and paste it in and now we're going to have the exact same thing happening i can move this point wherever i want it on my layer and then move my layer around and those points are always going to stick with it so if i wanted to do more of a diagonal i could do it like this if i wanted to blend this on top of the color that was already there i'll just type in a cc composite effect apply that after the gradient and change this to screen and now i have more of a highlight effect going on on top of my layer and i can play around with this however i want maybe change the colors a little bit so it's a little bit more golden but now i know that that gradient is going to stick with my text that is until i say maybe change the size of the text or even scale the layer then it's broken again and this is because remember after effects isn't really looking at the contents of this layer when it's applying these effects it's basically viewing this layer as if it was the size of the comp regardless of how big this actually is or where it exists in the comp so these two points don't realize that the layer just got bigger and that these two points should move with it they're only calculating the distance that they are from the origin of the layer which scale and rotation doesn't actually change so we need to do a little bit more work to get that to actually function the way we want and i'm going to do it with some null layers so i'm going to go up to layer new null object if you've never used a null object before it's completely empty layer it does not render all it does is gives us values basically that we can attach things to so i'm going to name this one point a and then i'll duplicate it with command or control d and rename this one point b and i'll just move them around so they're not in the exact same space now what i need to do is go back to my gradient expressions and update it a little bit instead of looking at this layer i now want to look at the null object layers so i'm going to just select that text and then use my expression pick whip to grab let's say point a since this is the start of our ramp so i'm just going to select the layer i don't need to select any specific property just that layer and then the rest of the expression can actually stay the same i'll click off and now this point a control is going to be where the start of the ramp exists even though the effect is on the text layer it's looking at a second layer for its information so let's copy that expression and apply it to the end of the ramp as well but we're going to change point a to point b since that's the name of the second null object and now i have two independent layers controlling where the gradient ramp is on my text layer but it's actually not working exactly right yet and that's because we still have this plus value at the end and we actually don't need that anymore we want these points to be locked in exactly where these two null objects are so let's just edit that expression one more time get rid of this plus value on both instances make sure we don't get rid of anything we shouldn't and now these two null objects are going to specifically place those two points of the gradient ramp they're still not attached to this layer but we can fix that very simply just by bringing up our parenting and grabbing both point a and point b and parenting them to the layer now wherever the layer goes the null objects go with it so let me just reposition these null objects so the gradient looks the way i want it to and now wherever i move this layer that ramp is gonna move with it even if i rotate it because those two null objects are parented they're gonna move with the layer exactly the way that you expect i can scale this down move it around do whatever i want and it always lines up the only instance where this isn't going to work is if i increase or decrease the actual font size and you could get even more advanced with expressions to use source rected time to map the position values of these two null objects to whatever size this text is but honestly that's a lot more work than you probably need to do when you could just scale the layer up or down but that's how i align any point control in any effect that uses them to a layer that just doesn't want to cooperate and just in case you were wondering why i didn't just use the position property as the source for where we tie the start and end to let me actually just show you why that's not a good idea i'll double tap the e key to bring up our expressions and instead of using the two comp expression at all i'm just going to type in transform dot position and that will target the position property of this layer specifically so i'll click off of that and now the start of my ramp is wherever the position is for this layer which if you remember the position property is in relationship to the comp space so it's actually doing what i want but in order to place the point exactly where i want it i need to account for that so i'm going to say plus value remember the value of the start of ramp property click off and then i can modify this to be whatever i want so i'll put it right at the bottom center of my layer and moving my layer around it does indeed stay right where it's supposed to the issue is if you were to ever parent this to another layer so if i make another new null object layer new null object and move it down to the left then i parent this point to the new null object already my expression is broken and that's because the position value of any layer is actually relative to any parent so as soon as i parented this text layer to this null object we're throwing comp space out the window the coordinate system is now basically parent space it's wherever this point is is the origin so if i move this to the top left corner of the null object then bring up the position value with p on the keyboard that is very close to zero we now have this weird parent space basically so that's what two comp is accounting for it's measuring the distance between whatever you're targeting in the first part of the expression with whatever is in the argument of the second part of the expression most often than not it's whatever we apply it to to the origin of the comp which is zero comma zero comma zero so regardless of whether or not something is parented it's going to take wherever it exists in the comp at that point in time and measure the distance to the top left corner of the comp and that's why we use two comp instead of just targeting the position value of any layer but now you should have a pretty good understanding of the two comp expression and how all of these weird layer comp and parent spaces work so you really don't have to think about it anymore if you just set up the two comp expression to target what you want and what you want to measure from then you should be able to get these point controls to stay right where you want them to be i really hope that you learned something in this tutorial and if you like the video be sure to give it a thumbs up make sure that you subscribe to me if you're not already and hit that notification bell so that you know exactly when my new videos go live and i just want to say a huge thank you to all of my patrons over on patreon if you're interested in supporting more videos like this one then please consider becoming a patron and if you like my teaching style then definitely check out my longer form content on skillshare and school of motion you can find links for all that stuff in the description of this video thank you so much for watching i hope you have a great day
Info
Channel: Jake In Motion
Views: 14,169
Rating: undefined out of 5
Keywords: after effects, after effects tutorial, adobe after effects, after effects tutorials, tutorial, adobe after effects tutorial, after effects for beginners, after effects basics, after effects animation, adobe after effects (software), after effects tutorial for beginners, after effects tutorials for beginners, tutorial after effects, adobe after effects tutorials for beginners, adobe after effects tutorials, learn after effects, jake bartlett, madewithenvato
Id: gSq19gpWwSU
Channel Id: undefined
Length: 19min 9sec (1149 seconds)
Published: Mon Nov 08 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.