Transcript for:
Modern Group Management in Houdini 20

hello everyone so Houdini used to have something called as the partition node like if you have any of my older trainings you'll see that I use it a fair bit but they removed it in I believe Houdini 19 I don't exactly remember when but I never made a tutorial on sort of uh if you're using if you were using the partition node then you know what is it replaced by so this is a small tutorial on showing you you know the stuff that you used to do with the partition node how can you do that now with Houdini 20 so Mo basically what was the partition node so it could generate groups uh based on attribute okay so um there are like a lot of different things that you could do with it one of the primary or one of the main usages that I used to do was uh converting Point numbers or primitive numbers into groups and then you know doing stuff with that through like a for or whatever so uh we'll just take a look at a few different examples of what uh was earlier being done with the partition node and then how do you do it now so one of the simplest things is let's say if you've done like if you have a bunch of objects and you want uh each connected object in in its own group so the simplest way to do it now is uh you can take a connectivity node so this was required even even previously but what we could do is we could just take a partition node out after that and convert these into groups so uh what the partition what the connectivity node does is based on connectivity generates an attribute called class and the attribute type is integer so if I just look at class you'll see like you know it put each one into its own group and if you look at the geometry spreadsheet at Point level then we should be able to see see there you go so you have like zero 4 and then you have 1 2 3 4 sort of like that now so you can do that for points or you can do it for Primitives like either way is is fine like so if I go to go to Primitives now you have a group now you have a attribute called class now uh the main change that happened in the previous few versions is that uh the name attribute started to get used more and more and what uh Houdini has done now is that you can you don't need to generate groups if you have a name attribute the name attribute itself becomes a group so just to show you what's happened now is if I change the attribute type from integer to string I'll I can keep this to class but I'll just call it name okay and there you go see so each one is now like this is piece four this is piece three piece two piece one sort of like that okay and uh so you can call it whatever like it doesn't need to be called piece if you don't if you don't do anything it'll just be 1 2 3 4 okay so but now what you can do is let's say if I uh don't visualize this and if I just come in here here and I was to apply uh I want to apply like a transform or anything like you can apply a poly exclude also so if I just apply a transform and if I come in here then you can see like all of those things automatically become groups so you don't have to do anything you know like don't click on name click on any one of these and then if I press enter see so I can you know sort of move this or if I change this to piece two see so now that is being moved so each One automatically becomes a group or not a group but the name is treated as a group so that is the nice thing about it now uh if you want to convert these into groups for some reason you have a very simple node called uh group from name and uh it doesn't have to specifically be name it can be any uh any string attribute okay so if I change this from name to class and then if I come in here see so this will this will still remain so now it's just called class uh so I I can just take this you know so this is fine and what I can do here is it's looking what is the name attribute the name attribute is class and so what happens now is if I look at this here so it's generated those into groups so you can use this but as I said like you don't need to because it will just automatically convert the string attribute it automatically treat the string attribute as a group okay another uh thing that we can do is uh this requires a little bit of code but let's say if you have like a grid and I I've added like an integer attribute to this so I'll just sort of remove this okay and uh the attribute is called variant so it just generated like you know some integers integer values for each primitive based on a noise map okay so if I just let me just adjust the size of the noise map so there you go okay so we have like uh a noise pattern on which the integer values have been distributed okay so let's say if I want to convert this into uh name attribute okay so instead of you know doing groups we just do name attributes now so the simplest thing to do is uh you need a Wrangle for this okay just take an attribute Wrangle and like it's V is for Vector F is for float so for string we need s so I'll do s at name is equal to and this is this is on primitive so we'll set it to Primitives and uh the function is called I2 a okay so that's the function that we use and it just needs the name of the integer see so it says string I2 o a integer number so we say at variant because which was that was the attribute that we had so it has to be an integer attribute okay and then we do click and now if you click on name you'll see like see there you go so you have all of these as you know it's made names for each one of them all right so now that we have converted this into a name attribute uh if you go to a poly extrude you you will see that you know you can pick this up as a as a group C so it's 0 1 2 3 4 so let's say if I pick up two and if I just extrude this C so there you go okay but let's say if you want to give it uh if you want to give it like a proper name because it just 1 2 3 4 so what I can do is I can take a name node and in the name node there is an option for uh we can clear this there's an option for renaming okay so if I just let's say if I type in piece over here here then you know and I just type in Star then see it's renamed everything to piece but what I can do is I can say pie star so this will become like a prefix see so now you have like piece 1 2 3 4 and you can also put it through a for each so if I if I put this into a for each I'll do for each named primitive and if I plug this in then I should get you know see so each one is separate let's say if I just do a poly extrude on the this and I'll do a small inser okay so I'll just do this and I'll turn off uh side okay so if we just yeah so if I come in here see there you go okay so each one of these becomes like its own Island and if I come in here and I can sort of offset this yes if you want you could create like some kind of fancy tiling with this you know like let's say if I take this and I make it you know slightly smaller and then what I can do is I can take a divide node and I'm going to remove all the internal edges let me turn off the name yeah so I can just take this and turn off convex and turn on remove shared edges and then I also want to get rid of all the middle points so we'll take a facet node and I can just take uh we can say remove inline points there you go and then I can take a poly bevel and I can just uh come into points and give it bevel so if you come in here see there you go okay so we can do this if you also want we can do something a little more fancy like I'll just remove this we'll do it after this uh because this doesn't matter but what I can do is I can take a float I can take an attribute it just float and we can add a p scale value to this uh set it to random and in the poly bevel I can use scale by attribute and use P scale so what you can do is we can actually you know like increase or decrease these values see so this is a little more science fictioning in that sense see there you go so you can get some pretty decent results with this or maybe instead of a random value let's try to pick up like a noise value yeah so you can create you know like you can do any number of things with this but there you go so this is how you know one of the other things that you can do with this so if I come in here and I offset this so you can get like you know different results okay so this is one thing uh the other thing that I also used to use with uh partition is uh sometimes when you import like obj or you know some particular format and it has uh material materials assigned to it and you want to convert those materials into groups uh so that becomes a lot easier now because you just have like the name attribute so what you can do so what I've done here is I just have like a sphere with like three materials assigned to it okay and uh this is this is using something called shop material path so if I want to convert these into groups I can just take a group from name and you know plug this down here and here we just type in shop material bath okay so get rid of name and what will happen is if you check this you'll see like you have material blue material green material red which is which are the names of the materials that I had but you don't again you don't need to do this because I can just take uh poly extrude or whatever you want and you can directly pick up one of the materials and just extrude it so if I can just take this see so now I can you know directly extrude it without making groups and also if you want to take a for each and we can do for each named primitive and the only change you make is down here in the piece attribute you call it shopcore material path and so what will happen is so when I come in see it automatically treats each material group as its own section so life becomes you know automatically easier okay final thing is uh if you want to convert points into groups okay because that was something that I used to do a lot okay so uh you get a new node or actually it's probably not new it's it might have been around for a while I just never looked at it but there's a node called enumerate okay so let's say if I just take a simple line and let's say I want to create like wires between them okay so what I want to do is I just want to give it some points and let's say like the top three points I want to connect them okay so what I'll do is I'm just going to take an enumerate and this is pretty cool because if you just click enumerate and uh you can say group type is primitive or points so in this case we want points and it generates an index attribute which if you visualize you'll see like you know it's actually doing this but uh let me just uh split this Paine top bottom sorry left and right and we'll look at the geometry spreadsheet see so you have you know an index uh attribute uh and it's just storing every Point number number so we don't want this a name is always better so we can just change this from integer to string and instead of index I'll just call it name and so now if you look at it uh and visualize it see so it's piece 1 2 3 4 all right but in this case let's keep it to integer okay so let's keep it to this and I'll call it index okay so uh what I can do now is I want to create a group so let's take a group by range I want select the top three points so I can just take this and I can do 1 2 3 set this to points yeah and do invert range yeah let's not visualize that okay and I'll call it top and now take a copy and transform and we'll just create like you know a few of these so let's just take like yeah I think that should be good and now I can take a blast and I can get rid of top or actually no we want to keep the top and now I can just connect this this is pretty simple I can just take an add node because each one of these will have the same value you know like if we look at this uh let's say if I for now I'll just change this to a name uh or let's just call this name for a second okay it just visualizes it better so if I Ki click see these are all 13 this is all 12 this is all 11 so it'll be easier to just like it knows that it can connect each one that has the same value it's automatically going to connect them I'll just call this index again it'll cause confusion if it's you know if it's named wrongly okay so just I'll do delete geometry but keep points then come into polygon by group and set this to by attribute and type in index and there you go okay now the last thing I want to do is I wanted to sort of like droop in the middle like if you look at this I just wanted to sort of like you know curve down in the middle so I can take a I can take a for each in this case so I can take a for each primitive so I wanted to do it for each one but what we want is we want to do it for like each section so I want to break them up okay so take a convert line so I'm just turn this turning this into a small exercise but what the convert line will do is it will make you know like each section between two points into its own individual line and I can plug plug this in and if you come in here see so it's just visualizing one so take a refine and I'm going to set this to 0.5 so we have like you know one point in the middle then take a then we need to readjust the numbers because it'll be like 0 1 and then this will become two so take a salort node and I'm going to say sort by sort by vertex order there you go so now it's 012 okay so now take a group by range again and this will okay this will I'll call this mid points and we'll keep start and end to one and there you go it will select the you know the middle one and I can take a transform I'll type in mid over here and I can just pull it down set this to points yeah there you go and then do a resample and we will set this to subdivision curves okay and so if we look at this there you go see so each one does that and I can like merge this with the original yeah there you go okay now as a final thing let's say if I want like each one of these to have like you know separate values for you know like how it's drooping so we can do like a a little bit of randomization in here so what you want to do is come in select the for each and click here which says create meta import node and it will create a new one and we'll call it meta and now what we want is like each value inside this is an iteration so we can use that iteration value and randomize it like you do random dollar PT or random at PT num we're going to randomize the iteration except we need to type in a lot more so what we want to do is come into this transform and we're going to use something called As a detail function okay okay so take uh detail and if you don't know what to type you can come into the meta and it'll show you so we need iteration so come to transform and then the you need like three things so you need the name of the node and then the name of the value and the attribute index so which in our case is going to be like zero so type in like colon like inverted commas do do slash it's called meta 1 and then uh this is called iteration and then this is zero okay now we need to randomize this so I'll just put a r andd front and back and if you look at this See it'll go upwards we need it negative so I can just type in a minus over here and it'll do that if you want to control it a bit I can use a fit range so we'll do a fit 01 and uh yeah just come in here and we need to have like a minimum Ma Maxum we'll do like - 01 comma - 0.3 and there you go okay so we can do this or let's try 0.05 and if we add a value here this will become like a seed value see so you can sort of you know like modify this and that's pretty much it so if I make it smoother and if I add more points it'll automatically give me you you know as many as I want so these are all the different things that uh I used to do with the partition node but now you can do them primarily with the like if you want to have Point numbers in groups then you use the enumerate so the enumerate is very important or very useful because you can also do like Primitives you can put each primitive into its own group each point into its own group so the enumerator is very useful and uh whatever was being done with groups now you can just if you can convert it into name attribute it just does the same thing because each string attribute is treated as its own group so that makes life you know a lot easier okay that's pretty much it