Houdini Guest Tutorial: Dart Throwing

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] hi everyone my name is Andreas and today we're going to be creating a authoring algorithm within Houdini this should be fairly simple as Houdini does provide us with most of the notes that we need but we're going to be using a little bit of X and a few Ops to dial in our system so let's get started so essentially what we will be doing is we're going to be scattering a bunch of points and we're going to have to do that in a way so that they are not intersecting and then we're going to intersect those points with the new set of points so the first step is to make sure that they are not intersecting with each other but they have the biggest size possible basically so we're going to be Computing the closest point and then take that distance to that point and cut it in half so that way we know how big the radius can be so that it's not intersecting with any other points so now we have a set of points that is not intersecting and the next step is to just scatter a new set of points with the same rules and then intersect that with the previous previous iteration and all the ones that are not intersecting with any of the previous iterations points we put into uh the same group and then we Loop over that and that's how we populate the surface let's start by putting down a grid and make that a bit smaller and add a scatter note to scatter some points maybe 11 and add a copy to points and a sphere to visualize the radi of our points let's set the radius to be one and the next step is to make sure that these points don't intersect with themselves before we start adding additional iterations of points on top of them so let's start by putting down a point triangle oops and in here we're going to be using Point clouds to essentially find our closest point point clouds kind of work like arrays so they store an ordered list of points based on their distance and then you can retrieve those indexes or distances to manipulate your data so the first thing that we need is a handle which basically returns that point Cloud on a pair Point basis and then we need PC open to create the point cloud and this has a few different parameters so first our geometry stream which is zero then our position attribute which is p then the position at which to retrieve set attributes which is also our position then the radius in which we want to look for points I'm just going to type a high number here but you could proceduralized this with some bounding box of some sorts but we're just going to type a high number for Simplicity sake so the next step is to retrieve the distance from this those points so so let's add a float called distance or dist and in here we want to use a handy function called PC import by index F which stands for float and I stands for integer and so on so these are our data types um this needs our handle which we created two lines above and then it needs a a specific Channel which is called Point distance which is an attribute that exists within Point clouds and then it needs the index from which to retrieve that point distance which is one because the first point is ourselves so now all that's left to do is scale our P Scale based on the half distance to that point so we take our this and multiply that by 0.5 so now as you can see those spheres are not intersecting with each other and as we add more points they shrink in size but they keep their scaling based on their closest neighbor all right so the next step is to put down a for loop with feedback and we do need a meta import node to import our iteration and num iterations and we also need a duplicate of the repeat again and within this loop everything that we're doing is going to happen within this Loop so first we want to scatter Points each iteration so when we connect the grid and we want to scatter points you can see that it's it's not working so on the first iteration we get our points and then on the second one we lose them because we are feedbacking the points so on the next on the first iteration the grids the inputs so it works and then on the second iteration the points are the input here so that's why they disappear so that's why we need this one to set to fetch input so that we can scatter points and it fetches the input instead of the feedback every iteration so when we connect this here and we start increasing nothing will change because we just fetch the input we scatter points and we and we output them here at the end so once I start doing this you can see that we get more points but we do also get the grid which is not what we want so that's why we put down a switch and we switch between this state and this one based on the iteration number so we go and we create a spare input and we use our metadata here and now we can in here write an expression which is a detail expression detail then minus one because we're using the spare input then we need our iteration attribute from the metadata which is iteration and then the index but of which to retrieve that attribute which in this case is zero but if you were to have a vector attribute and you would like to retrieve the y or the Z component you would need to use one or two but since iteration is an integer there's no different channels or different components to that attribute that's why we need Z and if that is zero then we want to switch so now you can see we have multiple points being scattered so now we need to set up a group for our new points which we call pts so let's grab a group and attach that here and also change the input here and then here we're just going to group all the points so those are our input points [Music] input and we call the group pts four points and then on the feedback we want to remove that group so we need a group delete and we delete the group perfect we can also grab our triangle from over here and put it in between here and the group so now we on each iteration we get our grid we scatter points we scale the points so that the radi don't intersect we put them in a group and then we merge them with the old points and the old points are also not intersected and now the only thing that's left to do is vary the scale of these points or the number because as we saw the scale automatically varies if we change the number of points so if we look at this if we add more points they become smaller and smaller and if we add less they they're they're quite big so that's exactly what we will use to change the size of our points all right so let's tackle that part let's put down a primitive FP sorry a detail W and we're going to call this scale and in the second input put the meta begin data let's create a bit of space here call this uh radi and in here what we're going to do is we're going to import are two detail attributes so they're coming from the second input and one of them is called iteration which gives us the current iteration and the other one's called num iterations and they're both integer so then we use a fit range and we want to fit our iteration between the maximum amount of iterations and zero so basically we get a 0 to one value out here so we can use that to use to drive a ramp which we will set to spline and we will also create a random seed basically for each iteration so let's bind that out sorry bind export connect that up and call it seed and then we need a fit so now to reiterate on this we get our iteration and our num iterations and we scale this value between zero and one so here we get a ramp up here to fine tune and dial in the size throughout the scle in iterations so now we can use another fit to fit between the minimum and maximum points that we want to scatter so let's promote these two parameters call them Max sorry Min scatter and Max scatter and then cast it into an integer and also bind it out and this room we're going to call SC for scatter so now we have those two detail attributes here so now we need to link our scatter node which doesn't exist yet to these two values so let's create another spare input and put the scale here so now we want to drive our for total count with the SC attribute that we created so detail minus one then our attribute is SC and then zero and also our Global seat with our seat perfect we don't need the relax iterations can turn those off can also turn off the max Point limit perfect so now we need to dial in some values here I found I'm going to copy these from my other file for the ones that I found that worked the best so set these to be Beast blind and then add one at around here which is still zero then add one at around 7 which is going to be 0 02 and then one at Point 77 somewhere and put these up here something similar to this and then for the minimum scatter I put 11 and for the maximum I put 100,000 so now all that's left to do do is intersect the previous group with the new points so let's put down another Point triangle not this one so in here first we're going to have to check whether our point is within that new Point group The pts group that we created here so if in point group zero for geometry stream then the name of our group which is pts and then the point number which is ptn if that is equal to one so it's true so our point is within that group then we start to execute our intersection analysis so so let's start by creating an array which we call pts for points and we're going to use another handy Point Cloud function which is called PC find radius and what this does is for each point it'll look for the the point radius of the currently processed Point against the radi attribute of other points so it basically knows if two radi are intersecting each other and then it Returns the point as found and puts it into that array so this has a few different attributes first one is always is the geometry stream then our position attribute which is p then our P scale attribute our radius attribute which is p scale then it needs a scaling factor for this radius attribute which we're going to leave at default we don't want to scale it in any way then it needs the position at which to retrieve these attributes which is p then it needs our pscale attribute and then it needs the amount of points to look for and we're going to use two because it'll find ourselves first as well like before so now we remove the first index which is ourselves so pts which is our array and zero so now we have an array with one or zero elements in it and if it has one element that means it's intersecting with another point and that means we should remove it so we need another if statement if the length of our points array is one so if it did find another Point except itself then we want to remove our Point perfect so now don't forget to switch on pack an inst instance for this one so this can get quite heavy we start to connect this here you can see if we run two iterations it's uh quite coarse cuz we're only sampling our ramp here basically twice so one time here and one time here so as we increase these iterations you can start to see we're getting a lot more points in between so when we have we have seven or 10 maybe you can see that we'll probably have you know 10 divisions so we're scattering 11 points once then 11 again and then we sort of start to gradually reach the denser amount of points which is 100,000 so I found that something between 100 and a th000 iterations Works quite nicely and gives quite nice results so these usually process quite quickly as well and as you can see now we do have a set of very nicely packed points on this grid and we can switch out this for any other geometry and it should work I hope you found this useful and you learned a thing or two and I hope to see you guys in the next one thanks for watching
Info
Channel: Entagma
Views: 15,075
Rating: undefined out of 5
Keywords:
Id: X0UsxcqOy5c
Channel Id: undefined
Length: 18min 51sec (1131 seconds)
Published: Mon Oct 02 2023
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.