 Howdy guys, IndiePixel here, and in this video we're going to go and cover how to apply banking to our curve geometry tools. So if I move this slider here, you can see that we're actually producing the bank based on the direction that the curve is turning. So a really useful handy procedural modeling trick. All right, so let's take a look at how to hook this up. Let's start by dropping down a geometry node. So I'm just going to go and type in geometry and I'm going to call this banking. And then I'm going to hit enter to dive inside. And then I'm going to drop down a curve node and do a space bar two of the scene view here. And we're going to go and draw a very basic curve to make this work. I'm going to turn on my grid snapping over here. And let's just draw some random curve. There's no need to get fancy with this at this point. It's really just to develop the actual banking mechanism itself. All right, so right after that, let's go and drop down a resample node. And I'm going to resample this by every unit length there. And we're going to turn on our subdivision curves. We're going to produce our flow normal by turning on the tangent attribute and typing in capital N. And then I always like to include the curve view value. So we get a value of zero to one on each point based off of its location or its distance along the curve there. Now we can turn on our point displays. Cool. So then at this point, let's go and drop down an attribute wrangle node. And I'm going to hit shift s on the keyboard to get my better wire designs there. And I'm going to call this node the curveders. And inside of this particular wrangle node, I'm going to go and use my curveder preset. Now, if you haven't watched the curve direction view, I highly recommend watching that so you can understand what this particular code is. Or you're more than welcome to pause the video now and just copy the code from there. All right. So now what we need to do is produce a ratio along this curve that will rotate the curve directions that we have. We need to do that based off of the direction that the curve is turning. And so to do that, we are going to measure the length of this particular segment right here. All right. So let's take a look at that. In order to determine the direction in which the curve is turning, we need to measure each one of these segments here. So let's first drop down a convert line node. So let's do convert line, let me go. What the convert line does is it breaks up the segments of a curve in individual primitives. So it'll better demonstrate that if I turn out my primitive numbers here and turn on this display flag right here, you can see I only have one primitive. I want to use a convert line. I get multiple primitives per segment. And the nice thing about this node is that it produces this rest length attribute there. And so if we were to go to our primitive class there inside of geometry spreadsheet, you can see we have this rest length. And this represents the length of each one of these segments. So how can we use that to determine which direction this curve is actually turning? Well, we need to compare to another segment that is basically peaked outwards. All right. Okay. And so with the curve durs, remember, we're producing this right vector here. And so if I were to go and say at n is equal to v at right, and then turn on my normal display here, you can see we have a vector direction pointing outwards from the curve, which is very handy in this particular case. And so we can actually run that through a peak node. If I were to drop down a peak node here, like so, and we can peek it. That's not recompute the normal just so we can see this working. So we can peek it, right? Let's do a distance of one. And then let's turn on the template flag on the convert line over here. All right. So now actually, let's do this. Let's go and create another convert line over here. This will actually just make this easier to understand. And I'm going to go into hold down control and then hit the template flag here. And so you can see that for each one of these segments, their ID is exactly the same, right? So zero and one one. So what we can do is we can roll through each one of those primitives and see if the length of this original segment here is either smaller or larger than this particular segment here. All right, you'll notice that as we go around a turn in one direction, the outer segment is a little bit larger than the inner segment. And that gives you information about which way we are turning. Because if we were to look at this portion of the curve, you can see this guy is larger than this guy. So that means we're going to start to turn this way. All right. And so that's the whole idea behind this particular technique. So it's not that difficult at all. Let's go and develop this into something actually usable because we need to create basically a percentage. So how much of this particular line here is greater or smaller than this particular line over here? All right. And so let's drop down another wrangle node over here. So drop down a wrangle node. Let's select both the convert line nodes and pump them into the attribute wrangle node. And this is going to be called the bank ratio. So we're going to find the ratio that those two values, those two line segments. And to do that, we're going to do float. And I'm going to call this particular variable other length. So this is going to be the length coming into this input one. We're going to compare it against the length coming into input zero there. And so to get the length from the other primitive over here, let's actually set this to a primitive. Let's write out prim one for the second input there. And we're going to look for that rest length attribute. And we just want to put in the prim, I'm sorry. So it's the same. We're comparing the same primitive number. And then all we need to do is say f at bank ratio because we're going to put a attribute onto our primitive over here. So by doing f at that that means we're adding a new attribute to the geometry. And I'm going to say that's equal to f at rest length. So let's do rest length divided by the other length. And that gives you a percentage or a ratio. Right. And there you go. So now our bank ratio, you can see that the values get larger and smaller and some of them are less than one, and some of them are greater than one. So that means this is like an outside turn. And this is an inside turner. This one's turning right. This one's turning left, basically. It all really depends on your orientation as you're looking at the curve. Anyways, and then we want to promote that to our points. All right. So let's promote that from primitive to point. And we are going to promote the bank ratio. And we'll let's just do an average. That'll be fine for now. Cool. And so let's actually dive back in here. Very nice. And now that I have that particular value, let's actually put this all into a subnet. I like to do this with these smaller sets of nodes. It kind of makes it feel more like a function as if you're coding, right? So I'm going to call this bank ratio. So it just makes it easier to see my whole network. So now I have a ton of nodes floating around. At this point, I just need to go and drop down and attribute transfer. I want to transfer our bank ratio attribute to our original curve. Right. So we want this one right here. We don't want the curve with all the segments in it. So we want to transfer that particular value and we're going to go from our points to our points over here. So let's just transfer our bank ratio like so. Very cool. So with that, we are now set up to move on to the next step where we actually need to remap the values for you to take a look at the values right now. So I have this visualizer set up. I'm going to actually type in bank ratio. I want to visualize this value on a per point basis. I'm going to set the class to point and we're going to set this to a marker and then go to parameters turn off update. Now you can see that we're getting values of one over here for this turn and values all the way down to seven over here. So what we need to do is we need to remap that value into a usable range like negative one to one. All right. So let's go and do that. There's tons of ways you can remap values inside of Houdini, which is what makes Houdini super awesome. So I'm just going to do it through all nodes basically. So let's do this. I'm going to do an attribute promote. And let's drop down that value and I'm going to take the current bank ratio. So we want to go from points to a detail because I want to get the minimum value. So out of all the bank ratio values on a per point basis, what's the minimum value? So I'm just going to do that. I'm going to set the original name to bank ratio because that's the attribute that we want to basically promote to a detail. I don't want to delete the original and I want to change the name. So I'm going to say min ratio like so. So that's going to be the minimum value that it finds on the curve out of all the points. All right. So we can call this min ratio. I'm just going to duplicate that with the alt left click and drag and I'm going to call this one max ratio. And I'm going to change the name to max. We're going to set the promotion method to max and everything else looks fine. All right. So now we have a max ratio and a min ratio over here in our geometry spreadsheet. So the minimum is 0.7 and the max is 1.3. All right. So at this point, let's drop down an attribute remap node. So say attribute remap there. Plug that in like so. And what we want to do is we want us to basically remap that range to negative one and one. All right. So how do we do this? So we need to put in the name of the attribute that we want to manipulate in here. All right. So the original name, new name. I'm just using the same name because I want to overwrite the previous values. And then in the input min, I'm going to do a detail expression. So I'm just going to say detail. And I want to get the detail attribute off of the incoming geometry. So the first input here, which you would do a 0 in the expression right there. And then the attribute that we want to get. So it's the name of the attribute. We want to get the min ratio for this input min. So I'm going to say min ratio and zero because it's just a single value. With this sort of actor, you do, you know, zero, one or two for the, the each component. All right. So let's just go and copy this whole thing and then hit tab on the keyboard to move down to the max. And then just hit the control V. And that will allow us and how I actually put in ration. Not sure why I did that. Let's go and change, change this to max. All right. So now we've got the minimum. So if you just click on the label here, we have the minimum value and the maximum value at 0.7, 1.3. And we want to remap that to a negative one to one. So now if we were to go to our points over here, and we can look at our bank ratio, in fact, we could actually do it in the scene view here, which is a little bit more fun. Let's turn on our visualizer because remember we set it all up to look at the bank ratio value. So now you can see when we are doing this direction of a turn. So when we're turning this way, we are positive values and when we're turning this way, we have negative values. All right. So now what we can do is finish up the final part of the banking. All right. So now we've got this value right here, that negative one to one value. Let's drop down another wrangle node and finish this up. And it's gonna be really easy. It's nothing crazy here. So let's go and call this banking and let's go and select it. All right. So on a per point basis, let's go and set up before we get into this here. Let's go and set up a couple of things. I'm actually going to make a new visualizer node. And let's do this. So visualize. I want to set up on my curve or not my curve direction. Actually, yeah, on my curve direction. Sorry. Let's go and set all these guys up. So I'm going to set this to a point and we're going to visualize the right vector. It needs to be set to marker and a vector for the style. So there you go. So you can always colorize it. Make it look a little bit more pro. Let's go make a duplicate now. And it's always a good idea to name me. So this is going to be our right and right. Let's go to color is two. This is going to be our up and up. And let's change the attribute to up and the color to green. Make sure we turn on active so we can see it. Very cool. And lastly, we can do the normal direction. You don't really have to, but I'll just call this normal and we'll do a capital N and we'll make it blue. So it matches the colors of the main gizmo down here in the nomen. All right. Very cool. Let's also make that active there and let's change the attribute. And that's because I actually use the, so up here, I use the right direction for the normal. So I should keep the old normal around just so I can, let's do this here. I'm going to say V at old norm is equal to at N. So before we manipulate it to the right direction. So that should survive all the way down here. There it is right there. So I have an old normal and inside of this, let's go and say that at N is now equal to V at old norm. There we go. Cool. So now it's pointing in the direction of the curve. All right. So the next thing we need to do is declare a new matrix three and we're going to call this a rotation and we're going to make it equal to the default rotation, which is literally like if it was rotated, like this little guy down here. So no rotation, the identity. And then finally, we're going to do a rotate function and we're going to rotate that particular matrix by our bank ratio. So we're going to do a bank ratio and we are going to use that flow normalize the axis. So if you just click on the name of the function here and do an f1, you can find out what all the different arguments are for. And a lot of these have multiple overrides as well. So this is basically the one that we're using right here. All right. So we're bringing into the matrix and we're going to rotate it a certain amount on the axis. So in this case, we're rotating it along the direction of the curve. So now what we need to do is we need to multiply our right and up vectors. So they rotate as well using that bank ratio value. So let's do that. We just say V at right times equals rot. So we're just multiplying a vector by a matrix and V at up is equal or multiplied by rot as well. There you go. So now let's go and take a look at this guy here. And I need to make sure I name this correctly. Let's take a look at our vectors. There we go. So now we're banking in the wrong direction. So we need to go and put a negative symbol in front of that. And then we also need to put in a control so we can control the amount. So I do CHF and amount. And then we need to expose that slider. So now we have control over how much banking we have. Pretty cool. So this will then transfer all the way through to your copy to points and to your sweep nodes. So if you set the sweep node to a ribbon, let's make this a little bit wider here. Turn down the columns and turn off all of our component displays and go back to our banking. You can see now it banks the geometry. For us. We'll also do the same thing for a copy to points. So if I drop down a copy to points node and let's do something like a box so we can actually see the orientation. You can see now we are banking those boxes. Pretty cool stuff. All right. So that's how you set up banking on your geometry tools. Thanks so much.