Houdini - Procedural Modeling Tips! - Curve Directions

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
howdy guys any pixel here and in this video i wanted to show you another procedural modeling tip that really comes up quite often i get tons and tons of questions about individuals having problems you know with the directions on their curves and how to use the directions in the sweep node and how to use it in the copy to points node and so i wanted to make a whole video about you know just generating the curve directions that are so important when you're doing procedural modeling and so what we're going to do in this video is we're going to go through and i'm going to show you how to produce this particular curve here that has all the proper directions for when you're using things like the sweep node or even when you're doing your own like skinning and copy to points these are very very important and learning how to control these particular vectors or directions inside of houdini for your procedure models for dini engine or whatever you're doing inside houdini is very crucial to producing proper procedural modeling along curves so let's take a look alright so let's dive into learning a little bit about the curve direction so i'm going to call this new geocontainer curve directions like so we're going to jump inside by hitting enter you can also double click now let's create a curve that we can work with so we don't need to get all fancy with this or anything like that i'm actually going to go into my top view by hitting spacebar 2 and i'm going to turn on my snapping now you notice that the uh grid numbers aren't on i've noticed it's a bug with the houdini if you just toggle in and out they come back so i'm going to zoom back in here and uh let's just create some crazy curve like that you can always go and select these points by moving around just click on them then move them around there we go very cool all right so i'm going to hit spacebar one on the keyboard and hit enter again i'm going to actually move these guys up and down a little bit here because we want to make sure that our curve directions actually follow the curve when it goes up and down like that so i want to make proper curve directions it's really useful when you start using the sweep node or you're you know using the copy to points node it actually comes in handy so much that's why it's a good thing to have in your toolbox all right so with that done let's go and drop down a resample node handy resample node and i'm going to resample this to a length of one so for every one meter or one unit here inside of houdini we're going to get a point along the curve so let's actually switch this over to subdivision curve so we get something that's kind of smooth like so all right very cool all right so uh to get these curved directions uh created let's go and drop down a attribute wrangle node now you don't have to do with an attribute wrangle node you could do with a point bop node i'm just more comfortable with um vex and so you're more welcome to do it in a point pop i might actually show that here once i finish the vex version so i'm going to call this guy curve ders and let's dive inside of our vex code here so the way this works is we need actually to generate a direction normal that actually follows the curve here and to do that it's really easy to go into the resample node here and turn on the tangent attribute and just type in capital n that stands for normal and you might not be able to see it's really tiny because the curve is really big you can make those guys bigger if you just hit d on the keyboard with your mouse over the scene view here and you can actually increase the size you can see that we now have a normal or a vector direction or a line if you will that is following the direction of the curve as it turns and twists and stuff all right so we want to use that as our base okay so the way this works is we need to create a um a normal dot is actually flat in the y direction so we'll try to step through this just to make it easier to understand so i'm going to call this vector flat norm that's what i usually uh call it and this is going to be equal to the current normal so we're just initializing it now to this current flow direction normal and then we want to go and say flat norm dot y is equal to zero that'll flatten it out now we can actually go and uh view this here if we were to turn this into a attribute currently this particular variable right here is uh just a local variable right to turn it into an attribute that we can actually use uh we need to put a v and then at symbol in front of it so it's a vector that's what the v stands for and that symbol turns it into an attribute that gets then put onto the geometry spreadsheet here so you have it here in the geometry spreadsheet and then we can go and visualize it if you if you select the attribute wrangle node and then x on the keyboard you will create a visualize node there and then we can go and visualize that flat norm so i'm doing this just so you guys can see what we're doing the whole time here and it currently exists on the point so you need to set the class to points uh the marker needs to be set where the type needs to be set to marker and then the style needs to be set to a vector so you can see now we've taken our original normal that's following the the curve and we've flattened it out in y all right so this is the first step into getting these guys working here all right so then uh now that we've found it out we actually need to go and normalize it so we need to say flat norm is equal to normalize flat norm and the reason why we're doing this is we want to keep all of our vectors um in a uh zero or yeah i know zero to one range and i need to go and put the uh at symbol in front of here because it is an attribute like so there we go all right so now we're normalized i'm really just doing that so all of our vectors have a length of one right it just makes it easier when you're you're not going to incur any sort of errors or anything like that when you're doing um any of the uh operations we're going to do here in just a second all right so now we've got this particular vector in place we want to develop the right vector so we're going to develop a vector that actually points outwards from the curve all right and so to do that we just say v at right again we're making it a an attribute so we can visualize it and then i'm going to do the cross product of the up vector so 0 1 0 so that's literally a vector pointing up in y here in space right so it's just a standard vector pointing upwards and then we want to put in the flat norm for this so the cross product will give you a a vector that is perpendicular to two vectors right so in this case i'm taking the up vector and this flat vector and what it'll do is it'll give us a right vector all right so it'll be perpendicular so one thing you can do in these visualize node is you can add other visualize markers in here and so if you hit this little duplicate button here and then in the drop down you'll see you have a second version here what we can do now is we can look at the right vector so i'm going to do right and we need to make sure we turn it on alright so now we have that perpendicular vector all right so hopefully that makes sense we have one vector that's pointing with the direction of the curve and then we have the up vector and we're taking the cross product of that and that gives us this perpendicular vector towards it so now if we look you can see we have a nice vector that's pointing always outwards from the curve it's very useful in many situations all right so then the last vector that we need is the up vector so i'm going to say v add up is equal to the cross product of at n so remember at n is our actual flow direction normal and then we also want to do at right so that'll give us a perpendicular vector that points um perpendicular to the curve so it'll point upwards all right so let's add another one of these guys let's go to number three here and i'm going to set this one up and make sure to set it to active and there you go you can color code these two so if you come into the marker color and just change it to green let's go to the right and let's change this guy to red the common colors for these guys and uh let's go to the first one and let's just turn it off now so now we've got all the uh vectors that we need for curves so when you pump this into a sweep node and this just comes up you know so many times when i'm uh creating my courses and i get questions about you know issues with curves and stuff like that um and the sweep node not creating a proper sweep it's usually usually comes down to these curve directions so you can see now our geometry is following along very nicely um you know the sweep node does try to to produce that type of geometry by default but you're going to run into a lot of situations where it doesn't and so generating these curve directions uh will always get you this result it's always a good idea so you know once you get this all typed out you can come up here to this little cog wheel up here and go uh save preset you can see i already have one here go save save preset and then just call this uh curve underscore there and then just say save preset and it sets it to your houdini user pref file which is inside of your documents houdini folder all right hope you guys enjoyed that so for those of you who want to see the point bob uh note version so let's drop down a point bob node here and uh let's just do the same process so you can see you know how you would do it without backs right so we need to go and dive inside so the first thing we have to do is uh we need to go and break up our normal here so what i need to do is go and drop down a vector to float node and we're going to pump in the normal there and then we need to go do another float to vector and just pump in the x and the z because we want our y value to be zero so if i were to put this into the normal nail here and take a look at my normals you can see we get that same result that we saw with the flat norm right so that's our flat normal right there so then all we really need to do is create a constant here so let's create a constant value and this allows us to create that world up vector so we need to set that up right here so this guy right here is the equivalent of setting up this constant value so we're going to go and create a vector and initialize it to zero one zero right so now we have that up vector so well we need to take the cross product now and so there's a note for that we just take the cross product and we just want to match the vex code that we wrote so i'm going to pump this guy in for the first element there and this for the second element so now we have our right vector all right so now you have the right vector here pretty cool but i don't want to actually override my normals i want to keep the original normal that we have and so we don't really need this geometry output note so what i'm going to do is create a new bind export this is how you create attributes with the point bop node so we're going to bind export meaning we're going to bind it to the geometry so for every point we're going to bind it export it so that way we can see it in the geometry spreadsheet and so what we need to do is set the type to a vector and we're going to give it a name of right and once we do that you can see we have this vector attribute here now on each one of those points pretty cool and let's go jump up now and take a look at the rest all we need to do now is take the current normal and the right vector and do a cross product with that to create the up attribute so i'm going to dive back into the point bob node so this is our right vector here this is our original normal right here so all we really need to do is do another cross product and we're going to do our normal for the first input here and we're going to do our cross product with our right vector and that becomes now our up vector so if i pump this in you can see now we have our up vector going all right so not really a lot of notes but if you prefer to do it in a visual programming way rather than with effects that is how you would do it all right so last thing we really need to do here is drop down another bind export node and bind and export this guy to the points call it up for the attribute name and we will then make it a vector and at this point i'm just going to cut that wire we can get rid of this geometry output now we don't need it because we're just bind exporting right here so that is the only output from this particular point bob node so if we pump in our point bob node in our visualize node we should get the same exact result all right so if i were to just switch between these two we get the same result and look at that we're actually getting this actually proves why you should normalize your vectors um so watch what as i switch these guys the lengths of the vectors are different and that will affect your procedural modeling and so we need to go and um actually normalize this flattened vector here so we need to drop down a normalized node and just run that through like so there we go so now if i switch these guys out you don't see any difference it is exactly the same so that's how you do with code and uh that is how you do with a point pop all right i hope you guys enjoyed that thanks so much so now let's take a look at a practical example of using these curve directions so one really great example here is a little tool i made to create roller coasters and this makes you know heavy use of a curve and so you need all the curve directions you know worked out especially when you want to do things like the banking and uh when you want to make sure that like in this case when i make the this loop here you want to make sure that the tracks you know are actually upside down and so understanding how to create your curve directions is very important when you're doing these procedural models for houdini engine and in houdini in general so any sort of procedural modeling task you're going to encounter these particular direction vectors and so hopefully uh it helps to see you know how you could apply what you just learned throughout this video if you're interested in more uh quick tips and tricks or you know full courses and stuff check out my patreon page it's at patreon.com forward slash any pixel thanks so much
Info
Channel: Indie-Pixel
Views: 29,213
Rating: undefined out of 5
Keywords: Houdini, Procedural Modeling, Houdini 18
Id: o1vGKRcwFWw
Channel Id: undefined
Length: 14min 25sec (865 seconds)
Published: Mon May 17 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.