Procedural Nodes (part 1) - Using simple math to create shapes in Blender

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video I'm gonna be talking about notes in the shader editor in blender and just how to make some simple procedural textures I'm gonna start off by talking about the texture coordinate node because this is a pretty important note to at least understand the basics of and then I'm gonna show you how to make these six basic shapes here we're gonna make them we're gonna play around with them a little bit and change the shape and then we're gonna see you know how we might use these shapes as well so let's get started first things first let's look at the texture core in a node on the right I've got a plane set up and I'm just viewing it from the top there on the Left I've got the shader editor open and I'm just running a very simple material it's the texture coordinate node leading into the node Wrangler viewer node just into the material output in order to have this viewer you have to have no triangular enabled so just make sure you do but you probably do already I'm guessing a nice shortcut by the way is to hold down ctrl shift and left-click on any node and it shows that nodes effect on your final material output so right now we're looking at the generated node coming out of the texture coordinate node and on the right we see you know that's nice colorful pattern but it's a little tricky to get a handle on so I'm gonna introduce a node that just allows us to you know make a bit more sense of this here and that is the separate RGB node so plugging that in it separates this image on the right into three color channels red green and blue right now we've plugged into the red we can see it is represented in a shade of gray that is how the value is translated basically black is equal to zero on the left here and white is equal to one on the right here that means that in the very center would be 0.5 so one thing I want you to notice is the red value it goes from left to right in a positive direction it's actually the same as the x-axis that is labeled in red you know it's kind of interesting I didn't really realize that until recently I was just kind of thinking about it and it was just kind of interesting so I just to point it out let's check out the green channel and we can see the same kind of thing happening here zero is now on the bottom and one is on the top and point five is in the middle and again it goes in the same direction as the y-axis which is labeled with a green color and finally we can check out the blue channel and it actually just looks kind of grey because there's actually no change the change would be if we had some said dimension to our object but since we don't it's just a solid middle gray color so another thing we could put in here instead of separate RGB is a similar node and that is separate oops separate XYZ and if we plug this in it actually gives us the same kind of value it's not exactly the same I I mean I assume but for what I'm going to be doing here today it's it gives the same results so I'm kind of treating is the same so separate X Y is that kind of the same thing X you know same as the red value Y is the same as the green value in Zed is just the blue value again there so just just to make a note of that separate XY said and separate RGB are similar just for what I'm doing today let's take it another look at the texture coordinate node it's still coming from the generated output there and it's going right into the material output I've got the same color we saw before but now we can make a bit more sense of it I actually find it kind of helpful to overlay this graph here this is what I'm used to seeing the horizontal x-axis and the vertical y-axis and we got the origin point just in the bottom left corner of this object so I think it's useful to think about the generated output basically projecting a coordinate system onto your object with the origin point being in the corner and it's actually more accurate to have these numbers instead of one to ten it should actually be 0.1 to one but I just found it a little easier to work with these whole numbers at first but it's just more accurate anyways with the POI one-two-one so next we're gonna check out UV I'm gonna skip over normal for now not really sure how to use that one but UV is pretty similar to generate it in that we've still got the origin point on the bottom left and if we plug in a separate RGB node we can kind of see what's going on here it's the same red pattern left to right same green pattern bottom to top there the blue however is different if you recall in the generated node it was a medium gray color probably a 0.5 and this is more like a zero so showing you a different slice of the z-axis but besides that the x and y values are the same for generated and for UV next step we'll check out the object node here plug that in and it looks a little different it's actually very similar to UV but now the origin point is changed so I'm going to get rid of this graph and bring up another graph and this time the origin point is in the middle let's see what that looks like when we plug in a seperate RGB node you can see now the red values anything less than zero is black so half this graph is black and green same kind of thing but on the y axis and blue once again it's just black so this one here it's same as UV but now our origin point is in the middle and one final thing I want to mention about the object node is that you can actually come down here and select an object to kind of move the origin point around so I'll show you what I mean on the right here I'm going to add in an empty and then I'm going to come down here I'm gonna select my empty and then on the right I can move that empty around and it changes the origin point so you can have an origin point anywhere you want in your object this way it seems like it could be useful okay we're going to start up by making that first shape here it's basically a linear relationship and the formula is y equals 2x so I've got the object output from my texture coordinate note and I'm gonna feed that into a separate XYZ note and from there I'm gonna add in a math note and I'm going to change this to multiply and change this bottom value to two and what this does is it basically multiplies every x value by two so it takes care of that 2x portion of the graph make another math note and I'm going to change this to greater than and then plug the Y into the bottom socket of that note and what this does is if the top value is greater than the bottom value then it returns black and if it's opposite it returns white so it's just kind of a useful way to make two colors there and we could change this if we change greater than to lesser then it just swaps black and white so I'm going to change this back the second way we can change this graph is by changing this value here we change this to four be steeper change it to 0.5 be less steep change it to negative four and it would be in the other direction so we can change that around it's still a linear relationship but we can adjust it a little bit and the last way you could play around with this is you could add another math note in there change it to add and this is now an offset okay let's take a look at this second object here that's gonna be pretty similar to the last one we're still going to use the object output of the texture coordinate node but this time the formula that we're going to try and recreate is y equals x squared so we'll start out the same way we'll enter in a separate XYZ note there and we'll add it in another math node but this time instead of doing multiply we'll select power instead and go to 2 so we can see what it's done it's basically squared all the X values over here and what that means is even when we have negative x inputs we get positive outputs just because there's you know when you square a negative number it becomes positive so we're gonna do the same thing as last time make a second math node change this to greater then and connect the Y socket to the bottom there again we have a parabola and we could change it back and forth by changing this to less then I'm gonna go back to greater then and we could also add in another math note change it to add and again this is an offset here so horizontal on the x-axis we could also add in another math node just another add one to the Y we could control that Y offset okay next we're gonna take a look at shape number three there and this is going to be very similar to the last shape here we're gonna add in our separate X Y Z we're gonna add in a math note change this guy to power and instead of two we're just going to change it to three because we're gonna go for y equals x cubed this time so add in another math note we're gonna change this to greater than and connect our Y to the bottom there we have our formula y equals x cubed and again you know we can swap this around go to less than changes the colors there back to greater then and we could throw in some values here change it to add first thrown so bellas here and just move it back and forth same as before offset it on both axes if you want there so you can see like just a little flow over there just get some interesting shapes here it's not quite a straight line but it's getting closer and then you can change this value but it's definitely a lot less stable let's just put these back to zero so you can see so if you were to change this it's a lot less stable then you know the multiply was it's basically if you want to do a wider parabola you know you can keep on going up in even numbers but or odd numbers here as well but if you do any decimals and it's gonna get kind of a little bizarre and crazy okay we're gonna make the next shape and this is getting a bit more complicated we're gonna try to make a circle here and I actually got this from default cube he had a series on procedural textures okay so let's start out here it's a separate XYZ note just like before and now we're gonna add in another math note and we're gonna change this to power and change the bottom value to two we're gonna do the same to the Y value just duplicate that math node and plug it in now you can see we've got the Y squared and the x squared values here and we're gonna actually add those together make another math node here and to change it to add and then just plug these guys in here see what that's looking like it's already a circle but we just want to tighten it up a little bit so we're gonna do two more steps we're gonna add in a square root node and then we're gonna add in greater than node then we're gonna tighten this up put it to 0.5 we've got our circle just like that way to adjust this is with this value here I can increase this and it changes the size of the diameter just up or down okay we're gonna take a look at this shape number five Ron now and if this is a diamond shape so I'm gonna put this together the same way we were doing the other ones with the separate XY set know it again and we'll add in a math note and we're gonna change this to absolute and bring it down and attach the why to an absolute as well and bring this in and changes to add and just add them both together we're gonna do one more thing we're just gonna do greater than so there we go we got our diamond that was pretty quick you know it's kind of similar to the circle but it's just got the linear relationships on the side there so anyway same kind of thing here - you can just bump this up and down and it'll change and we could always add in an offset here as well just kind of move this up and down depending on which axis we're putting this on okay we're gonna take a look at shape number six now this is a it's kind of looks like a leaf to me and we're gonna do the same thing at the beginning we're gonna go separate X Y Zed and then go ahead and add in a math note and we're actually going to do a combination between the circle and the diamond just go ahead and plug this in here so we're going to use a power on the top power - - and then we're gonna do absolute on the bottom then we're just gonna add these together so let's go ahead and make a new math node change to add we'll just add those together so yeah finally last step is to add the greater than note we'll just point this to 0.5 and there we go we got our leaf just like that couple ways we could change this around again we could change the power and the absolute let's try and just swap spots there that shortcut by the way there I'm just holding down alt left clicking on a node and dragging it off and it just disconnects there so anyways I changed this around and now the leaf is just oriented differently let's try something here let me try not a power node but we'll try a multiply node we can just see we get stretchy effect there so we do that in the X or Y factor there so okay let's take a look at this parabola again and just try and modify it a little further so we can see the setup again it's just a separate XY set going into the power and then the Creator then we're gonna actually duplicate that and just make a second identical parabola so just plug that guy in there nope what's wrong put that guy in there and this guy in here and that just gives us the same parabola here so what we're gonna do is add in I don't need to search just adding in another math note there and move this parabola just down slightly well that should be on this guy here there we go so what we've got here is one parabola that's just hanging below the x-axis and one that's just sitting right on it and I'm gonna change the color of that bottom parabola by changing this greater than to a less than now it's a white parabola and this is a black parabola and I'm going to add in a mix RGB node and we're gonna mix these together will not actually mix we're going to multiply them together and change that to 1 and now we have this white band running through we can take it even a little further mostly by adding in ad multiply divide subtract notes those are gonna offset and just kind of change it so let's try an ad note here for instance you can kind of see you know why don't we put it on this one here we can kind of see it gives us these interesting shapes to go back and forth if we were to change this to multiply I kind of get some other stuff here again you know pretty interesting we were to put this on the X it give us looks like pretty similar shapes but yeah that's a good way to change it around is just to add another dimension and just multiply them together and then just use multiply or add notes you can change quite a bit let's take another look at this circle as well do something similar here so we're gonna go ahead and duplicate all these guys here and then just make an identical circle down here and then let's let's change it a little bit just this bottom one let's make it a little bigger and I'm gonna add in an ad note here and we're gonna put this to zero and then we're just gonna let's move it you know what let's put it on the Y dimension there I'll just move it just a little down just like that okay so another shortcut by the way with node wrangler is to hold down ctrl shift and right click on one node and drag it to the other and it'll automatically mix those two notes together so here for instance it gave me a mix shader' so i'm just going to adjust this a little bit here we'll go multiply i'm gonna drag this up and right now we've got kind of like two circles intersecting each other and i can change one of these and it'll be the opposite color if you recall so now we've got kind of a crescent moon shape there so that's kind of interesting and we could move this around and it just kind of changes that shape there just however we want we could do this as many times as we want and just be really creative with this stuff all right well let's look at an actual use for some of these textures that we're creating this is a texture I just created with the circle inside another circle and one use is to use this as a factor in combining two other textures or two other shaders or whatever let's look at a simple example here use this to control a mix shader' I'm gonna bring a mixed shader in here and then a diffuse and then a transparent just like that let's plug the diffuse to the top transparent to the bottom and yeah basically this guy here when I bring it to one or part me to zero it's completely diffuse and when I bring it to one it's completely transparent and I just have to switch over two cycles to see that so now it's completely transparent bring it back it's you know in the middle it's halfway so this color data here we can use this to control this factor because black is equal to a zero and white is equal to one so what that means is everywhere there's black should be this diffuse green everywhere there's white it should be the transparency so let's try that out plug it in and take a look and that's exactly what we see so we could swap that around and now it's the opposite so that's it you know I encourage you to try playing around with these six shapes and just kind of making combinations between them and tweaking parameters and you know see if you can come up with something cool
Info
Channel: Sam Bowman
Views: 87,885
Rating: undefined out of 5
Keywords: blender, procedural, nodes, shaders, editor, textures, node, shader, texture, math, nodevember
Id: Uvc2P911rZk
Channel Id: undefined
Length: 19min 36sec (1176 seconds)
Published: Mon Apr 27 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.