#Houdini Heightfields to #UnrealEngine4 Landscapes

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
I'm going to demonstrate how to take a Houdini height field and bring it into Unreal Engine 4 as a landscape and I'm going to cover the basic generation of the height field in Houdini and the basic import process into Unreal Engine 4 then we're gonna paint it add holes to it and finally fix a collision problem that exists when you export a Houdini height field into a Unreal Engine 4 landscape so first we're going to do the basic height field in Houdini and created a digital asset Houdini digital asset which is basically a tool that you can create in Houdini it's it has a set of parameters that you can modify and can be used by plugins that run the Houdini engine and that plug-in works with like Unreal Engine 4 unity and Maya and some other programs as well so we're going to be working in this demo folder that I have you can see it's empty so we're going to open a new Houdini file I'm using Houdini Indy which is a commercial version of it but you can do the same thing that I'm doing with the apprentice version for free for non-commercial things so I'm going to save this file to begin with to that demo folder just in case something crashes we'll call this type field now we're going to create a geometry node here we're gonna dive into it create a height field type field noise and we'll use that as our basic terrain for now alright so I'm going to go back to my geometry object give it a different name called my height field going to select it go to assets new digital asset from selection and this is how I create my Houdini digital asset it's asking me if I want to make a subnet from the selection first I don't care to do that so I'll say no and now it's asking me where it's going to save this Houdini digital asset and I'm just going to save it relative to the current file so that's what this hip is right here so we're gonna call it Doug my height field I guess it's kind of a dumb name but I'll go with it except so some instances of getting a warning message saying some instances of my height field have had their parameter layout modified the parameter dialog these nodes will not like changes made to primarily out of this asset you may either leave these nodes I've changed keep the spare parameters on the nodes but revert the layout changes or delete the spare parameters completely I actually don't know what the consequences of this are so I'll go ahead and destroy all spare parameters why not see if something goes wrong okay so what you see now is this is where you define the parameters for the digital asset I'm exporting in a moment I'll add an item to this but for now I'm just gonna leave it as is I'll hit accept accept and now we can switch over to unreal and I have a new project ready to go I'm gonna save it to my demo folder and call it my project it's just gonna be a blueprint blueprint based projects so we don't need to do any coding for this notice C++ coding let's start me up on my other screen which you can't see so here's our default level I don't want I'm actually just going to make a new level that's completely empty we're gonna need a light in here I'll put I'll make it unlit for now actually so we don't even need that so I'm gonna go to the Edit menu go to plugins make sure that Houdini engine is enabled here if it's not then you'll need to install it and then I'm going to import that Houdini digital asset I created and I put that right here so my height fields in its drag and drop wait for it to cook and there we go so right now you can't see it very good because I'm looking at it unlit so I'm gonna add let me switch back to lit mode which won't be able to see anything at a directional light and just to make things easier to see we'll have a sky sphere and a skylight why not and I'm going to make these the two lights both movable so that it's just completely real-time we're not going to deal with any kind of baked lighting here connect my sky sphere to my directional light there so you can see right now material-wise it's just using the default world material and we'll change that in a moment but first I want it oh yeah let's save this level so I'm going to save this map as a new map that's fine it doesn't matter so the first thing I'm gonna do is go off-script right away and what we're gonna do is add a parameter that we can so that we can control our Gandini asset from unreal that's just to give you a taste of why you would want to do this besides just using the power of Houdini to generate the height field you can actually tweak it in unreal while you're working on your on your game so back to Houdini let's say that I wanted to expose the noise the noise say amplitude so I could go and change it in Houdini myself here but if I actually wanted to be able to do that in unreal I can also do that by exposing this parameter so set it back to what it was which is 500 and what we do is we go to assets and we say edit asset properties I'm going to edit the asset properties for the my height field asset go to parameters and we're going to it's just drag and drop this amplitude onto the parameters so just put it here and that's it so I can name it something else I want I'll call it like a noise amplitude while I'm here I'll put element size into so I'll call it a noise element size hit accept acet save asset update it then back to Unreal Engine actually gonna save this before I mess with it so right-click on the height field that I've already imported and say I could either rien port it but then that would only affect new landscapes a dragon dragged in so I'm gonna just rebuild all instances which will reinforce it and also update any instances in the world so now when I click on my height field down here under Houdini parameters which might be too small for you see I have noise amplitude and noise element size so I can go and change these parameters directly here so if I set this to a thousand say I'll get really noisy terrain be bigger I set it to like 3,000 it'll be really big too much obviously um go back to 500 or I could change my element size and spread everything out a little bit more whatever I like so when I do that it actually recoups it using Houdini engine alright so next thing we're going to do is creates the ue4 landscape material so right now it's just using this world material so go to new material I'll call it landscape open it up and this is gonna be pretty simple we're just gonna have three constants and then this is covered by the Unreal Engine 4 landscape documentation so I'm not going to talk about how doing landscape layers works but we're gonna add three layers for this demo the first layer is going to be called mountaintop we'll call the second layer slopes steep slopes and we'll call layer three the base so that'll be everything else so we'll bring these colors in those will be our base color our roughness we'll just set that to a constant like 0.9 so it's not too shiny and then we'll give these some default values so the first one is our mountaintop will make it snowy so like pretty white next one is our steep slopes so we'll make that kind of like a UH I don't know like a grayish brownish color or something and then finally we'll do base which will make like a really brown color I guess to be lighting this one up just a little bit just so we can see the contrast okay that's it we're here that save so now we want to apply that material to this landscape so I could select the landscape and say no I want you to use my landscape material instead then if I go to the landscape and started to try and paint it I would have those different layers available and I could manually start to paint it now now I'd have to create my own layers in here and as I do this you're gonna see the shaders recompiling apologies about that but just so you can see i'll fill fill it with the mountain top color paint on some steep slope color paint on some base color what the shaders compiled and this is just to verify that our landscape material is working like we expect you can see I'm painting on here now so everything seems pretty good I don't know if I gave it enough contrast between the mountaintops and the steep slopes but it works it's fine so one thing you'll notice right off the bat though is on the edge here I'm getting the stretching and on this edge I'm also constructions this the edge has been clamped and then stretched out and I know if that happens on every edge let's see it happens over on that edge as well and on that edge so every edge and the reason why is because when I created this asset I set my resolution to the default Houdini height map resolution which is a thousand by a thousand and Unreal Engine 4 is particular about what resolutions it likes and it actually wants it to be 1,009 1,010 j'en for landscape technical guide talks about this and what resolutions are recommended and and a bunch of other reasons why about like optimizing draw calls and these things and components which the landscape is broken up into but that's beyond what we care about here but we do care about getting rid of that stretching so I will take care of that so switching back to Houdini we just go to the height field and instead of a thousand by a thousand we'll pick a thousand nine by a thousand by nine and if we wanted to we could also expose the size as a parameter to the Houdini digital asset as well just like we did with the height build noise okay so I'm going to go ahead and save my asset and whenever we update the asset we need to re-import it into Unreal Engine so right click rebuild all instances which also does a and now you can see the edges are no longer stretched and closed with that kind of clamping look it looks fine now okay so next thing we want to do is you notice it lost when I ran the rien port it lost the layers it's like not connected and that's because we haven't created any layers in Houdini yet so the next step let me make sure I'm staying on track is to paint and so what we're going to do is in Houdini is create three layers from masks and we're going to match the names that we used in the ue4 landscape material so in the ue4 landscape material we used layers mountain top steep slopes and face so we're gonna use those same names and Houdini alright so switching back to Houdini what we're gonna do is we're gonna create masks and in fact I'll just create one right now so we'll say I filled mask by feature this is gonna be the one for the mountaintops and so we'll go ahead and select create our mask from height and compute the range and then change our ramps so that we're just selecting the top peaks there so this is gonna be the part we're gonna paint white okay so that's our first mask so I'll just call this mountain top mouse and at the moment like show info here I have to I'm probably gonna get the name of this wrong but voxel channel's created what is the height map which is called height right here yeah the Mo's mask which is currently selected I need to create three masks and they each need to have a different name so what I'm gonna do is copy that mask into a different layer so that's what the height field copy layer node by the way one thing you see me doing is changing what node has the display flat display flag that affects what how the that is basically the last node that's used to produce the output for the Houdini digital asset so make sure that you always have that blue mark on the correct one so here my source is mask and I'm going to call that mountain tops I'm just just double check that that's actually what it was called no singular mountain top okay so I'm mountain top then I'm gonna do another select for the steep slopes so I'm asked by feature this time by slopes I'll do any slope that's steep and No and then we'll copy that one into steep slopes again I'm gonna double-check the name they're steep slopes yep and finally everything else and this is the trickiest one because Unreal Engine 4 landscapes use weight blended this weight painting and so every every value that means the paint takes a weighting of I might be screwing this up but it's basically a weight painting of the different layers that you have and at least one of them needs to be nonzero but if all of them are one then it's not clear to me which layer would end up getting painted so the way I do this is I combine all all the layers that I've set up playing the first two layers and then invert that and use that as the layer for the last for my face to cover everything else basically to make sure everything is covered if you don't have everything colored covered you'll see it show up in unreal as a black area okay so first I'm going to take this top mask layer and what I'm going to use is this node called height field layer and that lets you combine things together so we're going to take the top mask we're actually the last one first so let's just see to range layer so we're going to take oh we also need to tell it that we're only working with the mask layer here and then so copy layer this is the layer oops I put it the wrong spot this one is these steep slopes late mats slope layer so I'm going to take the steep slopes layer and then add on to that the mountaintop mask and I'm going to say add I want to add them together so that's everything I've masked out so far and then the next thing I want to do is invert that and I can do that using a remap node type field remount and instead of mapping 0 to 0 and 1 to 1 I'm getting a map 0 to 1 and 1 to 0 and I also need to make sure I'm working on the mask layer so there's an inverted and then inverted so ok what I'm doing invert and then this is combine ok and then this value right here is the one I'm going to copy to the base layer copy layer I'm gonna call that base once again let me double check yes in this home base now one thing that you need to be careful of is to make sure that use the info button check it and make sure that at the final node you have all the layers that you expect to have so mountain top steep slopes and base if you just kind of especially when you start working on the mask to do everything else if you don't do it in the right order for instance if I took let me show you if I change the ordering these the mask still looks correct like that's everything and then I invert it but then when you go and look at the info down here I have height and mask but not base all right sorry I have height and mask and base but I don't have anything else and that's because the way that this the way that the gate is passed down apparently comes down this left channel to base terrain channel and the things that are in the terrain to layer channel just get tossed on the floor so everything that was created here which includes my mountain top layer and the steep slope layer aren't included in the final result so that's why the order or of these things actually do matter so like I said click on your node select I and just take a look and make sure you have you should always have height because that's your height field and then you should have all the masks that you want to paint on it and Maskull always be in there as well so this looks good right now let's make sure the last ones clicked and then I think we're good to go here let's click Save let me go ahead and say base layer alright so save that asset out back to Unreal Engine right-click and rebuild all instances again right so now on my landscape you'll notice that I have all those layers that I just created but I lost my landscape material and went back to world grid and so while inconvenient I could just switch it over here just drag it here but if you end up doing that a lot it gets a little annoying so I'll just show you one quick trick and that's going back to Houdini and that's to create a new attribute great attribute and we're going to call this unreal material and then we give it a path to the unreal material that we want it to use by default so I want to use this one so I'm gonna go ahead and copy a reference to that and I'm going to make this a string type paste it in there now the regular ue4 material string reference didn't work for me but this did this cap which is kind of like a simplified path it's just game slash landscape the other thing too is class needs to be set to either detail or primitive and where you find that information out is in the hue Demi engine for unreal documentation which is a side effects calm slash doc slash unreal if you go there and you go to parameters I think its parameters I know sorry special attributes and groups you'll see a bunch of things that you can export from Houdini that get picked up by Unreal Engine by the Houdini plugin in Unreal Engine so the one I'm working with now is called Unreal material and you'll see this thing is to either be a primitive or a detail I'm just gonna make it a primitive so I saved my height field again back to Houdini sorry back to unreal rien port again rebuild all instances and this time I shouldn't lose my material you can see it picked it up that time so you can also see that it's automatically set up the layers for each one of these and it has indeed painted it it's a little ugly but it worked alright I think that's the end of that section so next part is creating holes now you can either take this landscape and just start cutting holes in it but then when you wanted to make a change to it in Houdini you would lose the holes because it's gonna regenerate the asset so it'd be better if we can create the holes in Houdini itself so again if you go to that web page which I just showed you and down to the landscape section they have a section here which says if your height field has a mask called visibility then the plugin will use it for the landscapes visibility layer used to create landscape holes that's exactly what we're going to do so back to Houdini I'm going to just draw my own mask this time we're just going to cut a hole out with this so this will be my hole it's gonna be a big hole whoops that'll be my home so I've draw the hole and then we have to copy it to a layer called visibility save the asset back to Unreal Engine if you see me say V and stuff like crazy that's just because I'm a little paranoid I don't know if you actually have to so right-click re-import or rebuild I should say so cool you can see like something looks here like what I cut out but it's not a hole and that's because we have to set up a whole material alright so I basically want my whole material to be the same as a regular material except with it's not going to be an opaque surface so I'm gonna duplicate it I'm gonna call it landscape Bowl now what I'm going to show you is like copy paste you can consolidate your node Network especially when it gets more complicated using a material function I'm not going to do that just for the sake of keeping this a little more brief than it is so first thing we do is go down to blend mode opaque we're gonna make it masked and then we're going to bring in the landscape visibility mask and hook that up to the opacity mask that's all you have to do this is covered and I believe landscape materials docks that Unreal Engine comm well just look for landscape materials you'll find this page and they have I think yeah a section called landscape pool materials which covers how this works alright so anyway so this is our whole material but our landscape doesn't know anything about it so we have a normal material set but we don't have a whole material set so go ahead and just set it after a bit of compiling you'll see the hole come in here and then just like we did with the setting up the landscape name the landscape material name and Houdini we can do the same thing with landscape wall material which I'll show you as soon as this finishes okay so now you can see if there's the hole full in our landscape that one's not very convincing but you know use it for caves and stuff or underground areas alright so back to Houdini just like we use the attribute create in order to set a default material there's another one called I think it's called material unreal material whole something like that it's called unreal material whole yes it is and again it's a primitive or detail attribute which we've already set here and then and change it from landscape to I see a pole so and we'll attribute okay go ahead and save that that just means if we do re important now on we don't have to attach it to our landscape material again okay so I'll just prove that by right-clicking on here rebuild all instances now the idea is once you get this thing in your adjusting parameters that you've exposed you're not rebuilding this census all the time if you don't expose enough parameters you will have to be rebuilding instances okay so that looks good everything's set up and I can see through so that's the end of that section the last one is to address a collision problem and the first thing I'm gonna do is put a physics fear that as physics turned on just to demonstrate the issue so it's gonna grab a sphere out of here and we want to turn on simulate physics and I'm also gonna make it really big so it's easier to see right looks like a huge ball maybe a little closer to the ground and I'm gonna make a few copies of it now I put some under the Train let me delete those okay this one's kind of both then save the scene go and simulate that cool cool cool and it just fell right through well that actually worked the first time now I guess I'll just tell you what happens sometimes like I've been working with terrain today and I ran into this problem a couple times where I created the whole material but and you can see through it but things would not fall through it I don't know why I reported the bug to side-effects and I'll just show you the workaround even though it's already working for me right now so obviously I wouldn't have to do the work around now but what I did is this is just pure trial and error I have no idea why this works is I went to I clicked on the landscape and then went down to collision mipz level and changed it to one then re ran the simulation and it would work at that point and then I'd click on the landscape again and switch it back to zero which is what it was to begin with we run the simulation again and then it would work so that was the workaround if you do run into a problem where things aren't able to pass through the invisible hole area go ahead and try that hopefully if it isn't maybe I screwed up in my other project but if it is about hopefully gets fixed quickly hopefully you don't have to deal with it anyway you don't want to leave one thing I would say those unless you know what you're doing you don't want to set the collision depth level to one because that will reduce the fidelity of your collisions so you want it to be zero because that's the NIP level with the highest fidelity right so I think that's the last slide that we double-check so yep so just to reiterate what we did was write a cavity knee height field go to a landscape painted it up add holes and then fix that collision problem which didn't actually show up all right if you have any questions just let me know in the comments below I'll try and answer them I'm not an expert on this this is just me kind of learning experimentally and wanting to share for other people doing the same thing and also for myself for future reference
Info
Channel: Doug Richardson
Views: 20,516
Rating: undefined out of 5
Keywords: houdini, ue4, unrealengine4, gamedev, leveldesign, environmentart
Id: iUGRAbTHynE
Channel Id: undefined
Length: 33min 42sec (2022 seconds)
Published: Tue Mar 05 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.