Vector Displacement Tutorial Part 1 - Blender Procedural Textures

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
november is turning into the month of vector displacement so i want to do a couple of videos here just kind of an introduction for people to get their teeth into this i'm going to go super deep but you're going to learn all of the ways that i go about manipulating meshes there's a couple different ways that people think about it but i have one way which i think is more kind of artist orientated okay so i'm working in blender 2.91 and preferences make sure you have the node wrangler add-on enabled so if i just jump over into my procedural text string workspace yields may look different so some of the key things to understanding vector displacement first of all you need a lot of geometry if we just start with a plane here currently we've only got four vertices and for us to get more geometry we're going to need to add a subdivision surface modifier the vector displacement only works in cycles and displacement in general only works in cycles if you go into cycles as your render engine and just make sure you've turned on the experimental feature set in here we get this option for adaptive subdivision what this does is it will subdivide the mesh based on the number of pixels that it takes up so by default i think that the viewport dicing is at eight pixels which means one face for every eight pixels and render will be at one pixel i've lowered my global settings down to four pixels you either have per object dieting which is this sort of ratio on the modifier and you can see how that's affecting below but you also have global for the entire scene which is on your render tab under the subdivisions here so you can set the viewport subdivision level so you have control over that you see we've only got one level of subdivision at the moment but if i jump into cycles then you'll see that we've got this properly circle plane now leave it on simple for now just so that we keep it rectangular and let's do a couple of things so for us to have displacement in a material need to add a new material and press n to bring up the side panel options settings and we're going to go to displacement only not displacement bump so the difference here is that if you're doing regular displacement just in the normals of the surface you can go with displacement bump and it will calculate the bump map more accurately with the displacement compared to if you use displacement only where it calculates the map differently however if you're doing vector displacement and you're actually changing the shape of the mesh you need the normals to be updating and for that to happen we need displacement only if i just add a converter combine xyz this allows us to input a vector x y z vector if i plug this into the displacement directly then you can now see that if i increase any of these then we're going to be moving in those axes so we have the power now to move our mesh procedurally this doesn't really seem like vector displacement because we're not deforming it but it's just a constant over the entire mesh we can do more than just move the mesh so the first thing i want to show you is i want to show you how to translate rotate and scale to do this what we want is we want an input texture coordinate node and we're going to be using object coordinates specifically for rotation and scale i'll show you later how we properly integrate this with generated coordinates but just to get the rotation correct we're going to be using object so if i then add a vector mapping node i just drop that on there now if i was to change any of these and you can see that our coordinates on the plane appear to be changing and i also want to add a converter vector math that this to subtract now i'm subtracting the object coordinates from the rotated object coordinates so zero to begin with and if i was to move this and you can see that we're getting some constant value now for the whole thing so this is important because if it's not constant then it'll start stretching but while it's constant then it will affect the whole thing uniformly so now i can move things just how we did before by adding a constant vector but i can also rotate so this isn't deforming the mesh at all all of the vertices are staying where they were but we can actually start twisting the entire object around so we end up using this quite a lot for doing various things especially when you have an animated shader for example the uh the screen print i have rotation coming down on that screen and that's animated i also have rotation on the squeegee and the bottle in the fluffy shade of the hair so much rotation going on there as well really useful to be able to do something like this and you can replace this mapping node with just a vector math scale or a vector rotate node and that's going to let you move things around also so let's just hit one of the key points about displacement and this is something that i've covered before but i'm just going to cover it again really quickly so let's just go in using object coordinates here and we'll have a look at one of the key problems so if i just add a vector math onto object coordinates and set this to length then we have a gradient coming out from the center and if i add a converter math node set to less than then you can see that we've got a circle now if i displace this circle which i would do by taking a combine xyz and i can just plug this into the z so now i have i have zero and i have one but in the z axis right so if i plug this into my displacement have a look at my principle now so we're shading you can see that we're getting all of this stepping happen from the subdivision this is caused by essentially one section of the mesh is displaced down here and then you get to vertices and this is one face up to this point because we have a hard fall off so if i show this to a wireframe node and you can kind of see that we just have these really long triangles coming up from bottom to top and these are individual faces that have been stretched so for us to get away from using thresholds we're going to be using map ranges and you might not have used map ranges before so much but they're extremely useful we have a few settings here and a few inputs they're actually really simple despite what they might look like so if i take my my length here which is zero to one put that into my value of the map range so initially it doesn't change but you can see that we have our from values this is kind of where we grab hold of the gradient and then we have our two values which are where we essentially put it so if you imagine that you have gradient like this and if you were to say that you're from min and you're from max were here and you wanted to remap this to these positions then it's just going to stretch this range up until it fits this and you also have the option of clamping and this clamps to your two min and two max values so if you do not clamp then your whole thing will get stretched just to be bigger if you do clamp then you essentially flatten off any values which are higher than your two values we also have several different interpolations so you have linear which is as you would expect just essentially scaling the value range but we also have stepped linear which is like doing a snapped value so if we have a look at this then you've got these hard steps we also have smooth step so this rather than taking a gradient which is like this it will convert it to a sort of an easing gradient and then we also have smoother step which is just a much more pronounced smoothing so they're kind of the key things for us to look at let's start with linear and we're going to displace our circle here our threshold before was 0.5 so i'm just going to go from slightly inside 0.5 to slightly outside 0.5 around there and now i can plug this into my z have a look at my principled so to begin with it looks like it's going off to infinity but i can just clamp this and i just need to update that a little bit and there we go so straight off the bat we've got a tapered shape now it looks upside down this is just because our we have a look at this this value is zero and this one is one according to our two values so i can just flip those around like that straight away you can see that we have a lot more geometry going on on these sides and you can increase this even further to get a denser geometry so this is one of the main ways that we create vector displacement with continually editable geometry is by pushing geometry around so i now want to make the top of this bigger so that i've got straight sides for me to do that i can take this mask which goes up to one in the center right so i've got one here and i can use this to scale up this section and nothing here will get touched because this is at zero so if i go converter separate xyz and i just take my object coordinates which is what i'm using at the moment then we have x and we have y we can multiply these and plug these in here and just multiply these by our gradient by our map range gradient initially these are much too high but if i was to add an rgb curve on here and we're going to start being able to get manual control so i can make sure this is straight up above the bottom just using the grid for reference and then i can also give the side a little bit more of a profile just to make sure that we are actually staying straight so there we go we have a lot less stretching if we have a look at the wireframe we've got all of this additional geometry on the side there what happens if we want to color this though this is the issue that we run into with object and also if i was to actually just look at the map range everything looks black even though it's currently displacing because we've displaced the mesh outside what the object coordinates are showing this is why we always use generated right so if i plug this in and i'm gonna just need to tweak this because generated runs zero to one according to the bounding box rather than being centered so i'm going to add a converter vector math this on the noodle going to subtract 0.5 and then i'm also going to scale by 2 and this is going to make it exactly the same essentially in this instance with your primitives if you're using primitives it's going to make it the same as the object coordinates so now if we come through here we can see on our principal chain it looks the same but if we look at on that range this is actually now visible we can see the values after the displacement and that's really important because now if i wanted to come through here and use a color so let's go red and blue then you can see that we can actually do that whereas before we go back to our object coordinates on here you can't actually color using these masks you have to generate new masks and that's essentially not possible for complex shapes so that's the first thing always use generated let's have a look at doing overhanging geometry this is another one which is possible only through vector displacement right so you could get a very similar cylinder to this using regular displacement although you wouldn't be able to get the side straightened take another vector math node set this one to distance gonna plug that on there so if i view this and at the moment we are centered here but if i start coming down in the y axis and you can see that it's following the mesh because the generated coordinates are also following the mesh so i can just bring this down onto the front here i may want to give it some multiple so i'm going to duplicate this again set to multiple so if i increase this set to something like four then i can come down here like this so now it's much more circular again even though we've stretched all of these faces i'm gonna grab another map range and i'm gonna make this one a little bit smaller going to go something like that i'll add this to the y gradient the negative y gradient so how do we start mixing displacement together well i've got one displacement which is this one from generating this tower this stack and i want to now push our y down i personally for my workflow i like to keep things compartmentalized so i'm just going to drop this into a frame call this one cylinder i'm going to just put this into the y coordinate here so i've got this it's actually going to be negative y so i'm going to go to minus 0.2 or something won't be able to see it because it's a negative but all i need to do is i just need to add a converter back to math set this to add so we're just adding displacements together and if i go back into my principled node when i add this to here then you can see that we've got geometry being pulled out the side so this is kind of essentially how we do displacement or at least how i do displacement is i mask out a region and then i give it a vector there's a couple of different ways that you can do this either putting map ranges directly into combine xyz or for the hair shader what i did was i had my combined xyz and this was essentially where i wanted the tip to be relative to its existing position so i might say minus y and positive z so this is a constant if i was to just add this to here then you can see the whole thing gets moved however it almost have a converter vector math plug this in here set this to scale and use the map range zero to one so this is now my mask put this into the scale and i can plug this into my my ad here so now you can see that we have all of this control on a combined xyz so i can move this around however i would like so that is the essential crash course in vector displacement there's honestly nothing more to it than use generated push your mesh around so that you don't run out of geometry and just keep pushing masks and extruding them in various directions think of it as sculpting without dynamic topology everything that you make needs to fit within the geometry that you have when you start because you're not going to get additional subdivisions after the displacement the redactive subdivisions are calculated based on the screen space of the mesh pre-displacement and then your displacement happens on top of that i'm going to make something now fairly simple but it's going to show you a couple of things where we can go a little bit further into maths and also splitting geometry so to begin with i'm going to need to make a group node the range mask that you may have seen in some of my other shaders and you've been using it basically every single one of these shaders this month super useful so i'm just going to make a new material so before we get into range mask i want you all to enable the node preset add-on this comes with blender and it just allows you to set a directory in which you save blend files that have node groups in them so range mask is very simple it's essentially two map ranges that we multiply together there's a little bit of maths to get them to work properly so let me just make a gradient so that we can see this working so this is our gradient just the generated x and what i want to be able to do is i want to say i want between 0.4 and 0.6 and because we're doing vector displacement i also want to have the option of having a soft fall off and if i were to use this for alpha then i also want the option of a hard fall off so i need that flexibility built in pretty simple for us to do though so this is quite a nice node group but super useful so i'm going to add a converter map range we're going to plug in our x here have a view of this output so we're always going to be going to zero to one because we're doing masks here and masks want that range on and off now we're from min this is going to be we just add some values here so we're going to go our range min and our range max and these are going to be 0.4 and 0.6 i'm also going to want to fall off control we will make this a 0 to 1 range for our from we want to have 0.4 this is our initial position right and i want to control this max value but it needs to be controlled based on the other side of the range so if i just duplicate our map range down so i've got two of them now we're going to plug our range max into the from max of our second map range these gradients both go in the same direction i need this second one to be flipped so just change your two values to be back to front so first one goes zero to one second one goes one to zero because we are essentially doing this zero to one then on the other side we go one to zero for us to be able to see both of these together i'm also going to add a multiply so math set this to multiply so now i've gotten both on green but i need to control the minimum of my second and the maximum of my first if we have this range here and i want to reach one at least in their center so the shallowest gradient is going to be half the length of our range so we need to work out the length of the range half it add it to the minimum attract it from the maximum i'm going to add a converter math node we're going to take our maximum we're going to subtract our minimum this gives us the difference between them 0.2 and then if we divide this by 2 then this is going to be the half value and now if i add to my minimum then this goes to the halfway point for our maximum of the first and if i take my second one here my range max and i subtract this divide this goes into the from minimum and now what we've got is we have a gradient from zero to one back to zero now what i said before about wanting to have access to use this as an alpha mask for example we're going to do that really simple here we're going to add another math node just in front of this divide set to multiply so when it's 1 we have a soft falloff when it is very close to 0 we will be getting a hard fall off at 0 we get nothing so this then ends up being our fall off yeah i'm just going to group this up so select everything ctrl g then we're going to start making our inputs we've got our range minimum and our range maximum and these ranges are infinite and then for our falloff i want to have a slider for me to get a slider i need to add something with a slider i'm just using a mix rgb here just to get this slider on the front i can just plug this factor straight into that multiply node rename it full off now if i set this to 0.6 and point four see that we've got a mask with a range and i can change the falloff on this now if i don't want it to go to zero i also just need to make sure that my minimum value here is like point zero zero zero one and that'll just stop me from being able to go all the way off the bottom rename this to range mask take a look down in the description box below because i'm going to be putting in links to high-res screenshots of all of the node trees including this node group now that we've got range mask we can do a fun little task making separated geometry and we're going to make something go through something else this is going to be fun i'm just going to go and make a new material i'm going to do it on this plane and i need to turn on displacement only because this is a new material obviously we still have the modifiers the subdivision modifier on here first thing i want to do is split it in half so it gives the illusion of separated geometry so to do this i'm going to add a text coordinate node generated converter separate xyz excuse me my gradient and now i can add group range mask and we can range mask out section from 0.45 to 0.55 this is going to be an alpha mask so i'm just going to reduce this right down if you did want an extra bit of functionality you could have a second mask on here where we take a converter math node set to subtract and we're just going to subtract the mask from one so into the second socket of that subtract node and that comes out here so now we've got two so let's tall the top one mask and the bottom one other so now what we've got is we have the mask and we have the inverted mask just straight out of this node so that's useful because this is going to be our alpha we now have opaque opaque and transparent in the middle so if i plug this into the alpha to the overlays and it now appears that we have two different sections i need to separate my halves now so i've got a mask for each side so i'm going to add a converter math node on my x gonna go greater than 0.5 what this does is it colors one side black gives me a mask for that and this means that i can now control the displacement on each side individually super useful because i need to have my displacement isolated to each side making sure that we're using generated fullness as well just because we don't want to have any issues with coloring later so what we're going to do is we're going to make both of these into cylinders one of them will be circular the other one will be straight and we'll just pass one through the other so it's going to look like two things we're going to be able to texture them and manipulate them individually but they're going to be two items working on our first one i'm just going to duplicate this down so that we've got a spare copy here if i want to be working on this right hand side then what i'm going to do is i'm going to take this greater than mask i'm going to put it through a vector math scale this is what i always do so now i'm going to use this scale as my displacement right so if i was to look at this and i was to start doing stuff to this side then you can see that we've got this now you might be thinking well when we were looking at the cylinder before said not to use greater than for your masks when in this case we are and this is because i want all of my artifacts to happen here and then when i mask out the transparency you can see that we are getting rid of all of those now you could use this greater than you could change this to a map range and you smooth the fall off and that's going to give you a little bit more leeway so if you're finding that you're getting these black marks where you can't see through sections this is because your transparency passes need to be higher you'll see when we start twisting and deforming things it can start to get a little bit messy so i'm just placing half of this mesh it's key to remember that for every section that you do every little part of your mesh that you work on the final part before you add to the main displacement line wants to be this scale with your displacement mask so each section if you want to isolate all of your displacement to that section make sure you're going through this scale last so i can just take a combine xyz in here and i need to take my y gradient and to make this into a circle i need to first of all have some kind of set displacement this is a cosine graph so cosine has a wavelength of 2 pi so i'm just going to add a map range onto this y gradient going from 0 to 1 which is our current gradient to minus pi to pi i'm going to add a converter math node set this to cosine now plug this into my z so you can see we've only affected the half that we are scaling it to um if you've seen any of my time lapses you'll notice that i set my top right hand panel here to be the final shader and this is because if i'm working down here clicking on these so i can view the output i don't have to zoom out go all over here click on this zoom out and come back right so i just set this top right panel to be a shader editor and i just leave this one zoomed in on that final shader right so now if i click on one of these masks i can just go straight back to that shader without zooming my main tree now i've got my z displacement i also want to get some y displacement because i need to go from this to this so i need to pull these in by one and minus one and this wants to be at zero so i need to go from one at the beginning down through zero in the middle and then to minus one at the end and what this is is a sine graph so everything to do with circles is sine and cos so i can just duplicate this up and have a look at the sine so you can see i've got minus one here and positive one here if i just plug this straight into y then we have this kind of ribbon but we're still disconnected at the bottom so what i'm then gonna do is i'm going to subtract our y gradient from it multiplied by 2 y multiply it by 2 subtract from here and what this has done is it's given us this full circle all the way around there now this is centered at y equals zero so if we now want to move this up in this direction we're going to need to add some y value so i can just add this you can see that we now have this control to move this circle in its entirety so i'm just going to add one onto there now at the moment this is way way too big so i can do is out of my sign here and my cars if i want these to scale at the same time right i just need to add a value and plug it into both so i can just connect that one alt right click is what i'm doing just to get that quick connection and now you can see that we are scaling this pipe down now i have a cylinder i'm gonna do the exact same thing for the other side now again if you've missed a step then the nodes you'll be able to see a screenshot in the description below so i'm just gonna go and i'm gonna make this second one but i'm going to roll it in the other axis so again i'm just going to duplicate these down here expose my x and my z and now i want to roll this one up in this direction so this one requires the x gradient so if i get a map range i know that my alpha mask stops here at 0.45 so i don't actually have the full 0.5 half of the plane but if you don't know where your mask is if you don't know where it ends then you can have a look at this and you can flip your output around and then when you pull in your maximum then you get to see where it goes black so obviously i would want this plugged into my principle node so that i could also look at it compared to the alpha i know in this case we are at 0.45 and this range instead of being 0 to 1 we want it to be negative pi to pi so this gives us our full circle our full 2 pi so same again we're going to add a converter math node set to cosine this gives us our stretch in this direction and then we're going to do another one sine and this one is going to give us our stretch in this direction so we're coming back to put this into our displacement i need it to be a factor so this is going to be in our x direction and this one is going to be number z direction and just need to make sure i've masked it out to this area so just take a vector math node set to add and drop this on here and then connect it then you can see that we've moved all of we've moved all of this down where we don't actually want to be controlling any of the other one right we need it to only be reserved to this left hand section so i need a scale and i need a mask which is going to be our x is less than 0.5 so convert to math set to less than 0.5 plug this into my scale you can now see that we've got two different tubes and we've got some connecting and if we hide that then that's gonna get rid so obviously this left-hand tube does not join up so just the same as what we did before i'm going to add a subtract on here and subtract the y i also need to multiply my y sorry my x i need to multiply my x by two to get it to join up there and then i also want to have a multiply on both of these with a value to control the scale something around there i want this right hand one which is longer i want this to be circular and i'm going to use rotation to do this so this is my displacement mask that's our scale just to make sure that we're fitting this just to the correct one and i can ctrl j this one is the left cylinder for me to get this to rotate i need to be working within this mask so i'm going to be keeping this before this scale because i'm working on this section so scale is always the final one i'm going to be using a mix of coordinates now so i've done all of this displacement but if i go in and i just add a text coordinate node i look at my object coordinates get a vector rotate node because we're just doing rotation and also a converter vector math subtract the object coordinates from the rotated object coordinates i just put this in here and if i just add this to my vector here initially nothing happens it's going to go in the z axis you can see that as we start rotating all of our displacement that we've done up to this point kind of breaks and we're no longer able to control the axes how we want because we've rotated this now and you'll also find that if you rotate the actual object it breaks all of your vector displacement really important that if we ever do any rotation we also rotate the displacement we have several different factors here so i'm also going to make sure that i've got the same center just connect those up so this is our rotation center and i also want the same angle of rotation so input value make sure i've joined these up here so now when i rotate this we are actually rotating the mesh correctly the displacement rotates with our vector seeing a little bit of an artifact coming down here this is what i was talking about before with getting these transparency artifacts when you start deforming the mesh especially when you start doing these kind of rotational transforms this is just caused by not having enough transparency passes so you can just turn these up depending on how complex celsine is you may need more or fewer for my fruit tart i used 200 passes and i think if i'm not mistaken i think gabe used 500 for his spray paint shader 20 is fine for what i'm doing here so at the moment we just have a constant rotation i would like the rotation to be out from the center right so i want it to come one here one here and zero here so that i'm able to rotate around and first to get the rotation going backwards here this probably also wants to be negative one so i'm going to put a gradient up here so i'm just going to grab my y gradient and i'm going to put it through a map range and we're going to be going from minus 1 to 0 to positive one and then i'm going to use this to multiply the rotation angle so i'm going to add a converter math set this to multiply and we're going to just plug that onto here check our displacement and you can see what's going on here we're basically rotating based on this gradient so with the angle set to zero you see that as we start bending this going to be dependent on our origin right so i want to make sure that my origin is at somewhere useful um minus 0.25 so you can see that you're starting to get various bits of control here and you can make all sorts of shapes going on so don't forget this is a plane this is a flat plane so if i wanted to make i didn't know let's do like a kind of a ribbon coming through itself so we're just gonna do that so if i want to move this around in the y axis so that we go to being upright what i'm going to want to do is i'm going to add another factor rotate afterwards i'm going to add another add another subtract another vector rotate and we're just going to take off this object coordinate again into here probably going to use the same center as well this time we're working in the the y axis so now you can see that we can rotate this whole thing just going to rotate this until we've got minus 90 degrees which is pi by 2 so minus pi divided by 2 gives us 90 degrees there this is all over here if i want to move it i'm just going to add another add node and now i've got this constant that i can move still same before the scale so we can just move it bring it down like this so what i want to do with this right hand side is i want it to have it kind of spin in a circle going through and to do this i need to add rotation before my scale so converter combine xyz this is for our center i'm going to add a vector rotate i'm going to add a second vector rotate this is our center and i'm going to add an input text coordinate node object to this second one and i need to add a vector math node converter vector math add it just joins up there and i need to be subtracting the object coordinates from our rotated object there we go input value this is that rotation putting in both at the same time and instead of spinning around the middle like that i want it to be spinning around this point here so our center is going to be minus 0.3 something like that and then also around the z so i need to just move this across ways a little bit and i also need to move this down now you can see that we've actually got this moving through moving through that circle so this is an animatable value hash frame in here so this gives us our frame number if i add a converter map range i'm going to go from 0 to 100 frame 1 to 100 outputs 0 to 1 and now we can put this through a an rgb curve and then another map range is what we're going to use to get our 0 to 1 range off this rgb curve and we're going to convert this into a full 2 pi so just write tau in there so you can see at the moment this is just going round in a circle linearly but you can start twisting how things go around using the rgb curves and if you need more space on here then you can just stretch them out and you can do anything that you want for the speed on here every time we have a downward gradient we're actually moving backwards so i can do something like this where we're then coming backwards so there we go that's essentially how we go about creating large factor displacements and if you've got for example your your mask like this and you'll probably have more pieces if you just plug this into a mix rgb then i can plug this into my base color use this for having a little bit of color on here but i can also use it for roughness i could use it for metallic so now you can start materialing your objects everything is just about manipulating numbers right and we're generating vectors instead of color information once you've got into that way of thinking where it's like okay i'm going to mask this bit and i'm going to move it in this vector direction and using these vectors you can create really quite complex scenes in the next video we're going to look at generating a doorway with a door that will open as a door handle and frame so a little bit more of an applied thing three objects with rotation different materials it's gonna be great so thanks for tuning in hope you've enjoyed it i hope you've learned something and i will catch you in the next one
Info
Channel: Erindale
Views: 21,640
Rating: undefined out of 5
Keywords: blender, shader nodes, shading, procedural, nodes, shader editor, tutorial, eevee displacement map, eevee displacement node, blender pbr tutorial, blender pbr textures, blender pbr textures free, pbr textures in blender 2.9, Blender 2.8, blender tutorial, blender eevee, blender easy, blender easy tutorial, blender cycles, intro to blender, blender 3d, b3d, learn, free, concept art, parametric, computational, design, nodevember, vector displacement, advanced
Id: aEeBAxjvY8U
Channel Id: undefined
Length: 31min 53sec (1913 seconds)
Published: Thu Nov 12 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.