Houdini / UE4 - Tutorial - UV Pivot Baking and Shader Effects - Part 3 - Baking Pivots With Houdini

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so in part two here we're going to look at baking our pivot data to our UV of an object to either create or import into Houdini the first thing we need to do though off the bat is discuss a behavior with Houdini that I do not like involving geometry that you import and I'm gonna start creating a a geometry here based off of a cone that Lee so we can actually witness this and see it what's basically going to happen here is that as I export this file I'm just going to export this cone here with with a Z up axis so so that it's Z up as it's being treated and I'm going to export that here we're gonna call this up verified FBX and if I bring that into Houdini here using a geometry node and then a saree geometry shop and then we're going to use a file node we're going to see something strange so if anybody is familiar with Houdini understands that to Dini prefers the Y up orientation by default and you'll notice that our cone looks like we would have expected it to with it pointing upwards but the thing to be aware of it is is that it is pointing in the y axis positive meaning that if I jump over here to like unreal for example I'm going to import that same file we just looked at or just created and I'm going to make sure that I don't convert the scene we will end up with a geometry here that is pointing Z up as we expected but if I take this same geometry that I just imported into Houdini meaning that we just have a file note here we've all we've done is bring it into here if I take this note and I export it from Houdini directly out and I'm gonna call it here up test from Houdini export that and I import this one into unreal so again I didn't make any changes I didn't make I didn't move a single vertice around a single point around that kind of thing if I import this and I do not convert my scene you'll notice that our geometry here is now sitting on its side meaning that Houdini itself has manipulated the positional data of our object so it's position may not correspond anymore to the baked vertex positions as far as I know there is no way to override this as far as an import goes on Houdini so what you need to make sure that you do if if you need to use this file again outside or if you you know want to keep this consistent with other versions of other projects the very first thing you would ever need to do from this is use a transform node and rotate this object 90 degrees in the X and this will give you a z+ so that it is now existing how we were expecting it to in the first place there is one other way to import a FBX into Houdini you can go to file import film box FBX and you do have more options here including a convert to Y up coordinate system where you can uncheck this and we can select a geometry here and import it that way the issue is if we do this through here if I import that same file at same cone just clicking on import will create a new subnet inside of basically a new geometry and so unfortunately if you're trying to set up a a system basically where you can just you know plug in and have like a like this quick script that we want to run for our new our geometry just you know for each different geometry this is relatively obnoxious for tur for purposes of importing and such because it's going to create a new node or it's going to create a new subnet on the object level every single time my last note before we get started is that in order to actually export what I'll be showing you today you will need at least the educational or a limited license version of Houdini the apprentice version while it will let you do everything I'm showing you guys in Houdini it will not F export the FBX at the end for you that's something that apprentice cannot do so to start talking about creating our short script to bake our pivot data to our UVs we need some geometry first so what I've done here too to prepare is I have two different geometries one is the default Krag geometry that is inside of Houdini I then used the RBD material fracture node to split him up into smaller pieces and I finally rotated him 90 degrees so that he would lay in the Razzie up axis I also had here a cube both of these objects I've scaled 100 times but this cube I also ran through that same RBD fracture node just so he can get pieces out so the idea here then is for each one of these separate pieces if I use here and explode node so we can kind of see it I basically want to get the centroid of every single one of these pieces and somehow bake it to the UV we can even see what the the centroids might end up being by using the extract centroid node I can then you look at that use this I will put the exploded view on our secondary our template view and then I will use my primary view for our centroids and we can see that this node itself the extract centroid will give us the data we exactly want for all of our pieces you can see here if I'm kind of mousing this around a little bit that this is generating the pivot points or the centroid of every single one of these pieces we have so we somehow need to save this data to each vertice that we have and we're gonna do this by using a for loop now there is the for each primitive and we can use that in this particular case but there'll be one problem with it if I connect this to my fracture node and I look at this if we take a look at a single pass here let me turn off the template view of exploded view you'll see that if I go back to our box we end up actually make that there we end up looking at only a single plane if we look at each one of the passes and that's not exactly useful what we could do is because our RBD material fracture gives us this information we could change it to our piece attributes that we use something called name and then it'll start giving us the entire actual connected piece so now if I pass through here we can see that it's starting to give us each separate piece in fact if I pipe in the exploded view instead we can even see a little bit more easily that we're actually just now iterating through every single separate piece this is because if I split my pain of view here and I change this to my geometry spreadsheet every primitive from after the RBD material fracture is given a name and it's given a name based on its piece value so these for loop is basically using that and it is now looping through and showing specifically those with that name now this is fantastic freezing the RB material fracture but what if we are specifically looking for something so that we can bring our model in from my eye it's already been fractured there or some other program well in that case you're gonna want to use the for each connected piece and this is going to have an extra little note at the top here that we can just plug in directly and it will create its own attribute you'll see here class that it will use for that same purpose and if I if I use this st. exploded view here we can then see that if we go to a single pass of this it's doing the exact same thing which is basically letting us iterate through each individual piece which means that if we then use our extract centroid node we could technically look at a single centroid at a time so what we're gonna do is make sure that this node here this extract centroid is inside of here so that we know that we're going to get our centroid every time you want it now the only catch is we can't just use that because if I just pass the extract centroid through here I'll end up with just a single point so there's obviously more we need to do inside the Loup I'm also going to get rid of this exploded view because it is going to mess some things up for us afterwards so the next thing we want to do then is we want to make sure that we have a place to save this data to so we actually need to make sure that before we adjust this connectivity we're gonna UV unwrap this and you will have to do this two or three times it depends if you've unwrapped it once so that you have something for textures and materials in your in your other program like if you're bringing this in if I look at my vertex and my vertices sheet for my geometry we can see that I just created the UV effectively zero here and I'm actually going to copy this node two more times and I'm gonna unwrap this thing two more times the second time I'm going to call it UV one the third time I'm going to unwrap it I'm going to call it UV two so now I have a bunch of extra UV channels of data on every single vertice and that I'm going to begin writing information to we're going to write information to here using an attribute wrangel and we're going to put this attribute Wrangell inside of our for loop and what we're going to do here is we're going to take that centroid information that we saw the one that we got for every single pass here and we're going to plug that into our attribute wrangles second input so that we can utilize it there and so now here's where if you have experience with vex you let you know your Python and easily if you do not have any experience with vex vex is basically a c++ ish style programming language that you can use inside of Houdini and it lets you do things like this where you want to create your own kind of procedural work for example in our case I specifically want to run myself over each vertice because I want each vertice to eventually store so or modify the data here and so to start writing our vex code then the first thing I want to do is verify that we can change this UV 1 and UV 2 data to whatever it is we want so the first thing we're going to do is we're going to grab ourselves the set vertex attribute function and what I'm gonna do here is I'm gonna click on it I'm gonna click f1 and this is going to bring up the Houdini in in program help and this is gonna let us know what exactly this particular function is going to request and it's gonna want the geo handle which is for our case with attribute Rangel is specifically which pin we want to pull data from it wants to know the name of the attribute we're trying to adjust in our case we're gonna look at UV 1 it wants to know what primitive number we're working on that's gonna be negative 1 in our case it wants to know the vertex number and it wants to know the value that we want to send it to so I will type in 0 for our pin 0 the name is going to be UV for the attribute that we're trying to adjust I mention that we not we want to use negative 1 for which primitive sorry H primitive number we're going to use and then for our vertex number I'm going to use at VTX that's 4 as basically a at vertex number and that's basically whatever whatever iteration whatever vertice iteration we're running through that's what we're going to use here finally the value for this test here I'm going to set this to 0 0 just right off the bat and I click down here and we're going to see that this immediately changed to zero zeros so we're affecting the right channel I could change this to at VTX num also and then you'll see that each value is being given something different so we're getting the right one set the next thing that we need to do is we actually need to pull in our centroid data and for this we since we have this being plugged into the second pin we're gonna actually just make ourselves a vector here we're gonna call this this variable here centroid point I'm going to set it equal to point and I'm going to tell it that I want to use pin 1 I want to use whatever its position value is and then 0 specifically we can type we can hit f1 on this as well what if basically is asking for is you know geometry attribute name and then which index is that we are look what we're looking for it's the point number since it's basically the centroid is only producing one point we know that we just want pin 1 whatever its position is at point 0 which is only it's only gonna have one specific point there and then this is going to give us a vector this is going to give us a a basically a tuple with with a size with with three different entries into it but you remember I specifically use this set option over here with two so we have to basically set this data with only the first two values so I'm going to make myself a couple different vector twos here so this is gonna be a vector 2 UV 1 data and I'm gonna make a vector 2 UV 2 data I'm gonna set this first one equal to our centroid point 0 and centroid point 1 so I'm going to reference the first to the X and the y and that's run on a store in there and the second one I'm going to set this to my centroid point two which will be our z-axis and then the value 0 because I'm not really using that what I can now do is I can then set instead of doing a set value here what I will do is I will set my UV 1 data on my vertex to UV one data I will then copy this line and we'll change this to UV two and I will change this to uz to data and now we are storing our pivot data in our vertice so if I take this off of single pass all of our vertices now should have what our UV data is or where that point is and because it's always important to double-check your data to make sure you're producing the right values what we're going to do here is add a little bit of an extra script here at the end just so we can visualize the points in space that we have now added to our object here so what I do here is I'm gonna add in a group node just so that I can label all of my old points I don't label them old I'm gonna add myself in an additional attribute angle here and we're gonna collect the data now from all of our vertices so I'm gonna give myself two vector to about our data values here I'm gonna call this one UV one I'm gonna call this one UV two and we are going to set these both equal to their respective values on their vertices making sure I run this over vertices rather than points so I'll type in vertex and we know we want geo self I specifically want UV one for the top one and I want whatever vertex number we're currently on and then I'm just going to copy this to make it a little bit faster and we're going to change that to UV - now I'm gonna make myself a standard three vector here and I'm going to set this equal I'm gonna make this on a call this pivot and I'm going to set this equal to UV one zero that's our x value UV 1 1 that's our Y value and UV 2 0 that's our Z value remember our UV - 1 index is not used and I will simply add point and I will add a point to Geo self for every single vertex and I will place it at my pivot I don't really care if I have multiple points that are kind of overlapping each other the idea is as long as I see them all in the right space I know that everything is working properly and so we won't see anything because they're all inside of the geometry reading it right now so the last thing we need to do here just to verify what we're doing is blast away all of our old group and I will put our previous node on template mode and we can now see that we have our pivots for each piece being stored here now this is a very good point in time to actually mention that that this data is hard-coded into ru V's meaning that if we for example were to translate this object if I just for example put in a transform node here and I can then slide this geometry around my pivot data stays put it has been hard coded to be relative to our object so if our object moves our pivot data does not move so this is very very important so that's all there is to it then it's actually a fairly simple system I'm just gonna have a null point here that I can pull out that I can then use to export my FBX what we can do here is we can plug in instead of a cube we can plug in our Krag model here sitting over there on the side we can even take a look that his points are being baked to his right positions as well and they are what I can do here is I can make this my primary node and I can now export this as an FBX so that's exactly what I'll do export fill box FBX and I will go put him in my right folder we'll call this crag example bake and I'll export it in the next section we will look at bringing this FBX then into unreal and how we can then access the data that we've saved to it inside of our shader
Info
Channel: Okari
Views: 2,986
Rating: undefined out of 5
Keywords: Houdini, Unreal Engine, Pivot Baking, VFX, Shader FX, Tutorial
Id: bIX8EsFn0BQ
Channel Id: undefined
Length: 21min 37sec (1297 seconds)
Published: Tue Jun 23 2020
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.