 Howdy guys, IndiePixel here. And in this Intro to Vex lecture or video, what we're going to do is we're going to start to take it a step further. Now we take a look at how to create basic noises. So we're starting to get a little bit more into 3D shapes with Vex and stuff like that, instead of just processing lines and just dealing with searching for points and stuff like that. So what I wanted to do in this particular video is talk about how to create this pyramid shape here. Alright, because right off the bat it's not quite clear how you would go about doing something like this with Vex completely. Now you can completely do this using a set of nodes and you could create a pyramid shape quite quickly. And I'll show you that after we do the Vex version because it's important to start to understand how you can start working with the shape and stuff like that of just a simple grid and how we can turn it into a pyramid really quickly. Because what it does is it teaches us how to start utilizing blend modes, how to start to modify our bounding box sizes and stuff like that. So what I wanted to do is I wanted to go through the process of setting up the math to produce a pyramid. Alright, fun little exercise. So let's drop down a geometry node here and I'm just going to call this pyramid video like so. Alright, and I'm going to jump inside and what I want to do is hide the current pyramid that we have. I don't want to see it or anything like that. I'm also going to get rid of the shelf and all this timeline. So a little more space for the video, less distracting, and stuff like that. So I'm going to drop down a grid over here and what we're going to do with this grid is we're going to get a few of these parameters all set up. So the first thing I really want to do is just copy this parameter the size X and set it to the size Y or size Z in this case and then just copy these rows and columns so I can just move one slider. It'll just really make it a lot easier on us while we're working. So I actually want to give this quite a few divisions basically in the rows and columns or the X and Z directions here and the next thing that I want to do is drop down that attribute wrangle. Again, you can go and drop down a point wrangle for this if you want. Same exact thing. You can see that the attribute wrangle starts with points and the point wrangle has the same exact settings. So just to show you guys that the nodes really for the wrangles have just been set up as like presets basically. So if you just look up wrangle you can see that they're just setting you presets for these things. So let's go into this wrangle and we're just going to call this the pyramid shape right here. So pyramid shape like so and the first thing I want to do is get the size of this grid just the size and you'll see why here pretty soon. So we've seen this before but what we're going to do is we're going to call this the grid size and we're going to use that get bbbox size and feed in the zero index because that's the index that we're feeding the geometry into. And so from there what I want to do is I want to start to compare the X and Z directions to that size. So to do that and what I'm going to do is pump this into these colors just so that way we can visualize it. Now you don't have to you can always put this into a local variable so it can be like you know X gradient is equal to what we're about to type in but in this case I want to be able to visualize it for you guys but I also do this quite a bit in my day to day work just so I can see it while I'm working and then once I'm happy with the results I'll move it all into local variable or attributes and then view it through the geometry spreadsheet all right because we don't want to mess with the the vertex colors too much until you know we really want to pack that into it. Okay so let's first start out by just comparing the the let's look on the X direction here so we're going to compare the current X position so we're just going to take the position of every point okay so for every single one of these little dots here single one of those points we're going to look at that X position and compare it to the size all right and that will give us a particular gradient value so what I can do is I can say at p.x divided by the size so this grid size variable that we created .x like so so we can take a look at just that and we also need to make sure that we actually zero out our color because it's set to white or one by default okay so now what we're getting is a gradient so it's a positive gradient gradient from zero to one in the positive X direction and we're getting a zero to negative one so if you look at all these cdr values or the r channel of the color for this we're getting negative values basically and it's actually going to negative .05 not negative one okay so it's very important to understand that so what we want to do now is we want to create a different type of gradient okay so in order to get all of these into positive values we need to use that absolute function so I'm going to type out abs so it's the absolute value so even if the X position or the X component of the current position of the point is negative it'll still pump out a positive value and so what that does is it gives us a gradient now that goes from .5 to 0 to .5 all right so we're getting this kind of bell curve if you will cool so in order to get this to go from one to one in this case because it'll be a it'll go from one to zero to one right because currently remember we're going from 0.5 to 0.5 we just need to multiply this by two the grid size and there we go so now we're going from one all the way down to one I'm looking for the zero it's around here somewhere anyways so we're yeah we're going from one to zero to one okay cool so what I really want to do in this case is I want to flip this in this case for the pyramid itself so all I need to do is just do a one minus for all this and now we get a gradient that goes from zero to one to zero all right so if we were to actually pump that into the Y position currently so we'll say plus equals at cd.r like so we'll get this roof shape and it's a perfect gradient all right let's do something like times two and this is why this is very important especially when you start working with the Houdini engine because when you start working with the Houdini engine while it's super awesome and I love working with the Houdini engine the more that you can put into wrangle nodes the faster your tools are going to work you know currently we just we see a lot of tools that are being developed that are just using the nodes that are available to you inside of Houdini which is fine it's totally possible totally valid there's nothing wrong with that there's just a speed issue there so the more that you can put into these wrangle nodes the faster your Houdini engine tools will work inside of unreal and inside of unity okay so quick tip there and that's why I love teaching this stuff because you know understanding these kind of smaller components is very key to you know being successful at making tools for the Houdini engine okay so now that we've got that side going all right so it's basically half of our pyramid what we want to do is we want to pump in the other side of the ramp so in the green channel we are going to do the same thing so we're going to do the absolute value but this time we're going to test well in this case the the z direction right because our grid is on the xz plane okay and so I want to test that and we want to divide it by the grid size dot z times two same thing same exact thing and that's really just because we want a direction you can start to see really faintly the pyramid design and that's because we're using two gradients blended together all right so if we were to actually test just the green side here now you can see we get a roof shape on the other side so we got the red and the green all right super useful stuff cool so how do we get this into a pyramid shape well now we need to start working with blend modes so I'm going to get rid of this position offset there all right and let's just put in a couple comments here just so we keep things nice and clean and professional too right so we're going to get the bb box size and we're also going to then create our gradients all right there we go and what we then want to do is we want to do a blend mode so we want to use the min blend mode sorry so let's take a look at this okay so finally what we're going to do is we're going to say float shape okay there we go is equal to the min of our at cd dot r and at cd dot g and now if we were to pump that into our at p dot y plus equals shape what you'll start to see is a rough pyramid shape boom just like so so free to multiply that by something let's do for this time all right we have a pyramid perfect pyramid and we did that all with just a couple of lines of code well I should say it well it's a few lines of code it's not a couple right so there you go a few lines of code but that's still negligible compared to how many nodes you'd have to use in order to create this particular shape not the day it would be a lot of notes and I'm going to show that here in just a second but that is how you go about creating a pyramid shape inside of vex so very powerful and you know as as I dive more into the noises and more into these 3d shapes we'll get into parabolas cones you know different types of noises and stuff like that and functions or plotting functions and stuff like that to create shapes basically all right so there we go that's how we create a pyramid shape so let's take a look at the easier well I should say the node-based way it's not easier both are super valid and both are relatively easy you just have to understand vex and once you understand vex and a little bit of math this is easy too so let's take a look at the other way to do this so if I wanted to create a pyramid without writing any code or any vex code what I would do is I'd start with a grid like so and I would just make the the simple grid so I do have a preset for that but I'll just put two and two in here for you guys so I just want a simple grid here with no rows and columns basically okay and what I want to do is I want to then copy the size x into the size z here okay and I'm going to drop down a poly extrude node and the way that we're going to do this is I am going to copy again the size x value here and I'm just going to paste that into the inset and the reason why that works is because it's going to inset at the same size all right so we're just going to paste that relative and boom we all automatically have a point right in the middle and we can pump this up to four and you can see that we actually have a pyramid perfect the last thing we really need to do is just take care of the the two points that are at the top here because the the inset as far as I can tell doesn't fuse it automatically so you'd have to drop fuse node down like so and there you go so now we just have the single point at the top there we go excuse me there we go let's just pull that up there we go perfect now we have a perfect pyramid and if you wanted to close the bottom of this you would just go and put in a polyfill so polyfill and it will set this to single polygon and voila perfect pyramid shape and you would control the the height of this through that distance all right let's actually do some there we go whereas inside of the pyramid shape here we would want to put in a ramp or not a ramp but a channel float so chf and we'll just call this height and then just make sure that we actually produce that parameter and set that to something like five there we go so now we can go and adjust that the same exact way so two different ways almost the same results I can tell you just from experiences this will run faster inside of the Houdini engine this will run slower and obviously if this is all you're making with an hd a inside of the Houdini engine it'll be hard to tell but if you start creating more complex hdas for unity and unreal using the Houdini engine it's highly recommended to start using the Wrangles because they'll move faster they're all multi-threaded whereas all this you're going to get a lot of just overhead with with all these other nodes because you're not using a lot of the different other features you're just using a single feature all right we're just there's a lot of stuff that goes with this and this is pretty bare bones okay so that is that I'll leave you guys there and we'll start to do some more of these shapes as we get further into this whole series really appreciate it everybody I'll talk to you guys here in a bit thanks so much