 Howdy guys, IndiePixel here with another awesome little quick tip here. So what I wanted to show in this video is how to distribute something like rocks over a mound. So I'm basically taking the mound technique that I showed earlier in one of the intro to vex videos. I think it was like part three or four, I forget. But anyways, and I wanted to be able to distribute rocks in a natural way over that particular mound. And I'm definitely, obviously, you guys might be figuring out I'm working on turning tools and stuff like that right now. So what I want to do, I extracted out just the slip distribution technique that I've been messing around with. And basically what it does is it allows you to spread rocks or whatever over a particular piece of geometry. And it's actually quite simple once you figure it out. So I wanted to share the particular technique. Okay, there's lots of things you can do with this. I'm just showing you the basics of it. Maybe when I do actually finish my full tool that I have been working on, I will make a quick video about all the different features that I'm implementing in it. But for now, let's just go over the basics. So let's rebuild just the slope distribution here. So I'm going to drop down a circle over here. So I'm already inside of a geo network, so I'm just going to work inside this guy. All right, and I just made that into a digital asset. So I'm going to keep that over there. So the circle basically is just going to act as our plot of land to start with. So I'm going to make a polygon. I'm going to set it to the zx like so. And I want some normals. So I'm going to drop down a point. There we go. And I'm going to set this to normal and then just do atp to get normals that are radiating out from the center. Okay, and the reason why I'm doing that is because I want to augment the shape of this using a mountain node. It's just a really quick and dirty way. I found to just generate some random shapes for these little dirt mounds. So you can go and do it everyone with this. That'll work for us. I'm not going to get too picky with this right now, but I do actually want to try to get some of these concave areas right here. So you can see like rocks kind of moving down and into the little valleys. Okay, so from there, I'm going to remesh it. So we're going to do the border color. And I'm just going to do a simple version of the border color. I'm not going to do the full PC open stuff here. All right, so then we're just going to do a group. Not a grid. So it's a group. We'll call this border. And I'm going to set this to points. And we'll do unshared edges like so. And I'm going to just do a color. And border and we'll make that border black. And hopefully this will get me enough because I mean the reason why I was doing the PC open thing was so that when I blur it, I get a thicker line. This seems to be working all right. So we'll just do that just like so. All right, so that does the trick. So let's drop down a wrangle node or an attribute wrangle node. Okay, and the first thing I want to do is I'm going to actually set the border to black. Now this is something I haven't shown you and I am working on another two videos for Intro to Vex. One on BB box. I'm going to show a little bit of the BB box in here too, but also on grouping. So what I'm going to do is I'm going to say if in point group. Okay, and we're going to check the geometry or the self, right? So the input zero and I'm looking for border and we're going to check the current point number. So PT num like so. And so if it is in that group, you can see right here, there's this group right here. So if it is in this group, this current point number, if it is one, it's going to return one. If it's not, it's going to return zero or true or false, right? So that means I could check this. So I can say, well, if it is, then we're just going to set the point at rib to black. So we're going to do the CD and we're going to do just all black like so. And then I want the PT num and set like that. Perfect. And I got one thing wrong here. What is it saying? Oh, I got these guys mixed up. Sorry about that. So at PT num and then the value. So zero, zero, zero. There you go. That just ensures that the border is in fact full zero. All right. So then I just want to make the mound. So what we're going to do is go and. Just put some height in here. So we're going to say at P dot Y plus equals CHF height times the color. So at CD dot R be good if I used the proper math there. All right. So now we have a nice little mount. Perfect. Okay. So with that, now I need to actually create the normals. All right. So we just need to drop down a normal node and it looks like I have to reverse the circle. What's so weird that Houdini does that when you make a ZX plane? It's like automatically reversed. It's super weird. Anyways, if anybody knows, please let me know if that is me or if that's Houdini. All right. So let's go and take care of a few things here. So the first thing that I want to do, I want to create some normals that actually define the slope of this particular mountain. So to do that, I'm going to drop down another attribute wrangle node right here. And this is going to be slope normals. All right. So we're just going to walk through and create our slope normal. So the first thing that we want to do is we want to get the normal. And I'm going to store this in a variable called, I'm not going to create an attribute. I'm just going to create a regular variable. I'm going to store this in a vector called flat normal, because I need to flatten it out. And you'll see why when we start doing some of the vector math here. So that's initially going to be equal to the current normal. Okay. And then I'm just going to flatten it out. So we're going to say flat normal dot y is equal to zero. All right. So now if we take a look at that, so let me just say add n equals flat normal, like so. So now they're all nice and flat. Perfect. Okay. So now what I want to do is I want to get the cross product of the y up. So the world y. And so let's do that. So I'm going to say vector cross is equal to. The cross of the flat normal and world up. And unity would be vector three dot up. Be sweet if they actually had those in vex. Or I could just say vector three dot up instead of writing that course. I guess that's less. It doesn't matter. Anyways, so let's check that. Now we'll do cross. There we go. So now we get all the normal spinning around our shape. They're following the contour. So now we have those two normal. So we have flat normal and the cross product of that. What we can do is we can take the original normal and this cross product and we'll get our slope normal. So let's do another vector here. So we'll say vector and call this slope. And we'll do the cross product again. And this time we're going to take the original normal and the cross product. All right. And we'll put that into the slope. And there we go. So now you can see all the normals are actually pointing down the mounds surface appropriately. They're actually following the slope. This is good for things like an erosion effect. If you're going to do some sort of like erosion solver, even though Houdini has all the erosion solvers in them now. With all the new height field stuff, which is really cool. I really love playing with that stuff. But if you want to do your own, I do often find that the erosion tools are a little too global. So when you're working on game levels, a lot of times I want to have just some really local control. So sometimes you do have to come up with your own solutions. Houdini is great at that. Giving you the power to make your own solutions. All right. So now with that, what I want to do, I don't need to actually put this into the normal. I'm just using that right now for display purposes. So I can verify that the math is correct. Oh, and before we go any further, I do need to normalize this. So we're going to do a normalize. You can see that some of these guys up here are really tiny at the top here. So let's normalize it. There we go. Now we are insured that they're all the same length. All right. I'm actually just going to store this into the color. And honestly, you don't really have to store it. You can store it anywhere you want, really. I'm just putting it in the color because I'm going to do an attribute transfer here pretty soon. All right. So with that, we are good to go. So I'm going to actually drop down another wrangle note. And for this, I'm going to define an area of density where I want to scatter some points. All right. And these points are going to be the points that we distribute along the surface. Okay. So this is going to be our density area. All right. So what I want to do is I first want to get the height of this particular amount. And I don't want to constantly have to go and readjust these values. If I go and change the height of my mount. So what I'm going to do is I'm going to get the size. So in order to get the size, I'm going to do a get BB box size right here. And I'm just going to pass in the geometry. And that basically will return the X, Y, and Z sizes of this. Literally the exact same thing as using BB box expressions inside of Houdini inside of your parameters. So now what I can do is I can go and actually assign the color here. So if I assign the color, what I'm going to do is I'm going to take the atp.y divided by the size.y. And that'll give us a ramp, a gradient for that right there. And what I want to do is I actually want to fit it. So I'm going to do a fit of one. And we're going to take that input there. I'm going to go from zero to one. And we're going to remap it to something like actually let's do some inputs. So I'm going to do a CHF and we're going to call this our min. And then we'll do a CHF and we'll call that our max. All right. So we'll do that, expose the parameters there. And it is not liking one of these guys here. So atp.y divided by size.y there. And oh, it's because I'm just doing this straight up. There we go. Okay. So now I'm just going to put this back up to one like so. And what I can do now is just reduce the minimum down there to a value like that. So now I get just the density at the top here. Like so. Okay. Because I just want to have the particle start at the top and then they're just going to fall down the mountain. Or down the little mound. Okay. So let's go and scatter some points now. So we'll scatter some points. And I'm going to add the density attribute there. And I do need to instead of, let's actually just say at density is equal to atcd.r. There we go. So now we get all the points just at the top there. And obviously I only need about like 20 points for this. So that'll be fine. You can get rid of all the randomized point orders or all this stuff up here. If you want doesn't really need to be all spread out evenly but that looks pretty good. All right. So now all we need to do really is do a for loop. And for this I'm going to get the for loop with feedback. All right. So for every iteration this time I'm just going to make it so that it iterates. And every single time we iterate through one of these iterations all these points are going to move down a certain amount. Pretty easy. Okay. So let's move this off to the side here. Because here we have our normals that we want to move. So we constantly want to sample at every iteration. We want to sample one of the normals off of this particular mesh here. So I'm going to do an attribute transfer like so. So I want to transfer the normal color to the point. And you can totally transfer the normals as well. This is just how I did it in this particular example. So now I'm getting the normals assigned or the color assigned. And if I were to drop a wrangle node down. So this will be our move. All right. So I drop this down. Let's just wire it up because there's no reason to leave it like that right now. All right. So inside of the attribute transfer I just want to do color. Sorry. It's not. I was in vex land there. All right. So if I say at n is equal to at CD. And that will put the normal on it. So there we go. So now we're transferring the normal to the points. And we have a vector to move along. So all I need to do is say at p plus equals at n times some move value. So how much do we want to move every iteration? So I'm just going to call this move amount. Okay. And we'll expose that. And it's got to be fairly small. I found that something like point two five works pretty well. Just to start out with. So now if we go and take a look at the end of our repeat here. Let's select this guy and we increase the iterations. Let me actually template the. There we go. You can see for every iteration. We are moving down the slope. And you can see these guys right here. They're starting to go into this little valley. Always like that. So one other thing that I did. Here. It's just kind of randomized. And you can actually go in. And if you have actual geometry and you randomize the sizes of let's say a whole bunch of rocks. You could actually get the, you know, the volume of those rocks and determine a weight. But what I did in this case, I just created a random value. So I just said a random weight value. And I did a fit. A one between the Rand at PT num. And we I did something like point five and 1.2. I think it was. All right. And. Oh, whoops. That was weird. There we go. All right. So now I'm getting a random weight value. So again, you could just go and multiply or move them out by its weight. Like so. So now it just makes it feel a little bit more natural, right? So the more iterations that we have now, you can get these guys to move. The other thing you could do too is like constantly fire down and intersect. And if the intersection misses, don't move it anymore. Right. So you don't get these guys falling off. So you just use the intersect method. But I just wanted to show that part, right? That's how you get those guys to move down there like that. So just to visualize it, I'm just going to make a box. And I'm going to do a subdivide like so. And let's do a mountain just to create a faux rock. Something really simple. I'm just going to make it smaller. I'm not going to get into p scale or anything like that with this or randomizing the size of them. Because I really just wanted to show the random distribution or the slope distribution. Excuse me. So we'll copy the points. There we go. And we'll just scale these guys down and turn off those normals there. And let's do color. Let's just make these white again or some rockish type color. And let's give them proper normals so you can see them. Very cool. All right. And then let's just merge in the original mound over here. So let's get this guy. All right. So let's put this over here so I can see the lines. And there you go. Let's give this some color. Perfect. So now if we go into our iterations we can see the rocks moving down the slope. And we can go and change the, let's go into this mountain node. Go into there like that. And you can see that this works pretty well. Let's do something. Let's add some more divisions here. Now I'm just messing around. All right. Let's go back in here to see how the motion looks. I'm sure you could do this in a solver as well. Some sort of soft solver or something like that. But I just wanted to show how you could do this. It's a great little technique. Without having to get too advanced into the solvers and making your own, you could easily just achieve this using this particular network and distribute rocks in a natural way for your game levels. All right. That is what I wanted to show. Thanks so much.