Blender VECTOR DISPLACEMENT... with hats

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
guys it's getting super super crazy out there generations he's using this new technology called vector displacement and quite frankly we're gonna be left behind if we do not adapt evolve and learn how to use vector displacement so that's what I'm gonna be teaching you today we don't want to fall prey to those Gen Z they're just gonna be going light-years above us okay what what are we talking about today vector displacement so you can see how the sphere this is a scene I made there's a sphere and the node network and we don't really know what any of this does yet but I'm gonna explain it but all we know is that most of us except for the diffused psdf ends up going into something called a vector displacement node and when I crank that up to one for some reason we get a hat so welcome to vector displacement turning spheres into hats that's what we're gonna be doing today basically what vector displacement as for those of you who don't know and I'm pretty new to this as well is it's kind of like displacement mapping where you can take a mesh and then deform it along the normal so you displace it you know usually upwards but generally along the normal it's like that but it's vector displacement meaning it's not just along the normal but it's in any direction you want so the kids out there are making models out of spheres for some reason is this practical no but different applications of this are practical so if you know how to make a hat you'll know how to how to do anything so we're gonna go over how to turn a sphere into a hat I guess and just so we can visualize what's going on here just a bit better I'm gonna remove my like subsurface and view the wireframe what's happening here and I'll make this a smooth transition is we have a UV sphere you know this is just the standard UV sphere and then we're slowly deforming this thing into a hat and all these nodes back here are basically the math equation that define how we go from sphere to hat and you know how do we generate these equations I don't know we'll figure it out let's start up the new scene let me show you how to do it this isn't gonna be like a introduction to vector displacement like a thorough thing this is just gonna be an example project for maybe your first time using vector displacement we'll see how it goes so new scene blender 2.8 what 8 3i 2.9 those two buggy4 now what we're gonna do is we're gonna replace our tube with a UV sphere although you can also do this with a rounded cube doesn't matter anything spherical is fine okay we ever sphere we're gonna switch over two cycles which is necessary for a displacement and vector displacement mapping and then yeah we don't need to change any more settings here so that that's the setup go to shading create a material we're gonna call this vdm for vector displacement map even though we're not you know making a vector displacement map are just doing vector displacement last thing you need to set up by the way before we're good to go is make sure to go to your material settings for whatever material you made and make sure that displacement isn't on bump only but displacement only or displacement and bump otherwise there's gonna be no deformation right I'm gonna go with displacement and bump even though displacement only would be fine so there we go okay boys how do we go from a sphere to hat well the first thing you need to do is you add you have to add in a vector did this sentence even make sense add in a vector displacement node and connect it to the displacement socket and we're gonna be using object space which you're thinking okay what do these mean basically the way you want to think about this is tangent space is very very useful but very very hard to calculate so it's hard to use but it's useful so we're just gonna come brush that aside and instead we're gonna use either object or world space which basically say we put in a vector and the coordinates are just going to go to there no complicated tangent space no tangent by tangent by vector stuff just object space okay so set that up so currently what we have is if we just put in a vector so again vector displacement you can pick a vector for how you want to displace it we're able to actually manipulate this so right now we're just you know putting a combined XYZ node in here meaning we're basically displacing all the coordinates every single vertex we're shifting over by this vector which just kind of looks like translation you could also do scaling whatever and then we're gonna talk about that so the first question is how do we go from spirit a hat well you want to take it step by step by step I don't know the equation but we can construct it so think about like this we're gonna start off with a sphere we can turn it into a cylinder this is a pretty simple equation so sphere to cylinder then we're gonna squash it so kind of looks they get DVD or something you know a disk or frisbee so sphere to cylinder to frisbee we're then gonna curve it so it looks like a Pringle and then we're just gonna add the top part of the Hat basically we're going step by step by step so part one how do we turn this into a cylinder well I'm gonna use texture coordinates specifically object coordinates since this gives us you know coordinates of every vertex on the mesh with the origin at the center which is very convenient and the first thing is how do we turn this into a cylinder well what I'm gonna do is I'm gonna do a separate and combine which effectively does nothing if we just combine all these X to X Y to Y & Z to Z this effectively does nothing we're just separating the vector and combining it but if we want to turn this into a cylinder you know on the z axis you might think about what that looks like well really all it is is its taking the top hemisphere and flattening it so it doesn't have curvature but it's a flat top like a cylinder and then same for the bottom so basically we're saying any Z coordinate that's positive above the floor so top hemisphere flats in it up to like one up to two up to whatever height and then for negative values bring it down and flatten it well that means we need to manipulate the Z coordinate so again we're making a cylinder and basically what we just described is the math operation of where is it it's sign and what sign does is it says if you have a positive number output 1 and if you have a negative number either outputs 0 or negative 1 I can't remember but either way we're taking top hemisphere mapping it to a height bottom hemisphere mapping it to a different height okay so you might think that this will work so let's try we put it in our vector displacement and you see that it's close it kind of gives us a capsule so kinda does what we want to but want it to but it's not really working plus it's getting bigger for some reason instead of just finding the hemispheres the reason for this and this is actually a very important point so important that I need to save this is a very important point vector displacement takes your coordinates and displaces it by vector meaning you already have some coordinate of where the vertex is and then you're just adding something to it some vector but what we're doing here with the this you know sign this little math expression is we're giving the coordinates for the cylinder so we don't want to take an object and displace it into a cylinder because we what what I'm trying to say is we already have the coordinates figured out we don't need to add in the original of the sphere so we just need the transformation not the original coordinates so in other words if we only want displacement to not the original coordinates what we need to do is vector math subtract we're going to subtract away what vector the original coordinates of our sphere boom cylinder so again we have a sphere we gave it some math expression so you know turn it into a cylinder but that's just a displacement it still keeps the original info which is kind of redundant so we subtract and get rid of it okay so what does this look like in slow motion well it just flattens the top flattens the bottom pretty obvious or pretty easy rather okay and we can view this the normals are gonna be a bit weird for now just ignore it okay so we've made a cylinder next step i said is to flatten it into a disk in other words take your z coordinate and kind of scale it down so let's think about how to do that well clearly we need to do some manipulation here before we subtract away the object coordinates that's kind of like the last step so what I'm gonna do is I'm gonna add another vector math node and think about it if we're scaling your your first guess might be to use like a scale but this is kind of uniform so just you know mixer cylinder a bigger and smaller we want that but only on the z axis so I think there's a couple ways I'm gonna go with multiply which gives us control of XY and Z so I'm multiplying them by one which means do nothing but if we only change Z then we're effectively like extruding or changing the Z scale of our cylinder so I'm just gonna make this pretty thin something like this so again we have a sphere we turn it into a cylinder and we also flatten it boom okay next step and this is kind of like the nice creative step how do we turn this into a Pringle into a saddle like the brim of the Hat is kind of curved like two different directions so one way it's going like this the other way it's like concave down concave up whatever effectively the way we do this is what we what what we want to do is we want to add another vector and remember adding just kind of means translate everything because we're adding the same vector to every vertex so we're translating by the same thing everywhere so you know we can displace our cylinder but we want to displace it by different amounts depending on the vertex and specifically we want a nice curvature that's the idea so what we can do is we've already separated our object coordinates so let's so examine the x axis so what we can do is we can say as you progress along the x axis kind of do a nice curve instead of bringing it up everywhere right so let's actually do that you can do that with probably RGB curves is the smartest way to do that that's what I've done before so we're just gonna take X and plug it in here so we took object coordinates xvalue and you know put it in here and then the idea is what we want to do is again we're adding where we're doing a vector math addition here to add curvature so I want to be able to control XY and Z separately that's why I'm putting this here and we can add it to the Z so right now what you're seeing is we had the circle the cylinder the disk and now we're kind of adding kind of like normal displacement to almost kind of not really we're adding vertically on the z by this amount as we go across the x-axis so you can see what that looks like and we have complete control over this of course so first thing we might want to consider is that since we're using object coordinates it goes from negative 1 to 1 for the x axis and it's it's centered at the middle I want it to go from 1 to 0 because that's what RGB curves expects I'm just gonna do this with a quick map range notes instead of 0 to 1 to 0 to 1 negative 1 to 1 to 0 to 1 so now goes from here to here instead of them you know from here to here so we're just kind of remapping everything so now let's look at what this looks like ok and it's actually pretty intuitive what we're doing here at this point you're literally just drawing what it looks like so you can see we made this curve and it does that curve over there so if we want a nice curvature we can have both 0 and 1 like pretty much uniform so all these are kind of being translated up just a bit by this elevation and then in the middle we just kind of dip it down so you see we're getting a nice saddle nice saddle there so again we're adding on the z axis depending or by given by function as we travel along the x axis I know the vector displacement is confusing for those of you who are like oh I thought nodes didn't have math involved they do surprise okay so now we need a saddle so it curves up like this but we want it to curve down along the y axis which means basically do the same thing so I'm just going to duplicate this this time use the y coordinate so now we're looking at we're looking at it this way so we've already curved it going along the x axis now we want to curve it along the y axis so again we add negative 1 to 1 which I mapped to 0 to 1 and then I'm going to connect this to its own RGB curves so right now what we could do and again even though we're now going instead of ax x-axis y-axis we still want to displace upwards on Z so we'd still plug it into the same socket here let me just do that math addition add these I don't know what my sentence was basically what I was trying to say is right now we have the exact same RGB curves which means as you look at it from the x-axis it's gonna curve like this and same for the y-axis which means it should make some kind of Bowl it'd be easier to see what diffuse psdf kind of looks like a bowl we want one side concave up one size side concave down so what I'm gonna do is I'm just gonna reverse this so this goes up and these go down so you can see from this view this hill is basically being shown exactly here because we're looking along the y axis so we should now have a nice saddle curvature one way different curvature another okay so let's see what this looks like I was like doing this look at that so you can see how we're not really making the equation for the Hat in one go we're taking it step by step by step you know doing all the work here and then finally connecting it to the vector displacement of course we subtract object coordinates first but that's the idea so finally what we need to do is take the center and bring it up you know this is where the head is just bring it up and basically that just means define a circle and for that circle displace upwards that means add to the z-axis that's all there is to it okay so how do we define the circle well probably your first guess if you've watched some of my videos is to use a length for object coordinates which kind of works you might not be able to see this in gradient because of um it's kind of faint and YouTube compression basically what it's doing is it's looking at the three dimensional vector and outputting the length giving it this kind of radial gradient from the center which is kind of similar to a circle in the middle but not really because it's a three dimensional thing instead of a two dimensional thing we just want a circle going outwards from the top view so just imagine a circle kind of emitting outwards that doesn't actually have a Z component meaning all we need to do is kind of only consider x and y naught Z so what I'm gonna do is I'm going to multiply this incoming vector by 1 1 and 0 basically saying keep X keep Y make Z 0 everywhere and now we have this nice some radial fall-off not spherical the radial so before after ok and again the idea the idea here is this is yet another thing that we're gonna add to our Z displacement so you can see now it makes like this weird it took our saddle and just kind of punched in words which isn't what we want but you can see you know the idea the idea is correct so what what do we need to do to fix this well basically let me just get rid of this for now since we're not there yet we do have the radial gradients but we don't want it to be like black in the middle and white outwards in fact what we want is full displacement in the middle and then once it gets big enough like the size of the head there's just no displacement I'm just gonna do this with a color ramp to get the a nice little bit of a fall-off so first of all what I said is we want displacement in the middle right so before what we had is the Sun was kind of held still and everything else was brought up words we want to reverse this I'm just gonna flip the handles like this so now you see we kind of have the reverse thing which will kind of displace the middle upwards but we only want kind of the middle of this so I'm just gonna pick an area something like this right so you can see what I mean it's gonna pick this area and displace it upwards and since it already has that saddle curvature if we displace it upwards it's gonna have that saddle curvature on the top which you can get rid of but I actually like it okay and notice that it does it on the bottom and the top which in this case is a good thing so let's see what this looks like we're gonna add our color ramp which you can see is kind of doing the right thing so again really what it's doing is it's taking the center and just bringing bringing it upwards but keeping that curvature on the top and again the nice thing about this is we can control it's all procedural and in fact we want these two handles pretty close together so it's more of a sharp upwards instead of like a diagonal unless you're going for that Fedora look you know that's up to you and the reason I don't use something like a constant so it just goes immediately is it's kind of like too sharp we want a bit of a fall-off so there can be some geometry there and let's actually visualize what this looks like add this before if we use a wireframe node we can actually see the geometry so what I was saying is that with constant it just goes straight up there's only I mean these are triangles but imagine they were quads there's only one strip of quads going around which might be what you want but I want a bit I want a bit of a fall-off not much so we can have them really close right now it's effectively the same but when we add in more geometry with like subdivisions we're gonna eventually if we have enough and now you see we have multiple quads in this area but that's the idea and yeah I guess technically we did finish and notice that since that radial thing radial mask we made was at the top and bottom it's actually like a physically correct hat you could actually put your head inside of it it doesn't just displace the top but also the bottom okay let's see what this looks like so we have a sphere and we slowly deform it into a hat this is the weirdest blender tutorial of all time needs to be done though and you might be wondering why does this look so bad so first of all make sure you have shade smooth second of all make sure you have a good lighting so you don't get weird shadows and this is the kind of thing that does happen with a vector displacement maps you get weird lighting but I'll show you how to fix it okay so if you've already done shade smooth and made like even lighting with like an HDR eye or something and you're still seeing this kind of weird normal stuff the reason for this is is it doesn't actually have enough geometry to calculate good normals right now this is what the normals look like you can see they're very broken same with true normals kind of but we're interested in normals they're kind of broken but to fix this if we just add in more and more geometry you can see that it slowly refines does take a bit of time but it's dudes doing an okay job so now if we view this you can see it's a bit smoother there is a bit of a weird shading error right here and you can see that's reflected and the normal it kind of immediately gets cut off so again you just want more and more divisions and really instead of just making this number higher what I would recommend is enabling experimental mode and adding in a sub surf with adaptive which will kind of pick a amount of subdivision depending on how close we are to the object and like pixel slicing and all this so let's see what this looks like so now it should look much smoother not perfect of course because the more geometry the better you know actually increase it just in viewport to of course this will look better on render but you can see this already you know it works and because it's a knife I mean again there's no point in this but because it is procedural we can always go back and control things so we already talked about the hat top thing so now we have a nice slanted thing if we control the color ramp we can also control the thickness of it which was um remember we scaled the z-axis only so here we can have a super thick hat should be twice as thick and we can have a hat that is half as the it's taking a long time to calculate because I'm recording at the same time we can also control the curvature at any point we can also do some like weird stuff just add another candle here and it's gonna make weird hats maybe you could do something out of that I don't know basically the rest of this is just surface stuff this is just how you get the shape of it using a vector displacement you know the rest of it you could be like oh I want a I don't know I want like a noisy hat to give it like nice texture you can do all that this is just surface stuff make sure that when you do this you're gonna see some stretching and this is a tip I got from a JC if you're familiar I don't use generated coordinates user object coordinates and dough's don't distort and then you're gonna get a nice even uniform distribution everywhere so there you go I mean I don't know if you wanted to know how to make a hat out of a sphere but you can now you could also do it out of a round rounded cube like I said yeah you know that I don't know what to tell you so that there you go that's your first introduction to vector displacement at some point I might do a formal series on this starting from the beginning I don't know seems like a lot of work though anyways if you enjoyed this free tutorial the best way you can support me is via patreon and you could either do that as a donation if you're super nice but if instead you want something out of it there are benefits you have exclusive tutorials and behind-the-scenes access discs or tutorial files depending on the tier you get but really this is the only way I can do this full-time anyways I hope you enjoyed you now know how to make a hat enjoy vector displays them and it's quite a trip I mean honestly wasn't damn any nodes to go from spear to hat you might think that it'd be hundreds knots like 20 so yeah
Info
Channel: Default Cube
Views: 57,266
Rating: undefined out of 5
Keywords: blender, tutorial, vector displacement, displacement, shading, nodes, material, 3d, cg, cgi, vfx, animation
Id: BDtVsS_zR_8
Channel Id: undefined
Length: 21min 43sec (1303 seconds)
Published: Fri Jun 05 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.