Introduction to Houdini 16: Attributes & Geometry

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys in this video we're gonna dive down a little bit more into what attributes can do in Houdini and how they can help us do some pretty neat nifty things so to start off I'm gonna make Chama tree and we'll just start with a box so say we're making an asset and depending on the size of one of the primitives or say the area or perimeter of a ring we want to perform specific operations on it like say we're building a procedural house or setting windows and phases or doing something like that what we can do is use the measure saw to create attributes about a surfaces geometric data if we go over into primitive here by default or measures opposite to a perimeter type and we can go to override this name it's default names for perimeter is set to area so what we see here is that it's actually creating I'm gonna pin this so that our geometry spreadsheet doesn't update when I switch nodes that as I increase the scale of our box our area attribute updates accordingly and this is pretty useful for determining the area of a specific face we can also do this and use the perimeter to find the perimeter of a face the surface area of a face or the volume of a 3d object or the curvature of a curve in this case we don't have a curve so it can't calculate the curvature of a primitive in this case so go back to area and we're just gonna call this prim area for a primitive area because this is the area of all of our primitives on our surface and we can use the attribute promote saw to convert and or perform operations on this primitive area so we're gonna go and grab from our original classes our primitive and we're going to move this up to a detail so that we can see some information about the our geometry object as a whole so use this drop down area and grab our primitive area attribute and we'll see by default it's deleted our original primitive I can click on delete and our primitive area attribute will still be there now I go over to the details tab I'll see a new prim area attribute and this is the average value so if I go back to here this is the average value added all of these up and divided it by 6 is the average value of the area surface area of each primitive on the are geometric surface and we can change this to see the maximum or the largest face the minimum or the small area the smallest face the modes the one that is the most common as well as the sum and add them all together we're gonna leave this in sum because that will be the surface area so the combined area of all of the primitive areas for our geometric surface and just like we were able to take this primitive area attribute and move it up to a details we can actually do another attribute promote and we can transfer this back down from a detail attribute to a primitive attribute we'll grab our primitive area and we've now deleted it from our details channel and now our primitives each primitive is aware of the entire surface area of the geometric surface and we're gonna go ahead and give this a new name so it doesn't override our previous same with this we're gonna call this surface area up here check there's our surface area a name right there and then we go down in here we're actually gonna grab surface area instead we don't need to give it a new name in that case so we have our primitive area for each primitive and then the accompanying surface area for our entire geometry so we have just go ahead and add a visualizer for our variable here and just gonna call this area and we're gonna make a marker and this will be a primitive attribute and we're gonna be displaying our prim area get null node all right so now we can see the primitive area on each of the surfaces of our primitives so what does this do for us well using this primitive attribute we can actually group based off of the size of the surface area of a primitive so we'll create a group node and then in our base group filter we can actually do at prim area to grab the primitive attribute and base group is not in this input field we can't actually write full expressions in here but we can write small simple expressions and it's important to remember we can't have spaces in here a spacing will break the group structure input structure so well in a normal like attribute wrangle or some other vex inputs we could have spaces and here we cannot so we'll just say if our primitive area is like less than two enter and now it will group all of the primitives whose surface area is less than two and I can go up here and we can add some let's make this a polygon mesh and increase our axis divisions right now everything is less than two but if we go and let's make this to five same thing so what if we and this is really helpful you're like well why couldn't we just select normals pointing to the right or normals pointing to the left because geometry you can get pretty complicated and let's add a mountain saw to demonstrate this so you'll see now that I've added a mountain top with some more noise our primitive sizes are a lot more varied and it's still calculating the area for each primitive and then applying them to the group as we need and now let's go ahead and look at some more things we can do with referencing attributes and group notes so I'll make another group and in here we're gonna grab our primitive attribute again it's a primitive area and here we're gonna say if our primitive area is less than a certain percentage of the total surface area so we want primitives who are relatively small and scale to these entire surface area of the object so to make a expression call and the group parameter input parameter field here we need to actually use the left tick this is the upper left hand bar of your keyboard where the tilde is - this is the key to the left the one on a standard keyboard so do left tick and we'll type detail because we're gonna be grabbing the let's go actually because I want to grab a detail attribute let's in our surface area let's not delete the original so that our entire object is still aware of its surface area now go back to our group node and we're gonna grab a reference to our surface area detail attribute so we're gonna do detail and then this is the path to the node where that detail exists so in this case it could be our null because it still exists there I wanna do null one and then we're going to say we're grabbing a detail attribute from this node and then the name of the detail attribute we're getting so in this case it's going to be surface area and then at the end we need a float value here this is if we were to be grabbing an attribute that had a vector property so like say it had an XY and Z position this is the index or enon value for which X Y or Z we would be getting so if it was zero we'd be getting X 1 we get Y and two we get Z so in this case because there's only one does we just think this is zero and we'll end that and now if we end the tick here it's going to group everything because obviously each primitive area is less than the entire surface area but if we go inside of our tick and do C times zero point one so we're gonna say things that are less than 10% of the total primitive area and it looks like everything still is let's go a little bit smaller and we'll do point zero one so one percent of the size and so now we're only getting go back to our mountain and add some more noise it's only going to be grouping or change the noise values a little bit primitives whose total surface area is less than 1% of the combined surface area of the geometry let's go back over here to our smaller fixed area let's go and give this group a name so it's not just Group one and we're gonna call this small areas our small prims now in our small prims we can create an attribute based off of the group so we can apply an attribute and a value to all the primitives in this group so we'll do another attribute create and now we're gonna create a new attribute and we'll make this primitive attribute now we're gonna say let's just do small Prime's or small Pro and we're gonna make this float that's fine we could do an integer and we're gonna say that it is in this small prim group we're gonna give it that attribute with a value of 1 and by default it will be zero so we're gonna say our small prints group and then if we go back to our primitive details here we'll see in our geometry spreadsheet if we make this bigger all of the geometry that is inside of our small prims group now has an attribute with a value of 1 and if it's larger than our small params then it has a value of 0 and now we could go through and blast and say we're gonna blast away small prints there or we could say instead at small print is equivalent to one see nothing changed but if we do zero here then it will invert and you'll see that we can delete objects away based off of just here like we did with creating our groups based off of our attributes all right so let's take another look at wow we can use attributes to do some things with poly extrudes so we'll go ahead and just subnet this guy and then we'll go over here and make a grid we'll turn on the visibility on our grid all right and I'm gonna go and copy these over and I'm just going to increase this doesn't like 20 so we got some more variation my grid there so so the poly extrude node works very well with attributes we're gonna create the poly extrude and we can increase the distance like normal let's pull this geometry spreadsheet down a little bit and what we're gonna be doing here is we go over to our local control we can modify the local attributes which have default names but aren't actually existing yet so we say distance scale and turn that on and we can create an attribute then we can then control with an expression to help us perform operations on our public street or on the primitives that we are extruding so to help visualize that gonna create an attribute here and this is gonna be I'm gonna call it ramp and this is going to be over primitives and our primitive value here we're going to beat name C let's just do like value from zero to one across the z axis so we can get that normalized value with dollar BB Z and let's put down a officialized note so that we can see what that looks like these are fine attribute as is primitive and we want to see ramp and here we have from red to black across our like a nice gradient across the surface and we can go into our poly extrude and you'll see right now it's probably extruding everything but we can change our distance scale to reference our ramp variable that we've created I'll see right now it's not doing anything and that's because modifying things at the primitive level we or I don't know of a way to poly extrude across a gradient at the primary level so if we instead do individual elements you'll see we've now got the beginnings of something akin to stairs and as we increase this value there we go nice stepped shape and we can have some fun with this and after we create our attribute we can go in and do an attribute randomize and then we can randomize that out attribute so we've got our primitives and just a ramp and now we've got this random thing looks kind of like use this for a city generator or something like that if you wanted or for random patterns and yeah so let's say we wanted to create something like this but we wanted it to be smooth we want a angled ramp rather than stairs so to do that we actually can convert our attribute over to points and we're going to need a group for our front face so I'm just gonna group our front face that'll be these top faces right here and we're gonna convert this group because remember if we go over here our group attribute our groups are an attribute with a value of 0 to 1 we scroll that are here will see the primitives that are part of our group face so we can actually do a group promote and we're going to be promoting this group attribute to a point from primitives to points so we're gonna primitives to points and we're gonna be grabbing our extruded front and we'll see now if we got our points are extruded front group is now a point group and we'll need to convert our ramp attribute from a primitive to a point attribute as well so we'll do attribute promote and grab ramp this will come from a primitive to a point I'll see now our ramp attribute is listed over here in our points and now that we have our point group and our point attribute for our ramp we can create an attribute angle node and write a really simple expression here to set the p/y value or the y position of all the points to reflect our ramp attribute so we can do p at capital p dot y to grab the y position attribute of each of the points and we'll just set this equal to our ramp attribute i'll see now we've got let's go ahead and make this connected components again so we have a nice smooth ramp here and if we wanted to increase this we could do a times ten and that'll make a steeper ramp value because remember the ramp is a value normalized value from zero to one so now and we could do all kinds of fun stuff with this so let's say we wanted it to ramp up until a maximum value that we've defined and then we want it to level off so we could do that just by adding something like a clamp and we'll just clamp our ramp value at the rate that it should increase and I'll say clamp it from zero to three and then we'll see that as our ramp increases it will eventually hit the 3 and level off and we can change this to a lower value will level off slower or a higher value and it'll of loss much faster so let's go ahead and take at another way that we could use attributes and how to create new attributes with the attribute angle so we're gonna subnet this again keep our node network kind of somewhat clean and I'm gonna make another grid so in this grid you just leave it default right here should be fine and we're gonna make a tribunal and in this attribute wrangle we're going to write a simple expression to add a new point to the center of each of the primitives on our grid so to do that we'll just make int I'll just call this new point let's say Center Point let's set this equal to a new point that we create with add point it's the add point function and this is going to reference the relative primitive and then the position that it should perform on or the primitive they should perform on we're going to say zero and at P and then we're going to need to run over primitives and set of points and you'll see that now it's created a new point and the center of each of our primitives on our grid so now that we have that we can go ahead and use some other simple expressions to create a new group and add that group attribute to these newly created points so that we can create the points and then add them to a group all at one go so we're going to create a new string and we're gonna call this group name and we're gonna say our group name is center points and then we're going to use the ad attribute function and the ad attribute function needs four inputs so the first is going to be the geo handle so similar to our ad point it will just be zero it's the geometry that we're working with was will be the first so zero the next input is going to be our attribute type and we're just going to make this a point attribute the options here are going to be we could have written point we could also write prim or vertex so the next input that we can create will be the name of the set attribute so in this case we want that name to be group name and we don't have to put this in quotes because it's already defined as a string here I could have just put quotes enter points and then the fourth and final is going to be the default value of this new attribute that we're creating and so I want to make the default value 0 there we go so we go down and we can see our center points attribute has been added with our default of zero so now we just need to set each point that we create here to have this attribute we can use the set attribute function to set the attribute of our center points attribute to a value of one if it is one of our newly created Center points so again we're going to start this out with the geo handle of zero the attribute class is going to be point the name is once again going to the group name because that's the attribute that we'll be modifying and the element number is going to be the center point value so the that way we were adding setting this value to each of our new center points the next value is the vertex of the primitive we can just leave this as negative one we can basically means to ignore that value then we'll be setting the value that we want it our attribute to set to in this case will be 1 and then we have a bunch of different modes that we can use with set attribute this could be some multiply app and if it's a string and we'll just for now use the set mode we'll fish that out and now if I scroll down in our geometry spreadsheet will see that eventually our center points will have a value of 1 while our non Center points will have a value of 0 so we'll create a visualize node and then change this to a marker I'll do it's already a point attribute so this will just be Center points just null we don't get that double render and there we go we'll see all of our Center points have a value of 1 and all of our let's go ahead and make this a little bigger so it's easier to see our Center Point set value of 1 and the non Center points that get originally came in our grid have a value of 0 so using this attribute we have created a point attribute for each one if we wanted to let's say add this automatically to a group an actual group not just an attribute that we could reference in a group instead of creating a point here we can instead create a point group update that I'll see now when we middle mouse click over hit this we have a point group of center points and there are 81 points in that group and our geometry spreadsheet has updated to have group : Center points so let's say we wanted to do something like if I have a tube and I'll set the height to something around two and will decrease the radius scale a little bit looks about good then we can do something like the copy two points and we'll just grab from our null node over here and instead of copying to all points we'll copy to our source group or a target group of center points five one and notice let's say we want our grid to merge down here but we don't need these extra points that we're copying to so we can just make our merge let's move these to the other side to make this a little bit cleaner and we'll just merge down from our group right there can we see down here and there we go so now that we've looked a little bit into what we can do with creating custom attributes in Houdini let's look at what we can do with some of the built-in point attributes that already exist in Houdini so I'm gonna go and do a demo of a common issue that I face I end up performing operations like this quite often I'm gonna make a circle and primitive is fine let's do the ZX plane let's do polygons alright so let's say I had a shape and I want to duplicate it along all of the points in my circle or along a swiped curve or something like that well if I go ahead and turn on point normals here and if we look this point normal attribute is something that's created by default in Houdini but you'll notice it doesn't appear in our geometry spreadsheet anywhere so if we want to create a new point normal for our circle we can just add a point saw and update this to a normal value and we'll see now that we have a public parameter that we can see in our geometry spreadsheet for our point normal direction so what happens if I were to make say I make another circle and this apisa explain polygons again let's go ahead and reduce these divisions down to something like 3 or so we'll make this an open arc and we'll set these arc angles to something like 180 to 360 so we get this trapezoid type shape so polyfill this and I promise there's a reason for me creating a shape and something like this I just want something where we can see what direction it's facing and all to make a poly extrude and it will just increase the distance on this to make it taller say three all right so now we've got our shape here let's make it a little thinner looks fine if we do a copy two points here and we copy this over here something really not what we want happens to our shape on our circle we'll see that they do get copied to the points but if I made it standing up I want it to duplicate to each of these points and it's a template this the other way I want this shape to duplicate to each of these points standing upright the way that I want on the points and to do that we can use the normal attribute and go ahead and modify this so that we can control the orientation of the objects that we duplicate along to the points so a quick way to do this let's say I wanted all of these to just stand straight up right I can change this vex expression to value and then I'll be able to control the absolute orientation of the point normals for each of these points so let's say I want them to point in this direction so I want them to stay like this in the z+ direction so I can just change my Z normal here and if I turn on point I'll also see all of the points now have a normal facing in that positive Z direction so when I go to our copy points our objects are copied all facing the positive Z Direction just like they were originally and I could do the same with the x value or at a different vector if I wanted and now they would all be facing towards the positive x-direction so what if I wanted these to all like lay out or face a [Music] specific direction like relative to the points position on the circle to do that we can actually not use our value and instead we can just use the position attribute and now each point will have a normal relative to its position along the circumference of the circle and so we go back and look at our copy two points we get them all facing outward at towards the direction of the point normal that we've created and if we wanted them to face end we could just put a negative on our point normal there you can see how we could use stuff like this to get some pretty cool effects or shapes all right so subnet this again I got one more example that I want to go over and just how to modify some curves using point expressions and modifying the attributes in them so we're gonna start out with a line just a really simple curve I'll turn on points so we can see this and we'll make it a little bit longer and we'll actually go ahead and just copy this parameter and paste that over here say two times the points for the length we go alright so there's a couple different things that we could do modifying points and their position attributes on curves so let's go ahead and make an attribute wrangle and we're just gonna start writing a simple expression to offset the points based off of their point number so I'm gonna say if and we'll do at Pt num so the local variable for the point number and we're going to do modular two or percent to equivalent to zero so what this will do is say if the point number divided by two is even or that's what modular two is equal to zero then we'll perform some kind of operation on that point in this case I'm going to say we're gonna move the P Z position so the Z position attribute of the point must move this by like negative 0.25 or something like that we'll see now every other point or all of our even points are moved point to five in the and the negative z-axis and so say I wanted to make this a little bit more extreme I could do else and we could do at Pt Nam modulus 2 equals 1 for all of the odd points and I could just write a else statement and a new line because the only opposite of the only other condition for even is odd but you know I'll do at P dot Z and we'll say one with this and the positive z axis 5.25 what did I break I need else if it's getting ahead of myself all right so now I've got a nice zigzag line and as I increase the number of the length of my line I continue getting this zigzag pattern as it gets longer and we could do a couple more things with this we can actually just go ahead and bypass that make another attribute or angle and on here we're actually going to just use some simple trig functions to get a similar shape so we're going to do at P X for the x position and we'll make this a function of cosine I'll just say at cosine at PT num and now we've got this nice smooth sweeping shape so we could say let's say we're gonna use this to make like chain links and a fence or something like that like a nice chain link fence pattern make a new line and we'll do if now that we have set the x position based off of our cosine will say if that X position so our at px position start this off correctly and we're going to say if it is less than zero so if it's on this side of the axis then we'll do a Z offset to get this again set that equal to the X offset I'm out so we'll get this nice like a chain link fence weaving through itself we could just do else at P dot C equals at or negative at P dot X so we get it going the other way this nice zigzag pattern and then if we wanted to clean this up a little bit after we've done the operations on our curve we can just convert this from a polygon to something a little smoother like a NURBS curve it's a little less sharp and then we can resample our curve viewpoint see it's pretty dense but that's okay we're gonna go and resample by polygon edge so it doesn't because we get some less deformations in there and then we can drop down a refine so that we don't get like all of these points in here we probably only need a little bit of them around these bends as a go straighter we need less points so we'll just do our first you in second you so from the beginning and end of the curve and it will unrefined increase this value so that we get even less dents on our curve that's a little better and now we can just add a copy note and we'll start making some copies and they're gonna be across the x-axis here and we're gonna want to probably scale them in the negative x-direction each time we make a copy and we'll get this nice alternating fence pattern here and this will just keep going as we make more copies and again we could just increase the height of our fence line here and to add some polygons too we can just use the poly wire function and now it's got some nice geometry and this isn't perfect we probably could have thought out the math for how these lines were going to overlap with each other a little bit more but and you get the idea and there we go so that's just a couple ways to use attributes with modifying some geometry in Houdini
Info
Channel: Going Procedural
Views: 6,110
Rating: undefined out of 5
Keywords: Houdini, Procedural
Id: KnZ0glIG_qA
Channel Id: undefined
Length: 41min 55sec (2515 seconds)
Published: Wed Oct 18 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.