PRO-CEDURAL Part 1 | Advanced Blender Shading For Beginners | Base

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back to another default cube cg matter tutorial and the first thing you're probably thinking before we even get into this is why are you in a dark room and to be honest with you I have no idea it's just very late at night and I thought you know what let my voice carry you through this tutorial don't need to focus on my beautiful face what we want to kind of focus on rather is just everything I'm showing you here and blender so what is it that I'm gonna show you how to make well looks like I'm showing you how to make a cone which is kind of like a stupid tutorial it's very simple to model fairly simple to shade but there is a twist there is a reason I'm making this not only a tutorial but a tutorial series and that is that this cone is actually just a plane I know I know crazy stuff and some of you might have no idea what I'm talking about how is the cone actually plane what what's actually going on here is we have a single plane and all this geometry all this shading everything you're looking at is actually derived from this node Network which I can make fullscreen it's derived from this node network and if you haven't seen this before it can look like black magic it's like oh how do you first of all even deform the geometry and second of all how do you make something complicated with it well that's what we're gonna be talking about today I guess and it's kind of like a useless art in some sense it's like why when you just want to model the cone in this case it is kind of useless there are advantages like for example I could like change certain aspects of this like the cone radius so here I'm making it a very thin cone and it kind of breaks the geometry a bit but you just need more divisions so I can change something like that I can distort the stripes on it I could change a lot of aspects of this and that's one benefit of this what what is called a procedural workflow where we can control everything at any time nothing's baked in that's one advantage but the other advantage is that just knowing how to do this will help you out with a bunch of different projects right so this thing is rather useless right making a cone out of nodes but what you're gonna learn here will apply to things that are actually useful so generally the cone is actually a fairly simple example once you know what you're doing your cones actually not that bad and that's why I picked it but if you haven't touched nodes before I imagine this will not feel very simple at all kind of feels they can advance topic so I'm gonna try to break this down in a beginner fashion and I think I've gone over enough intro so basic idea is we're gonna make a cone procedurally out of shader nodes and I'm gonna try to explain it as slowly as possible so this is the blender scene I'm gonna start off with probably you're gonna start off with the same one I'm using blender version 2.9 I believe yes the 2.9 alpha now might be in beta I don't know older versions of blender work newer versions if you're watching this in the future of blender will also work um do not worry about this the only thing that matters is we need to be in cycles and this is actually super important because the main idea one of the main ideas of making this cone is gonna be displacement taking a plane and deforming it and this only works in shading if you're in cycles does not work an Eevee so cycles and then just pick whatever settings you want beyond that so I'm gonna use my GPU to start off I'm just gonna take this cube and replace it with a plane since this is what we want to convert into a cone technically you could do it with a cube but I think this is actually much simpler I'm also gonna turn on experimental mode and add a subdivision surface which kind of smooths this out right if we enable more divisions and all this which I'm not going to do right now although we could we could like increase the levels it'll make it a smoother we do want extra divisions however we do not want this smoothing so just click simple and this will kind of divide it without changing the overall form of it so again add a modifier of subdivision surface set it to simple and if you have experimental mode enabled like I do you're gonna have this feature for adaptive which you want enable this basically says don't subdivide by certain amount just subdivide depending on how close it is to the camera so here it's gonna be very subdivided whereas if I go further away not so much because you need less geometry because it's taking up less of the screen this is just basic setup now in the shading workspace which is where we're gonna be spending our time one more thing we need to do before we can actually get started so I'm just gonna make a new material called cone and we should probably save this all this is just some basic setup hopefully it's understandable we'll call this video cone the last thing as I was saying that you need to take care of is for this material whatever material you're using to make our cone make sure you go to the material settings and under settings go to displacement and make sure you either have displacement only or even better displacement and bump so before it was bump only means that whenever we plug something into the into the displacement socket it wouldn't have done anything so that's why we care okay so how do we start off what is this first part of making the cone about well I found an interesting way to divide these videos is by going over different features of the cone so the first feature of a cone is kind of like the base of it which is a rounded square it's basically what is sitting on the cement or on the street or just on the floor in general so we want to make the base of it and then we'll work up to the circle and whatever else so our first goal is making a rounded circle sorry I hope I didn't say that twice but a rounded square is what I meant hopefully I didn't say circle either way our first goal is making a rounded square which is kind of easy but we want to make sure it's fully procedural meaning we can change it on the fly even after the fact so I guess the first part of making a rounded square is probably just making a square so I'm going to start off with texture coordinates and we can either use generated UV or object it's kind of up to you I prefer something with the origin at the center so right now object coordinates has that alternatively you could use something like scrolling to UV coordinates alternatively you could use something like UV coordinates and then just displace them by minus 0.5 and then it will give us something fairly similar to object coordinates we just need to scale it a bit but anything with an origin in the center is good in my book so I recommend object coordinates just use those ok so now we have our object coordinates and I'm going to separate them by XY and z so as we look at X you can see we have negative x values as we get to 0 and then as we progress up the x axis it goes to positive values with why it's vertical and with Z we kind of just don't care we don't care about this third dimension okay and again I'm trying to keep this as simple as possible for those of you don't understand what's going on the way I want you to think about this is we're gonna look at where our X values greater than this number and you can see it's just sweeping from left to right so really this is just the x-coordinate of our object to where the origin is in the middle okay so now we kind of have x axis and y axis which is a two-dimensional kind of graphing situation how do we make a square out of this well there's a couple ways the way I like which is now the fastest one of the fastest you staff to do a bit more because the math and ode didn't have so many options but nowadays we have something called compare so I'm going to choose compare and let's compare X let's compare X to 0 with some threshold so I'll explain this in a second you can see what this note basically does is it creates a stripe vertically that we can control the thickness of okay why is this well it's taking our x value and comparing it to 0 so X compared to zero and we're and this is our threshold so we're saying how closes X to 0 with in distress hold if it's very small then there will be only a very thin slice of values that actually satisfy this condition if it's very large then you know once we get to 1 it actually fills up the whole thing so you can kind of think of this as a radius in a kind of very cubic square sense so again is X within this threshold of the value we're just comparing them we can then duplicate this and do the same thing for our Y which think think for yourself what this will look well with this look like when we view it well it's going to look horizontal because now we're comparing Y values which makes it look like a horizontal stripe and we can control it again so if we want it to be a square we kind of want to combine these meaning that first of all we should use a value note or something like it to give the side length the same value because the square has the same horizontal and vertical length otherwise we'd have a rectangle and then to combine this region in this region all we have to do is just in another math node and set this to multiply the way you want to think about this is that multiplication means and so where do we have this and this at the same time so what's the intersection well it's only at the square whereas something like addition ad is saying or which kind of looks like this yes there's a stronger overlap in the middle but it kind of gives us a cross so it's the or for and vs. and for multiplying okay so now we have a square that we can control the radius of alternatively if we had these be independent we'd have a rectangle so we could control these axes individually but we do like the fact that we can control these side lengths with a single value because it is a square okay so let's say that for now we're gonna choose point five as our you know side length or is it its I guess it's kind of like half the side length because of the radius thing either way or maybe it is the full thing it doesn't matter either way think about this as a radius and I'm just gonna give it that name okay so now that we've made our square the question is how do we round the corners I mean the expression that we're using mathematically doesn't really have information about where the corners are nor would we know how to round them so let's try to take a different approach so here's like one algorithm or one idea for how to do it so imagine we took the square and added a circle at each corner so one here one here one here and one here well wouldn't really give us a rounded square because the circles are actually contained inside of here it's getting us close I get spitting the corners where we want them with this nice circle but we still have this kind of sharp corner leftover so we want to do that with the circles but we also want to cut into the shape first so imagine that with this corner we kind of cut away a square and then we add in a circle that would give us the nice rounded corner so that's the idea we're gonna go with so first of all how do we get rid of squares how do we delete the corners and then how do we add in circles so for deleting the corners we need to know the coordinates of each of these well let's think about what the coordinates are we know that the origin is right here it's in the middle and coordinate zero zero and we know that this corner is this radius in this case it's 0.5 along the X and 0.5 along the Y so in this case it's 0.5 0.5 now it is 0.67 0.67 and in general as a value value over here it's negative value negative value because we're going to the left which is negative X and then down which is negative y and then you know you could keep going like this top left is negative value for negative X and then value etc okay so we kind of do know the coordinates they're dependent on this so let's try to make a square on each of these corners and we can kind of repeat this note set up but we just want to shift it up here so how do we do this well first of all let's view our object coordinates if we can take this origin and move it to the corner and again we'd have to do this for all four but if we could take this origin and move it to the corner that would be super useful right that's exactly what we want then we'd have the origin centered at where we want all the action to happen well we can do that very simply by adding a vector math node which is you know this is addition of a vector just translates everything essentially so here I'm shifting the coordinate system on the X and the y and we know that we want to translate everything by at least the x and y by this value right here so we did either this is kind of a tricky situation you can either plug this in and it will like kind of do it I guess you want to multiply by negative one so now we have the bottom left corner but it's also manipulating the Z coordinate because we've said use this value for x y&z we kind of want to ignore that part so what I'm gonna do is I'm gonna make a combined XYZ node so instead of putting in our vector manually here we could connect this and control it outside of the addition and then we're just going to control X let me try that again x and y and again this is the bottom left corner because it's kind of counterintuitive you'd think that adding point five point five which shifted upwards but rather it's saying this point was already negative 0.5 negative 0.5 and what happens when he had point five point five well it bounces out to zero that's the origin so it's kind of the opposite of what you'd think let me just make the opposite of the scenario so before these values reach here what we can do is put a math note in between set it to multiply by negative one and now it will be up there okay and then we could kind of repeat this node Network from before so let's literally do that let's just copy it shift D to do that and now we're gonna plug this and instead so instead of whoops I've lost my nose I think button yeah that there's a couple hotkeys for covering that but um what I was saying is instead of just bringing these object nodes directly into our square setup we're bringing in the translated version that's the idea let's get rid of that okay so currently what is this gonna look like well it's gonna look like a square that is centered right here with a radius of 0.49 point four nine and if we add in a value node just like before now it's a radius of square centered there we can now control this okay so if we want to have this cut away from our original square it's kind of obvious what we need to do we take this Square and subtract this square right we want to get rid of it so how do we do that we just take another math note said it's just to subtract and we want to subtract we start off with this and we want to subtract this away so we'll just do that right here and now you can see we've made a square with the corner kind of cut off and we can control kind of the radius of that cut off okay cool one more technical thing to think about before we kind of do this for all four are the three remaining corners is technically technically actually yeah technically some of the square especially the area up here is kind of hanging off an area where there is no square here basically what I'm trying to say is when we subtract we kind of get rid of the intersection but some of this extra stuff over here is not just zero but it's negative because we took zero and subtracted some of the remainder of the square a nice way to visualize this a nice way to visualize this is with a greater than node so you can see this looks exactly the same but if we go into the negative territory we kind of have this hidden thing right here which you know we don't see because anything below zero is just kind of set to black but could mess up our displacement in the future so to fix that just enable clamp and that'll make sure that anything below zero just get sent to zero right it clamps it between zero and one and now if we do a greater than and go under zero it will just give us you know everything will give us white because everything is bigger than a negative value currently because of clamping okay so now the question is do we need to kind of just do we need to kind of duplicate this and then each time use a different vector over here to get all the corners that would be one way to do it but not only would it be pretty computationally expensive because you've been adding you'd be adding a lot of nodes but it'd be messy and it would take a lot of time so let me go over a trick that will help you quite a bit so here are here's the coordinate system that we're using to you know do the thing really what we want to do is do the same trick for this corner and for this corner and for this corner and a nice way to do that is notice that anything that isn't this top right area anything that isn't this top right area has the issue of being a negative in some sense so this black area is negative and X and negative and Y this area is negative and X this area is negative and Y basically what I'm saying is if we can somehow convert these areas to being entirely positive then we'd have the exact same thing going on as this quadrant over here and there's a name for this this idea and the name is absolute value so vector math node we set it to absolute value if I can find it absolute and I will be honest with you I mean we could logic it out but I do always forget where it should be placed so let's try to put it ahead so that doesn't seem to really do what we want right we want this black dot not only here but in the other three corners so it's definitely not that and I'm thinking I'm thinking that what we need to do is put this probably before so let's try that there you go you know if you think this out it probably made sense you know before trying it back and forth and all this but the reason that this works is originally we have object coordinates where again we have this quadrant idea where this is a positive quadrant and the other three have negative you know components to them if we take an absolute value then they're all positive and then when we shift them it's kind of doing the thing everywhere okay if you don't understand that don't worry basically the trick is absolute value gives us a nice four-way mirroring kind of like a symmetry and then if we view our squares now we have them in all four quadrants and really in all four corners that's the thing and we can control the radius which means we're subtracting away this entire thing which gives us this so we've got we've kind of made a procedural cross generation and you can see that now if we can somehow add in circles like here and here then it will look like we have rounded corners not really we're just kind of taking a square subtracting away squares and then adding circles but visually it does do exactly that okay so how do we do that well we already know that we want to use this trick this absolute value trick to put a circle not only in this top right quadrant but in the other four so if we can focus on making a circle on the top right quadrant we all the rest of the work is already gonna be done for us so I say that we take our coordinate system here this absolute value and shifted coordinate system which looks like this and let's use it to make a circle there's a bunch of ways to do this the easiest way in my opinion is using the length function which when you input in vectors because that's what this is it outputs the size or magnitude or length of those vectors and here's what it looks like you can kind of see how this might already give us four circles basically think about it as let's only focus on the top right quadrant for now so right here is where one of the origins were that we've kind of manipulated to be there that's going to have a length of 0 because the vector is 0 0 0 length of that is 0 and then as we go radially outward from that origin it's gonna give us a nice radial gradient meaning we were kind of just mapping the radius in each of these quadrants right because we did the Merrit trick if we muted this then it would just look like that and if we muted this it would be in the center is the idea so that's unmute so now to make this look like you know circles we could either okay there's two methods you could either use a color ramp node and I feel like this is a kind of short-sighted way of doing it so you make this kind of crisp fall off it works however not only is it very imprecise because you're just kind of dragging handles but we don't just want to any circles we want circles with the exact correct radius otherwise when we put the circles on top of this there will be some I mean we'll get the nice overlap but we're gonna get some areas of the circle that are outside of where we want right so our radius is already chosen for us so how do we do this well we can use a math node math node since we've converted these vectors into values because the length is just a number it's not three dimensional and we're gonna use something like either greater than or less than so greater than is gonna say where is the radius bigger than in this case point five and then we can manipulate that and notice that the circles are black because anywhere in the interior has a radius smaller than this and the radius as you go inwards gets smaller and smaller and smaller so obviously it's gonna be smaller than point two nine in this case that's one way to do it I'm gonna use the less than which is just the inverse it doesn't matter you could have just done this and then use the invert node or something like that whatever you want we're gonna use the less than so less than and again we don't just want any value and let me illustrate why I've already explained it but let me illustrate so we want to take this and add add our circles back in which are already centered on the corners because of our nice set up from before so let's just add because we want this or this and you can see and again make sure you have clamping otherwise you're gonna have some areas that have a value of two because we're taking a region with one in a region with one and adding them which gives us two so just clamp that to make it a uniform you can see that these circles are way too big and you could just kind of guess what the radius should be oh by the way we do need to shift them down I did forget that maybe we should take care of that first but either way you do see the argument there in this case is too big and we'd kind of have to manipulate it to be just right so let's take care of that shifting that I forgot to consider so right now these circles are centered where they're centered at the corners of our original square that's close to what we want but instead we want them centered at kind of where kind of the corner of where we cut it off which is determined which is determined to remember by this a radius of of these squares right this determines where the corners are so we want this corner this coronary etc well I feel like this is it should be pretty obvious that all we need to do is manipulate our input coordinates so I'm just gonna duplicate these and feed this into what we had before like this and let's do that so now we have two different variations one very let me get rid of that I am having trouble selecting this we have one variation of our coordinate system the absolute value in addition going to our squares and we have another variation of absolute value in addition going to our circles so let's do what we had before we're using the same vector that uses these you know x and y values that we already explained why we're using so currently this should give us the exact same thing as before which almost gives us what we want but again the circles are in the wrong place which is visible when we do this so all we need to do is we need to manipulate what vector we're putting in here so it shifts correctly so I'm gonna do it by putting in another vector ad note I know it's getting messy right here and you can see that we can kind of just manipulate these values until it's right and here you can see why this actually looks like a rounded square once we get the positions right but how do we get this exactly without guessing well all we have to do is use another combined XYZ and this time instead of using x and y from our square radius we'll use it from our corner squares I'll clean this up in a bit because it is getting crazy so same as before X Y okay which gives us what we want however again these circles aren't big enough and they should imagine that they're centered here they're centered it's getting confusing they're centered at the corner of this of this cutout this is where they're centered well how big should they be they should have a radius of this length right and that would give us a nice perfect circle well we actually already know this value and that is this one so point oh eight point oh eight so we take this we plug it in here we view it and it's beautiful it's beautiful and you might be thinking okay that was a lot of work I could have just moved stuff manually and I balled it until it made sense we'll look at it this way look at it this way we have two parameters we have two parameters one of them is the radius and I guess I should specify we'll call this main radius or maybe we should just call it side length really because it's referring to the original square and we'll call this one rounding because it's referring to the radius of our circles and it also positions them in the correct spot which looks like rounding so here's what I want you to consider we have one slider that changes the side length and the circle's notice are staying in the correct space spot and the rounding works as well if we make our rounding big enough it will look like a circle and if we make it small enough it will look like a square and all of this works together you could have made these independent from each other this one and this one so you can get a rounded rectangle instead of a square but in this case we have a much simpler situation and remember we kind of got lost in the weeds here remember the idea here is we wanted to make a nice procedural base for our cone so a cone kind of looks something like it doesn't have this much rounding more like something like this and with our you know our generator we it's basically a generator for with our generator for rounded squares we can now create any base for a cone that we want and let me just give you a sneak peak about what we can do with this first of all let's do a bit of cleanup don't worry about the fact that this is a mess because honestly we'd never need a touch thus the only things we care about are these red things these inputs because that's what we'd be manipulating so just drag everything that isn't read into a clump and then you could either you know select all and then control G which puts them in a nice node group and that's probably the better way to do it or you could just hit shift P to put them in a frame I'm gonna go with ctrl G to put them in a node group which we can move closer so now it's you know it's still the same thing going on but it's a lot simpler and we can always control using these or alternatively you could just use you know this stuff built right into the node but I think for simplicity sake we'll just keep these same set up from before okay so I want to show you one more thing before we wrap up part one which I feel like was pretty intense but again it's hard to explain the stuff out of beginner level because it's very mathematical but remember we set up all our displacement stuff let's actually see what this looks like with displacement so what I'm gonna do is I'm going to view this with a diffuse BST F and for our displacement we're just gonna use a displacement node hook that up and then and then by the way set in the level to zero said it's not like offset at all what should what should our height be for our displacement I'll give you a hint this is our height I'm meaning black is zero meaning a height of zero don't change it and 1 or white is a height of one so we can just put that here and let's view it with there our diffuse be SDF okay so a couple things first of all it looks a bit glitchy especially in the corners and this is just because it's procedural meaning that the amount of detail that we're gonna see how smooth this corner is gonna be is directly dependent on how much geometry we have so if we take our like dicing scale and make it smaller you can see this gets nice and rounder you could go down to 0.2 this is going to become more and more computationally expensive as you continue but you kind of just want to set this to a very small number on render for now we're just viewing it and the second thing is that the effect of this is very large right a cone isn't this tall the base of it we can either control the with the scale to make it smaller but that's not really what we want because we'd rather keep this at at one since we're gonna be feeding more than this than just this into our height so we want to keep this normalized so what I recommend is just using something like a math node and then just multiplying it before it even reaches height so that's one way to do it and let's actually change our lighting to an HDR I'd just so we can see what's going on a bit better so I'm just gonna use a free HDI that I have from like HDR I Haven or something something with a bit of contrast like that and let's hide that with film with film transparent okay so again we can return to our nodes which I always lose we want to make this even you know not as tall and and if anything you could just make a value node so right now it's like point 1 3 and then connect this and now we actually have another parameter for the height of our cone so you can see how all of this is building very procedurally so let me call this um let me call this base height just like that okay and again to make this smoother we just bring this down and I think this level also helps but again it will make everything a bit slower so I just recommend making it very smooth on render time and by the way for you experts out there who want a good way to solve this without just increasing the resolution or you know decreasing dicing scale which increases the resolution a good solution is instead of having a very harsh map that goes from let me views it view this from the top and remove displacement that goes from black Toit immediately if you could have a bit of a gradient a bit of a fall-off there will be a nice transition for the geometry to catch up with the boundary so hopefully professionals experts know what I'm talking about right there that's just an advanced solution but for now this is actually fine and if you look at a cone the base of a cone it is pretty straight there's a bit of curvature but this is at least a reasonable approximation so I think this is a good place to leave off this part of making the cone thank you for watching part one of this advanced procedural stuff I just wanted to end off with this before I actually end the video if you want to support this channel and everything I do and you like these tutorials and you want to get benefits the best way to do that is via my patreon you're gonna get exclusive video tutorials if you get a certain tier you can get project files you can get a whole bunch of other stuff but in general it's just a very very nice way to support me and these tutorials if that's something you want to do and um yeah the patreon promotion at the very end I'm serious about it it is the only reason I can do YouTube full-time so thank you everybody who wants to do that enjoy part two when it comes out there might be a day or two doing
Info
Channel: Default Cube
Views: 81,763
Rating: undefined out of 5
Keywords: blender, tutorial, shading, advanced, beginners, procedural, nodes, material, node network, part 1, cg, vfx, cgi, 3d, shader editor
Id: N7-8rZOtjIQ
Channel Id: undefined
Length: 31min 58sec (1918 seconds)
Published: Sat May 30 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.