### Introduction to Procedural Textures – Getting started with Blender Nodes Part 1

Hey, welcome! Today we’re gonna be showing the beginnings of working with nodes in Blender by creating a single node that allows us to generate four different shapes control the size and control the fall-off of these shapes. Okay let’s get stuck in I’m gonna be working in blender 2.82 If you’re working on previous version I recommend you come up to this one which is currently the stable release I’m gonna be working in this workspace* today Yours may look different So I’ve got my node space which is big because we’re doing nodes And I’ve got a small 3D Viewport in here The work that we’re gonna be doing is entirely with nodes so it’s importantly got the Node Wrangler add-on in the bold you’ve watched any other videos I’m sure you will have heard this 100 times Node Wrangler, in your add-ons in blender preferences, just make sure this box is ticked and it will add a lot of additional functionality that’s gonna help you streamline the process A bit of node etiquette: When you have the node Wrangler add-on installed if you control shift and click on a node it will give you a preview the socket if you keep clicking it will click through the different sockets and you will see what each of them displays. The next thing we’re gonna be using quite a lot is I do shift right to click and this will add reroute nodes. Just keeps things a little bit cleaner The other one I’m gonna be doing quite a lot is the scalpel Which is control right click and that lets you sever nodes. Very useful We’re gonna be making 4 shapes, right Circles, squares, triangles, and hearts And I feel like these will give you a good understanding of what we’re doing with nodes because it’s not just about putting a shape on a cross-hair. We’re not just saying draw a circle here or draw a square here. What we’re saying is these gradients describe values from zero in the middle to in this case 1 and -1. Although this is actually an infinite gradient so it’s just the amount of it that is currently on our object is 1 to -1. Hopefully this will make more sense as we work through What we’re gonna be doing procedurally is we’re gonna be generating shapes from these values so we’re not saying per shape on top of this using the location we are taking the X values from 0 up, and actually below as well, and the same for Y. So for all of these we’re going to be using object coordinates. Something I like to do is I like to press Shift Tab, or you can also go up here and click the magnet, this will just snap your nodes to the grid. Keeps it neat. Then also I like to hide unused sockets which you can see is CTRL + H. So there we go CTRL+ H. First one we’re going to be doing is the circle. What we want to draw a circle is we need a radius and we want this radius to be the same all the way around. So basically we want to be able to define a length. Now Blender has a node that does this very easily so Shift+A > Converter > Vector Math. That goes on top you can just drop this on top of the node. To release it from the node, without breaking the noodle, I just held Alt to pull it off And you can just drag it back on to the noodle and it’ll splice in. So we can change this from add to length and you can see that this has given us a gradient out from (0,0). Now how this is calculated is it’s using Pythagorean theory: A^2 + B^2 = C^2 For a triangle with a right angle like that So we want to know what this point is here. We want to know what that is, and we have the X and the Y coordinate and we want this to equal this distance here – the value of this point is equal to the distance. We can say that to get C, this side, we can get rid of that by square rooting everything. So just to display that, we are going to use a Converter > Separate XYZ. You don’t have to do this but I feel like understanding exactly how everything works will add to your ability to manipulate what you’re doing later so please bare with me. We’re taking our X which you can see here and we are squaring it. We are taking our Y and we’re doing the same. We are then adding these together to give us that, and then we are doing square root. So you can see that this and this, the output is identical, and that is how the length node calculates that value from the vector input. It was important to recognize and this is not just dropping a radial gradient on that point zero zero is calculating each value of each point on the surface based on its UV coordinates based on that formula that we just did. What if we want to get rid of some of the edge and change the size of it? Well everybody has different

ways to do this My way is to use a MixRGB node. I’m just gonna drop on here. First thing we’re gonna do is we’re gonna set this to Color Burn then we’re gonna set the value to black on 2. Now you can see that as we increase and decrease the factor, this changes the size of our gradient. Now if you clamp a node, it basically means that it is limiting the output to be between 0 and 1. Color burn and color dodge will always clump the output, so this is only zero. It’s not less than zero, if that makes sense. Now to decrease the fall-off, I’m gonna be using a Color Dodge node and I’m gonna set the value of this one to be white and now you can see that this is bringing the whites in, and this is allowing us to change the scale You could, alternatively, use a Converter > Math node and set this to Greater Than and this will give you control over the size of it. Basically saying, is this greater than 0.35? Yes No. That’s how that works. It’s just a binary output. Issue is that you get very hard edges, whereas this allows you to control the edge. Lets you have it completely hard as well but lets have a bit of softness if you so wish. Another way that people do this is with the Color Ramp Color Ramp is one that is, again, super useful. It lets you bring up the black and it lets you bring in the white. This is nice but it requires you to move these flags which you’ll see later, when we put all of this into a group node, that’s not very useful to us. You want to put this in a frame and CTRL+J with the nodes selected. N to bring up your Information Panel and change the label to Circle. Next one we’re going to be doing is squares. So how are we gonna get squares? Well we’re going to be doing a little bit of separating and then joining back together so Separate XYZ. So this is gonna give us a readout for our X and our Y. What we want to do is we want to have this mirrored on both sides because we want our square to be dead center To do this we’re gonna use something called Absolute the notation for Absolute is two vertical lines. So what we have here outputting is X but it’s |X| We’re using the vector absolute it’s also an absolute on the normal math node This one will take a single stream of information, that’s what the gray means This one will take a triple of information, that’s what the purple or yellow mean, is they will take three streams. Very useful because we now have |X| and |Y|. Absolute basically makes all values positive so -1 becomes 1, -3 becomes 3, but also the positive ones remain positive What we can do this is we can add our color dodge and color burn MixRGB > Color burn. Our X goes in to here. Set this to black Color Dodge, that into color 1 Set this to white. And now what we have, on our X is we have the size and we have the fall-off Gonna do the same for Y What I did right there actually is probably worth noting. If you want to duplicate a node that has its inputs Then rather than doing Shift+D and reconnecting it you can do Ctrl+Shift+D and they will keep the noodle that goes into it. Very useful. So now we’ve got got our X and we’ve got our Y and we’re going to be using a function called Smooth Maximum. There are two ways that you could have done this, you could either go Add and then you can clamp the output, this will give us this at the corners. What I’m actually going to be doing, rather than using add, we’re gonna be using our function yeah she’s gonna be called smooth maximum know who’s gonna basically take like some value at each point do you think it has a nice full look on the corners this is an hour hour square so now that we’ve done our squares we’re gonna select all of this and ctrl J to put it all into a box and we’re gonna call this one squares next we’re going to do is triangles now how do we get an equilateral triangle when we’ve only got horizontal and a vertical gradient bear in mind that we want the center of the triangle to be at zero zero well it’s actually not as hard as you might think if we have an axis and we want to draw the triangle like this well because we want the center of it to beta 0 we also know that when the size is 0 this gradient is actually gonna be here what we know is that this triangle has a value of 60 degrees here and this is a right angle and the process to 0 at 0 so we know that y equals some this is a negative gradient some negative constant of X and it gets to 0 so plus the round which we can get rid of we can therefore say because we want to know for doing our notes we want to know when this equals 0 so what we can do is we can say y plus K x equals 0 and then from that

all we need to do is create this formula with notes so what I’m gonna do is I’m gonna add a converter separate X Y Zed now when you want the absolute of X only acts so this is mirrored but the bottom line just wants to be the bottom line we’re gonna do is we’re gonna add a math node add X set this to absolute so now what we’ve got here is our Merritt X values here so we’ve got absolute x times some constant that we don’t know what this is and then we’re gonna add Y we’re just gonna take this Y value so as you can see we’ve immediately got value here and if we change what this is x then you can see the nice rotating these two sides now if I meet press M then you can see that this gradient it continues on into the X region but with absolutely its own the considering positive integers so we get this mirrored appearance we also want to do something with the horizontal axis right so we want this to be white below and we want it to be black above what we need to do this is our y-axis we need to invert it so I’m going to get x minus 1 Y into this and there we go so now we have our upside down just like we did with the squares we’re gonna be using smooth maximum drop that in there so you can see already that we’ve got something that resembles well certainly three points I’m gonna do just before we work out what the constant is I’m gonna add the dodging burn just like how we did before so burn first and I’m gonna add the Dodge afterwards now how do we work out what this K is well K is the gradient we know that we have a triangle and we know that triangle is right angle and we know that this value here is 60 degrees so what we can actually do is we can say we have opposite we’ve got adjacent so he’s gonna be tan what we want we’re gonna be using trigonometry and this constant ya the constant for the gradient is equal to we can say turn we need to be working in radians so 360 degrees in full circle is 2 pi so 60 degrees is one third of one half of a circle so the third of Pi we can just type in here pi divided by three and then I’ll give us our 60 degrees if you don’t want to have to do that maths you do you know after you you can say this any 60 output is two radians and that’s 1.0 for seven PI by three is our angle and that is our constant it’s now for the triangle you can see that is a perfect equilateral triangle Hey okay just pausing there this is future me so just realized while editing this I haven’t actually explained properly why it is that we using ton here tangent the idea is that we need the constant that describes this gradient right so if we have our graph and we have a line coming down it then this line has an expression right so it’s y equals let’s say totally arbitrarily that this has a negative gradient of two so we can say minus 2ax notice it passes through here at three so this is how we normally describe a line now we want to know what this gradient is but all we have is this angle for our triangle for our equilateral triangle this is going to be 60 because your collateral triangles are 60 degrees interior angles on each corner and the reason that we use tan is because the gradient is the rise divided by the tread and with trigonometry we know that we have a right angle triangle we’ve got the angle and we have the opposite side and we have the adjacent side in this case we do not have the hypotenuse because we’re using just opposite and adjacent that is why we use tan so this is theta tan of theta equals opposite which in this case is y over adjacent which is ax so Y over X is right over tread so that is our gradient if we can find out what this is then we have our constant and we know that tan of theta equals this so that is why we are using tan of theta which is our angle which is 60 degrees but in radians and 60 degrees is the same as pi divided by 3 so that is the reasoning of how we got to using tan yeah I hadn’t explained how to talk so I just wanted to come back and say that real quick ok back to the other one so we can put this into a group and I’m gonna call this one and to bring up the panel of triangles then we’ve got one more to do and that is hearts so hearts obviously a little bit more challenging again for us to be able to draw a heart shape on our axis fortunately we are working with a symmetrical shape once again so we need to consider half of it the first thing that we can think of is that it’s like a circle there has been smooshed upwards on the the outside we know how to make a

circle and that’s gonna be our first thought of call I am gonna take the object equivalent I’m gonna take a vector math node I’m gonna plug it in here if the length this is gonna give us this and just so that we get a clear view of what we’re doing I’m gonna start off by having now a mixed and I know it makes Dodge we need to do some in here that makes the circle get distorted so the first thing I’m gonna do is I’m gonna separate X Y Zed and then I’m also gonna combine X Y Zed and I’m gonna start with these I’m not worrying about the e said so I’m just gonna do ctrl H to hide it what we can try and do is say as x increases we need to subtract Y from it so first of all that’s just a lot of math node in here it’s up to subtract know you can see that we’ve got in this shape here definitely distorted well what’s happening well we only want to be considering the positive x values and not negative X values so to do that we’re gonna add absolute node into our X string there we go okay so we’ve been on the way already now I think if we add constant in here then we get a little bit of play in our lateral scale – that’s nice we’ve got a little bit of control here there is an actual mathematical formula for doing a heart x squared plus y squared minus 1 all cubed subtract x squared Y cubed just have a look at what that one looks like so this is what this heart looks like I think it’s probably the most common heart shape that people used but it doesn’t go down to the zero scale which is what we want for our note because we want all of our shapes to come out with the same size I’m gonna group all of these things together I’m gonna call this one hearts now we want to make a group node a single note that will allow us to output four different shapes and control the size and control the fall-off so to do this we’re going to select all of the notes that we’re going to put inside and then do ctrl G ctrl G is gonna allow us to make a creep node you can see everything’s gonna go green here if I tab then I will tap in and out of this node so a moment you can see that it’s called a node group I’m gonna rename this one shapes so if we go into it with tab you can see that it’s now gone green we have a group input node and we have a group output node output is called color we are gonna want to have our four outputs as Circle Square triangle and hearts because we are only outputting blackamoor information from each of these I’m going to set these two single streams of information I’m gonna add full output I’m gonna delete the color one that was automatically generated when you generate an oh group if you have noodles that are coming into it and off of it then the group will automatically generates sockets for each of those noodles and it’s gonna also automatically name them and create automatic default values max min information so with these four outputs I just click add this will add a single stream value like a gray socket I’m gonna rename these ones to circles squares triangles and hearts and then I’m just going to plug these in I have texture coordinates on the inside but we want to have our factors coming in from the outside make us able to use these shapes in future projects because at the moment we have four streams rather than plugging in independently from the group input I’m gonna do shift right click and drag over the noodles and this is created one reroute perm initial one right so it’s clumped them now these two ah shit together so I’m gonna do that like that we now have all 4 coming out with this one if you want to get rid of this you can’t just press X because that will delete the noodle as well to dissolve it you can do ctrl X which will dissolve vertex like it would do in 3d modeling or you can do alt drag to get rid and then delete it once it’s disconnected so I’m gonna plug from my group input you can see that we’ve got this great out socket here transparent socket the house is to add an input then we would have a single line of information if you look vectors through a gray socket they’re gonna get compressed into a single line of information so we can’t do that what we need is we need a blue one however when you plug this transparent one into any socket it will take on the attributes of that socket so in this case purple this one we can just change the name of that director so this is gonna be our vector input next what we’re gonna do is we want to have a slide factor for our scale and our fall off because we want that slide I’m gonna plug that right on in to the factor there and then I’m also going to take another one and I’m gonna put down into the factor of the color Dodge so the first one we’re gonna call size and this eye we’re gonna call full off and then I’m gonna plug these n size into the band pull off into the Dodge there we go and now on the outside we have shapes you can see that we’ve got a factor input into which I’m gonna plug in our object coordinates now you can see that we’ve got our circles squares triangles and our hearts and on all of

these we can change the size and we can change the fall-off so now we have a very simple group if you want to add this to other materials it will be on your shift a group anything in your file which is a group or get added to this list so now you can see we are adding groups in here now this default value thing is a bit on 0.75 I said that you wanted that to be different it’s in here we could select the socket for the interface on your node settings select the default value I’m going to change mine to point five just to both of those and then I am going to just make sure that happened and now when I have them we have this here if you’ve been following along you will have this group node we for different shapes and the size and fall-off control there are many many more shapes that you can describe mathematically using this process but hopefully this video is just giving you an introduction and an overview of how we can use you v’s to generate textures you can get really deep into this and we’re going to be using this node group in next lesson where we talk more about generating vectors in order to transform and manipulate our UV coordinates so hopefully this video has been useful thanks for tuning in and I’ll see you in the next one

## Recent Comments