The ONLY Vector Displacement Tutorial

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
vector displacement is one of those methods that you hear about you hear about it being complicated you see it in november stuff and really there are a couple but generally there are no good resources for very very beginner vector displacement i just want to focus on some simple vector displacement taking a cube and turning it into a pyramid a sphere a cylinder a cone basically swapping out primitives with genus zero if you know that that topological like thing about shapes point is we're going to be taking shapes and converting them into each other because i don't think there is an easier way to teach vector displacement so get your blender open and ready because by the end of this tutorial you are going to know what it means for displacement to be vector displacement specifically and how to do it so let's do that a couple things to keep in mind whenever you're doing vector displacement you need a couple settings before you can even do it in the first place which you know inherently confusing but it it's a that's just the case first of all render engine it needs to be set to cycles um deformation or just in you know general um material based displacement does not work unless you're in cycles you could do the displacement modifier and it works with ev but first of all make sure you are in cycles that's the first thing second thing to think about is since we are doing displacement deformation of the actual like geometry like we're moving around vertices um it's always useful for a modifier to be added which one is that that's going to be subdivision surface i'm just going to set this to simple so that doesn't actually change your geometry and we're just going to add a couple divisions so what's happening here and we can actually view this with like a wireframe shader is we're adding additional geometry even though like the silhouette looks identical so again um it's always useful for whatever base mesh you're starting off with to have additional geometry and then the final thing and this is where i think a lot of people probably get caught up thinking damn has never cut out for this is in the material settings make sure you scroll all the way down and go to the settings inside of the material settings kind of like those russian dolls and then displacement change this from bump only to either displacement only or displacement and bump in other words we want our displacement not to just be based on normal mapping and you know all that bump mapping stuff um but also geometry based displacement i use displacement only because uh the third option has some like lighting artifacts and stuff like that um i think it's because it's trying to like preserve some kind of orientation of normals or something like that point is use displacement only so once you have the render engine set to cycles the subdivision surface and the material settings with displacement only you are now ready to begin so vector displacement how do you do it what is it and is it important for what it means to be a human long story short everything we do in the material you know the material workspace what's this called shading workspace shader editor everything we do in here kind of goes into three categories it's either a surface property like the principled vsdf where we're literally changing what's on the surface it's either that a volume property so in other words kind of like a volumetric cloud smoke stuff like that so the interior of the mesh and finally we have the displacement type which is the one we care about and this is about changing the geometry to begin with so uh we are not concerned with either these green sockets we are just going to be manipulating this displacement socket okay and really you can just plug in a vector to begin with and we'll talk about what that means so for example i'm going to use combine x y z this is just a three component vector x y and z um so again it's kind of like a vector in three dimensional space with an x y and z component you connect this and if it actually lets you do that um you're gonna see that nothing is happening why because in some sense we are displacing we are moving our geometry by uh the zero zero zero vector in other words do nothing is what blender has right now um instead of this what we can do is say move it on the x-axis and it's going to do that by exactly two units three units whatever it may be we can also go down the y-axis and the z-axis okay and so far it's pretty simple but there's kind of a key inside here that's not so obvious the key insight is that this vector describes some kind of transformation it does but it doesn't describe like the final position of the vertices right it's not like every one of these eight vertices moves to the vector 3 0 0 it's that everything's being displaced it's being changed by this vector so in other words we are adding the vector 3 0 0 0 which basically says move every vertex 3 units to the right okay so again key insight here is we're not like messing with the texture coordinates and and all that we're just saying displace not final transformation just move it okay and you could also do this with a single value although it will i think it will assume that x y and z are the same in this case so we'll be moving diagonally so right now it's saying um negative 2.2 for x y and z etc um you know and that's a thing so we could just say you know displace it in one direction but that's not too interesting because we want to like reshape the thing meaning we kind of need information about this geometry to begin with because you know you could do the combine x y z for an arbitrary mesh like the susan monkey or a sphere or anything like that but it doesn't really say anything about what mesh this is so to do that moving on we need texture coordinates and you've probably already messed with texture coordinates we have generated normal uv blah blah blah blah um long story short um object coordinates are usually the easiest to work with because they basically tell us exactly what the position of every like point or vector on this cube is so for example uh you're going to see that it's it's almost as if you can imagine that there's like an origin at the middle that's why there's these crosses that would be the vector 0 0 0 as we go up everything tends to get a bit a bit bluer because the z components getting larger and we can actually like view it like this um so you can see we can see the x component getting larger as it gets brighter and wider same with the y axis and the z axis and this just gives us the points the vectors of every you know position on this cube okay um so ideally we like to use object coordinates or kind of identically position coordinates from the geometry node the only difference here is if you move the cube it doesn't move with it whereas object coordinates do because they're based on the origin of the object okay so we're going to be using object coordinates on a very technical level if you're actually putting textures and masks and stuff on here and you want them to move with the deformation we actually need to use generated coordinates and transform those but for now uh do not worry about that for now we're just kind of having this white mesh that we're going to be manipulating using object coordinates okay so first transformation we want to do is be able to turn this cube into let's say a pyramid and you might be thinking okay how do we do that without hopping into edit mode taking this face and like scaling it down well in some sense this instruction of scaling down the top face is exactly what we're going to do in vector displacements right so as we go up the z axis what we want is for x and y the other two axes to be pinched um so that at the top they're at a scale of zero okay so how do we kind of describe that well first of all we separate by x y z so i can say okay we want to look at the z component as we're going up again we're baking these um edit mode instructions into like a mathematical procedural kind of instruction manual okay we're saying we want the z component uh one kind of technicalities right now z is negative one over here then at zero then it's one because again half this cube is under the ground point uh before we do any transformation i just wanna fix that so map range negative one to one is basically gonna say take the input negative one to one and map it to zero to one so now instead of going from negative one to zero to one starts at zero so wherever wherever we have a negative one map it to zero and then go all the way up to one and in fact i guess we wanna invert this so i'm just gonna switch these around okay so right now what we have is a z direction gradient that is a one on the bottom and zero on the top which is perfect because what we want to do is scale is scale this um as it goes up right so here it should be scaled by zero so it's pinched and here it should be be preserved so we're scaling or multiplying by one and just before we actually do this transformation just so you can see what's happening what we're going to do is we're going to do some kind of transformation with object coordinates and and if we were to plug this into displacement directly you're going to see that i mean we could have it like move around um like we did before but one thing you're noticing is that the cube itself got bigger again why is this the case because displacement is a change it's not a final position so in some sense we've actually added in object coordinates that we don't even want so no matter what we do at the very last step of your vector displacement should always be subtracting away the original coordinate system again we need to get rid of the initial state so now we have a setup that lets us kind of add this so this is identical to doing that combine x y z from before but now we're just adding object coordinates and then subtracting them again the reason to do this is because we need to transform those object coordinates in the first place otherwise we would we wouldn't uh be messing with adding and subtracting the same thing it doesn't really make sense right and you know we don't have to have addition we could have it be multiply so let's set this to one so nothing changes um you could scale on each axis individually and that's pretty much what we're going to be doing just with a gradient okay so that's the lesson so again we want to be using this gradient as we go up the z axis we want to scale x and y by this gradient so again i guess i shouldn't have deleted it what we're going to be doing is using a multiply set this to 1 1 1 so nothing changes and i just want to be very very clear about this let me actually clean this up so it's easier to look at i want to be very clear about this the last step of the displacement of the vector displacement displacement should always be subtracting the initial coordinate system whichever one you used whether it be a uv or a modified generated coordinates like i was talking about a bit too advanced for this one or object coordinates or whatever you always end over here by subtracting that same uh coordinate system so i usually like to give this thing a color to remember we could do a bunch of stuff here but it has to connect to the subtraction at the very end okay so how do we turn this into a pyramid for example well we could multiply not by like a single vector like 1 1 1 but we can use the gradient so i'm just going to connect this here for a bit more control 1 1 1 is basically the same thing we had before but this time for the x and y axis i'm going to use this gradient so i'm just going to connect it here and here and you can see it gives us a very nice pyramid that gives us you know the bsdf surface once we actually look at it okay so this is our transformation again the reason it works is we have the z component isolated let's uh not have this transformation we have the z component isolated as we go up the x and y since that's what we have connected are going to be scaled closer and closer to zero in other words that's the same thing as like scaling that face in okay so let's apply that and one kind of cool thing is once you have this kind of mini node group or i guess it's not a node group this mini setup you can take it ctrl g and turn it into a node group and i guess we don't need to actually see the results so let me just get rid of that we don't actually need to see the gradient i just have the vector displacement the neat thing about this is we've basically made a step that describes exactly exactly if i can remember how to spell pyramid need to watch more yu-gi-oh exactly how to make a pyramid which means we can actually take these we could blend them together with like a mix node or something like that and i guess make sure that you're blending in the original coordinate system it will like to take generated for some reason uh we can mix these together so we can actually have a transformation effect going from one to the other okay so um that's one let's say now we want to turn this cube so not really the pyramid but the cube and by the way just to be very clear about what's going on here again we are deforming the actual geometry uh so you can see right now we have the subdivided cube that we can have a arbitrary number of subdivisions uh we take this we do our vector displacement and when we mix it you can see it's actually moving the actual geometry which is why the wireframe's changing and the more geometry we have for this typically the better for a pyramid it doesn't matter because it even works with as few as eight vertices but for sphere it does matter um so let's say we want to take this cube and turn it into a sphere with the pyramid we had an easy trick of pinching it near the top but how would we do like a similar thing uh well how would we mathematically describe turning this cube into a sphere well if you were to model it i'd probably subdivide it a couple times just add some geometry and then there's this like two sphere command that i think should let us yeah make it into a sphere so if we were doing it in edit mode this would probably be the technique so how do we take this and turn it into vector displacement mathematical knowledge knowledge language that's probably it um so for the divisions we already have it taken care of but how do we do the to sphere command well the the way the two sphere command works is what it does is it takes all our points i guess every vertex we have depending on the number of subdivisions it looks at the length or in other words the magnitude of that position vectors again it's looking at all the points it's looking at how far away it is from the origin and then it's saying we want to normalize those lengths so every length should be 1 or two or whatever and the reason that works is because a sphere is basically a set of points that are equidistant from an origin so if we were to make all these points the same distance from the middle it will kind of map it to a sphere so the corners are going to be pinched in more the stuff near the top won't move as much or towards the middle won't move as much et cetera okay um so in vector math language we do this by taking again um even even though we have this mix we can take this as our last step of the vector displacement so we can chain more stuff here what we could do is add in a vector math node put that in here and there's a command exactly for this normalize um and again what it does is it looks at all the lengths of these incoming vectors and it multiplies or scales them by the reciprocal in other words it normalizes them takes them all to the same length and this is a good time where you can do shade smooth to make it look a bit nicer and just like last time we could mix these two steps together so now we're going from a cube to a sphere and by the way if you want shade smooth without like smoothing on the cube version one thing you could do is in the normals apply auto smooth which is saying only smooth if the angle between any two polygons or faces is like less than some threshold 30 degrees although sometimes we need to bump it a bit more and another way to make this better without doing that is you could add in more geometry so there's a harsher crease but now we have a way to go from like a sphere to a cube and to a pyramid and you can even go from a pyramid to a sphere although it won't work as well because the geometry has actually been manipulated uh manipulated so we're kind of pulling geometry from weird places especially near the top where we've basically compressed the entire uh top face so order of operations does in fact matter um but now we have a way to turn this into a sphere um let's do one or two more uh let's do a cylinder if i was to turn this sphere so again you could start with the cube the pyramid or whatever but since we're doing them one after another how would i turn the sphere into a cylinder well um if i was to take this and kind of like stretch it out like this so you have to imagine the sphere stretching with this if we were to stretch it out and flatten off the top and bottom that would give us exactly that how do we describe this mathematically this one's actually pretty simple we just separate by x y z so i can look at again the x y or z so x we have to be over here to see it uh what we want to say is take the top hemisphere so again where z values are positive we want to like map it so they're kind of like stretched up to the top so they make a flat circle kind of like you were taking an eggshell and just flattening it or like one of those hopping uh toys if you know what i'm talking about we want to do that and then for the bottom hemisphere we want to do the opposite in other words where we have a positive z value map it to 1 negative z value map it's a negative one and there's actually a math function for that it's called sine in other words um does it have a plus or minus next to it so not like sine and trigonometry but sine like this and this will map all positive values to one and negative values to negative one in other words we've now manipulated our z coordinate and we don't really want to manipulate x or y those are fine we just want to do some z stretching okay so now if we were to take our x and just put it here our y here and our modified z here you're going to see that it gives us a new kind of map that we could connect again whatever you do the last step should always be going to the subtraction of the vector displacement um now it's going to give us a cylinder again what's happening here and this would be easier to see once we mix everything together i suppose so again let's mix now the um what is this this is the sphere now let's mix the sphere with the cylinder you can see what's happening is the x and y coordinates are staying the same but we're just kind of stretching it like this and you're seeing that there's some like geometry issues these things get better the more geometry you have so we could actually just add more divisions and you can see it cleans it up a bit and i think part of the issue here is we started off with like a pyramid or something but or is it the auto smooth did we still have that enabled um point is the more geometry you have for this the better so let's uh go one step at a time just to see what we have so far i'm again a lot of these lighting artifacts do go away uh once you have more geometry okay so let's see what we have so far so so far is it not updating for some reason hold up we can just fix that very quickly why is it doing the cylinder it's doing the cylinder because i guess it's taking this chain so i guess we can just plug it in them manually um so we started off with a cube we then made it into a pyramid and we could actually control that with the mix i just want to be very clear about each step here so we have that next thing we could do is uh normalize it this is what turns it into a sphere again um normalizing all those lengths so now we have a sphere then we did a conversion using the um sine not trigonometry but you know positive and negative version we took this and now we have a cylinder and by the way a quick way to fix this shading thing if you don't add a bunch of geometry as you could always go back to shade flat and in fact now this makes it much smoother the more geometry you have the cleaner this will be so here you can see it's not very we cleaned this up now we have a cylinder and then if we were to view this mix this should be the transition between a cylinder and a sphere okay uh final shape now and i guess we'll keep it on a shade flat shade smooth is kind of perfect if you have a spherical shape but otherwise i guess it's not too hot of a commodity you know um so final step how do we turn this into a cone well if you think about it the way you make this into a cone is the same thing as last time we'd kind of want to pinch uh the top of this just like last time so instead of taking a cube to a pyramid um now it's a cylinder to a cone and because that transformation is the same again we want the z-axis make that gradient and pinch x and y we could actually take the very same node group as before and this is where the procedural approach is very powerful because you could literally just take this copy and paste it and now you have a cone right because again it's the same idea we're just pinching as we go up on the z gradient so we can even add a mix for that so you can see what that is doing okay so now let's kind of look through our whole animation and by the way you could combine these to make custom shapes i didn't even realize we could make a teardrop so easily but i guess it's true um let's see what are we trying to mix here i think i think i've messed up my like mixing order a little um so that our um our mix shaders aren't working perfectly but again uh what do we have let's go one by one we have a pyramid that came from a cube so if we minimize this cube pyramid and then we can mix those we have we also have the sphere version we then also have the cylinder version which again we could mix and then finally using the same pyramid node group which i guess we should just call like a pincher because it's not very specific to pyramids just any shape that's pinched uh we do that to get the cone and you know that that's kind of like the essence of a vector displacement now one thing you're probably going to notice if you try to now mess with like surface properties after all this is that whatever kind of like noise texture or whatever we use so let's say we use a noise texture here you see that there's a lot of stretching so like the first solution is you take the last thing before your vector displacement so these are the modified coordinates use this as a vector it kind of helps but not really you're going to notice that with these deformations it's it's not really behaving the way you expect to it doesn't kind of move with the geometry like color just kind of appears at the top out of nowhere and stuff like that and this is the idea of generated coordinates i was talking about before generally object coordinates are the nice one to work with but generated coordinates are the only other than uv are the only coordinate system that kind of move with the deformation so if we want a texture to stick um onto what we're doing we need to be using generated coordinates so just a quick trick of how to manipulate these you take your generated coordinates you add negative 0.5 because before um it uses the coordinate system of the bounding box um i guess i could show you what that means so if we were to i guess look at this vector displacement step right here and minimize it or mute it you can see that what we've done is we've transformed these generated coordinates so before they were off to the corner now they are centered whoops now they are centered just like object coordinates and then finally you take this you scale it by two just so it's the same magnitude so now everything's going from zero to one and now these should be indistinguishable from object coordinates object coordinates and then manipulated a generated coordinates so what you could actually do is use this as your coordinate system and we could actually take this turn it into a node group or whatever you want to do and then again we want to do the same thing for this subtraction because you want to subtract away whatever coordinate system you started with and now now we should get some a mapping that moves with this and and it's important to think about what step of the displacement you want to use as you're at texture coordinates and you could play with that um but now you can see even though there's the seam down the middle and you can like work with that you can see now this is kind of moving with it uh slice slightly more in fact we could just use the original generated coordinates here and of course there's going to be stretching vertically because we use that sine function but if we start off from the beginning and i know this node graph starting to look like a mess but that is welcome to vector displacement now you can see actually let me go one step further now you can see that we started off with a cube so now we have this noise mapped with these modified generated coordinates nothing special but with the pyramid you can see it's actually moving with the geometry um other coordinate systems wouldn't do that so that's kind of special and then also it works with every other step and maybe we'll be more clear with the sphere with the sphere you can see that again everything's moving with it so that's pretty nice but uh yeah that's kind of like the essence of a vector displacement moving shapes to other shapes how to stick a texture and more importantly how to think about like mathematical transformations not doing it in edit mode explicitly but doing it in this procedural modeling kind of a thought process which is important because soon blender is going to be getting geometry nodes which is uh kind of a system like this but we're not doing it in materials right we're doing it in a way that makes sense so hope you enjoyed the tutorial hope it was useful hope you can now do vector displacement chances are maybe none of you could in the beginning and now maybe one percent of you can uh just play around with it download other people's blend files and node groups and see um how they generated the vector displacement for example that teardrop from before it's kind of complicated or confusing how you would make that shape but if you just combine the idea of a cylinder and a cone apparently it makes it or a cylinder and a sphere or something so there's always new things to learn and yeah that's pretty much it see
Info
Channel: Default Cube
Views: 35,409
Rating: undefined out of 5
Keywords: blender, tutorial, vector displacement, beginner, displacement, procedural, nodes
Id: rYfHcB6tVrU
Channel Id: undefined
Length: 24min 5sec (1445 seconds)
Published: Sat Nov 14 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.