 Howdy guys, IndiePixel here. All right, so what we're going to do in this particular video is learn how to get height information out of our map box samples that we take and how we can actually turn them into stamps that we can then use inside of Unity over here. All right, so you can see that I have a nice terrain stamp here, so let me actually just reset this here and set this back to stamp terrain. You can see I have a nice little mountain brush that allows me to go and just create new terrains there, or new mountains basically on my terrain. And now when you start to combine a bunch of these stamps together, you can create some pretty cool looking terrains that already have some erosion flows on them and really it's there to generally allow you to create better brushes than the standard stuff that we have here, all right? Just allows you to create more realistic terrains, I'd say faster, okay? But what we really want to do is we want to go through the process of using Houdini in map box, all right? And what we want to take a look at is how we can go through and take little samples out of that bigger terrain that we did, so let me show all the other objects here. Let me actually jump back up here and turn it back on, there we go. So what we want to do is we want to figure out how we can take small samples of the terrain that we sample with the map box and create terrain stamps out of them. So how do we go and create a texture like this, right? Using cops instead of Houdini, all right? So let's take a quick look at how to go about this whole process. All right, so let's take a look and see how we go about doing this process. So the goal here is to, you know, get a terrain stamp out of all this and I want to use map box to do that because I want to sample, you know, real world terrain. So I'm going to create a new geometry node and what I'm going to do is I'm going to call this my terrain sampling and all we're going to do inside of this geometry node is just get the data from map box. All right, so this will be a little bit of a review for those who have seen the map box beta part one video on YouTube. All right, so what we're going to do here is we are going to sample a terrain using the map box node that is now available. I should also note that I am working with 17.0.435, all right? Just so everyone knows I'm relatively up to date. That's relatively the last, I think, production build. Anyways, so what I'm going to do is drop down that map box node and then go to the API key here. And remember, you just go back up to your map box account. Okay, so then copy your public token. All right, and go back into Houdini over here and just paste it in there like so. And then to get the process started, what we want to do is we want to look up a place on the planet. All right, so now we have the entire planet in front of us. What I want to do is I'm going to go and sample a piece of terrain from somewhere up in the wonderful northwest. And what I'm going to do this time is do a volcano because we have lots of volcanoes. You can see them all right there. Going right along that ridge there. So what I want to do is just go find some, you know, impressive terrain, nothing too large. This is great because we actually have two types of terrain on both sides of the mountain. Something a little more canyons and arid. And then we have something more lush and we have a nice mountain range in the middle here, which will give us the ability to create a bunch of cool stamps so we can sample a bunch of areas here and make little stamps that we can then go into Unity and use as terrain stamps with using the new terrain system. Okay, so I think I'm going to do this area. So I'm going to hit download. And I'm going to wait for Houdini to do its thing. All right, we'll be right back. Okay, so we got a nice result here. Now you might have noticed that once the map box node is finished, you don't see anything in your view. And that's just because it's laying it out at the corner or it's putting one of the corners of the terrain at zero, zero, zero. So you just have to hit space bar G on your keyboard and it'll center up the terrain. So let's take a look here. I actually really dig all this because we have a lot of cool features that we can sample from this. So we got a bunch of cool canyon stuff, got a nice volcano here. All right, and then we have some cool, just kind of valleys and general meadows and stuff like that, low level mountains and stuff like that. So this is great because now it'll give me a bunch of great or variety of terrain, I should say, to sample from. Okay, so what I'm going to do here is just quickly go through some of these settings. All right, so you can see I have my latitude and longitude. All right, for this, so if you guys want to sample this same exact terrain for this particular tutorial, those are the values I'm using. The height scales at one, resolutions at one. We can always bump this up to two. All right, but you have to wait for it to resample all the data. So let's just wait for that and I'll be right back again. All right, so now we have a little bit more resolution to all this stuff, much better. All right, I think that's going to be good for the video. You can set that pretty high, but you need to have a pretty powerful computer to run some of that data. And I definitely want to make sure that my computer doesn't crash in while I'm recording this. So now we've kind of resed it up a bit. I have terrain mode to set to height field. One of the more interesting parts here that I should explain is that all of this data is being saved to these particular paths. All right, so your hip is basically your current hip file location. So wherever this particular hip file is saved at. And in this case, I actually have it saved inside of one of my folders here. All right, so if I go to my desktop and I just travel down into my work folder, and we go into all these projects here. All right, so then I have this project that I set up, a Houdini project, okay? So this is where that hip is pointing towards because this is where I've saved this particular file. All right, and then it's creating another folder for me called maps and inside of there, I have all the data. Cool, all right, so you might see this and be like, well, there's my height map, I can just use that. Well, it's not actually in the correct ranges. You can use the color maps and stuff like that. But in this case, for this particular tutorial, what I wanna do is create my own height maps and stamps from all this data. So we have to do a little bit of work to get the data that we have here processed. Okay, so let's go back to the Mapbox node. What I'm gonna do is I'm actually gonna lock this. All right, and what that'll do is it'll prevent this from updating. So let's say I'm happy with this particular area of terrain. It's given me a lot of variety in the terrain that I can sample from. So I'm just gonna lock it so I can't change, cool. All right, so I'm gonna drop down to null nodes here. Now, and I actually wanna go back in there. There we go. I wanna drop down a couple null nodes here. Alrighty, and I'm gonna call this out height and I'm gonna hold down the Alt key on the keyboard and just drag that null node out and hook in the OSM data. So this first input or output, I should say, is the height field that the Mapbox node is creating. And the second output here is creating all the OSM curves. All right, so we're gonna call this our OSM curves or just OSM, how about that for now? Because I really just wanna keep all things sampling inside of this one geometry node. All right, we'll create another geometry node where we will process the data even further. All right, so let's take a look at that OSM data. I'm sure there's quite a bit because I got a few towns in here. Yeah, all right, let's turn all that off. So we're getting all the roads. We're getting rivers. Whatever information was available at that particular location. So Mapbox provides quite a bit of information for all this stuff. Okay, what we're interested in in this particular video is all of the height field information. All right, because we need that height information to pull out our terrain stamps. All right, so let's jump up and out by hitting U on the keyboard. Also, if you don't wanna do that, you can just hit the OBJ button there. Now I'll bring you up to the root of the whole scene. Okay, so OBJ is the root. And what I wanna do is I want to create another geometry node here. And I think for this particular video, what I'm gonna do is reduce the resolution on the terrain. It's kind of chugging my computer a little bit on my laptop at least right now. I should actually be recording on my PC, but anyways, for this particular geometry node here, what I'm gonna do is I am going to call this our process height node. Okay, and I'm gonna go back to my map box and I'm gonna unlock it. Cool. And I wanna click on it and I'm gonna set the resolution back down to one. I really just wanted to show you guys you could up res it as well. All right, so now we're back down to resolution scale of one. All right, so what I wanna do is bounce back to the process height geometry node here and I'm gonna drop down a object merge node. All right, and there we go. So I'm gonna call this get height like so. Gonna make sure that we import the transform into this object. And I wanna get the height from the terrain sample. So we're getting the results of that null node that we put inside of the terrain sampling node. All right, so now we have the height in here. So if you wanna get rid of the color information, because remember we have all that already here in the terrain color.jpeg, all right. And I don't really need it anymore so I'm gonna do a height field, a quick shade. And basically what this will do is just get rid of any sort of texture information that's been applied to the actual terrain there. Even though we are still getting some snow, that's pretty cool actually. I'm really digging that. So there must be like a mask or something like that being provided. All right, so what I'm actually interested in now is sampling a portion of this particular terrain. That way we can get a stamp out of it. I wanna be able to create some sort of terrain stamp out of this. All right. And so after the quick shade over here, what I wanna do is I want to drop down a crop, height field crop node. All right. And this will further just help solidify or help with the resolution of the actual terrain itself as well. So you can see currently, if I do a space bar G on the keyboard I'm getting really tiny little piece of the terrain. And so what I wanna do is make this a lot bigger. Let's do something like 3000 by 3000 over here. That's even gonna be small. So let's do 10,000 by 10,000. That's pretty good. All right, so what I wanna do is try to find an area over here that's kinda cool. So I'm gonna actually look at my quick shape node there and just move this around just on that X and Z plane till I get an area that I'm really digging. So maybe we just sample the area over here by the mountain or the volcano I should say. Cool, that's pretty good. So let's take a look at that result. And there we go. So now we have our terrain. So I'm gonna hide everything else just so we can see the result. We can also just drag this around as well until we get an area that we wanna create a stamp from. I think right around the volcano is gonna make a lot of sense. Cool, so let's go and take a look at how we can go and pull the height information out of this. So what we're gonna need to do is we need to resample basically the current height information into a zero to one. Currently we're not in a zero to one range because if you take a look at the size of this thing, I mean we're already at 31,000 meters. All right, so this is a large terrain. All right, so we need to resample it. So what I wanna do is I want to do a height field and I wanna do a remap, not a resample, so remap and we'll just feed that into that remap, okay? And what we need to do now is go to the compute range. So I'm gonna compute the range here and you can see that our input min is at 1,000, input max is at 3,200. So what we wanna do is remap it to zero to one. All right, and that's gonna make it look not impressive anymore. So I turn off the grid there. You're just like, what? That's weird, there's no height field. So what I'm gonna do is name this just so we can reference it easily. So this is going to be our height remap, like so. And at this point, what we're gonna do is we're gonna switch into a different context. So currently, if you're still learning Houdini and stuff like that, we're currently in the SOP context because we're dealing with OBJ, okay? Well, what I wanna do is I want to be able to pull off the height information from this remap note here into a texture that we can then use inside of Unity. All right, and so to do that, I'm going to hit tab again on my keyboard and drop down a cop to network. So we're gonna work with cops. So remember, all this is in the SOP world. What we can do is we can actually drop down a cop to network, all right? Inside of this SOP, okay? And work inside of the cop context, which means the compositing operators. Okay, so hopefully that's not too confusing. So what we wanna do is we want to dive into the cop net and then hit tab again on the keyboard and drop down a SOP import. Let's do that one more time there. So do a SOP import node, all right? So this basically is gonna say get height. Like so. And what we can do with this particular node is we can actually retrieve the information from this particular node right here, the height remap, which is also why I renamed it. So I can just go and hit this button right here and quickly find it. So height remap, cool. So with that, we've now imported the height information into the compositing context. And so what we need to do is we need to be able to view all this in more of a texture standpoint. And so what I'm gonna do is hit this little plus button up here and load it up in or load up the compositing view. And this allows me then to take a look at everything that we're importing. And so to import, to officially import everything, what we need to do is we need to set the resolution from the SOP and also set the planes from the SOP. And if I take a look at the height now over here, take a look at the height over here, you can see that we are getting our height information. So I had to hit a space bar G on the keyboard to center it up, all right? Because you can have, there's lots of space around here. So space bar G again, centers it up. So there we go. So now we have our height information for that particular area of the terrain that we just sampled, okay? And to quickly export this, all right, we could drop down, I'm gonna hit tab on the keyboard and drop down a RAP file output. All right, this is basically a rendering operator. So the RAP context allows us to render, okay? So RAP just stands for rendering operator. And this allows us then to render out any of the planes. Okay, so you'll notice that, let me explain planes. So when we hit the button set planes from SOP, basically when you're working in cops, the compositing world inside of Houdini, you basically are working with a bunch of planes. And all these planes can have data on them. And so right here, you can see the two planes that we've actually imported. So mask, which has nothing in it, and height, which has all the height information in it. And you can also come here into the actual SOP import node and view the different outputs as well. And so what we're looking to do is export out our height information into a texture. And so what we wanna do is we want to then put that plane scope into this particular area right here. So I'm just going to get rid of the C and A, which stands for color and alpha, okay? I'm gonna select height. That way this RAP node right here will export the height plane. So all the information, all the data inside of the height plane. And I also want to send it to a particular folder. So our output picture is gonna be sent to our current project. So our current project is in job. Or you can also look at hip. But job is your current project, your Houdini project on the hip file or the hip path is the path to your current hip file. So where this particular scene lives. And in this case, they are the same. Okay, so I'm just gonna select job and I'm gonna go to render and I've already done this before. So I'm gonna select my brush, masks folder. And I'm gonna give it a new name. So I'm just gonna give it a name of mountainbrush02.tga. It's very important that you add the extension that you want because you can just type in the extension that you want and Houdini will sort it out for you. Okay, so I'm gonna hit accept. All right, so now we have that in there. The other thing we need to do is make sure that we're just rendering the current frame. I don't wanna render the timeline, right? This is not animating or anything like that, okay? So just the current frame, cool. So with that, you can see that our color plane changed and our alpha plane changed. So all I wanna do is go to my color plane and export the height information. And that will allow me then to get my height data out. Okay, so let's do that. Let me go and select the Rob node here and I'm just gonna hit the render button. And you'll notice that we're getting an error right here, all right? So if you middle mouse click on a particular node, it says, cook error in input, get height, all right? And that's just the current node. And really what that means is there's some error in our particular node here and I think it's that. We need height, not height nine. All right, let's hit render again and there we go. Just like that, we have our particular height field exported out. So let's go check this out. So I'm gonna go back to my project. Again, this is where I've saved my Houdini project. And if I take a look at render, brush masks, you can see now that we have a mountain brush O02, texture. And if I were to import that into Unity over here, so let's go into art, let's go to textures. I'm gonna show this in the explorer, like so. And this will just allow us to view the information or the texture information. So let's go and select our folder as well. There we go. So I'm gonna take mountain brush O02 and copy that over into Unity. Let that import and take a look here in the inspector. Again, I'm using 2018.3.1 F1. And there we go. So now we have our texture. Cool. And you can see that Unity's gone ahead and already imported it to one of the powers of two. And so what we can do inside of Houdini over here is we can make sure that we can rescale it. So you can always go into the image, say override size and scale it up there. But I usually like to leave this particular node with just its default settings when hitting set resolution. You can go in here and say scale. So if you hit tab and say scale, all right, we can actually scale this to a particular resolution. So in the scale dropdown. And let's just pump that up to five total by five 12. There we go. So inside of this whole cop context or the compositing operator context, you basically have almost like a substance designer type of workflow. It's not as powerful as substance designer. Well, I shouldn't say that straight up. It has all the nodes in there, but substance designer has really been tailored to creating procedural textures, whereas the compositing operators have been tailored to compositing images together with like masks and stuff like that. So while you can do it, it's a lot more complicated to do inside of the cops. Anyways, so now what I want to do is switch this over to height so I can see. So now I've scaled it up to five 12 by five 12. All right, so let's do another render here. I'm gonna say render and voila, we just rendered it out. Let's go back in the unity and just to reimport that. So I'm gonna copy it again and paste it. There we go. So now I have five total by five 12. All right, so hopefully that clears things up in terms of getting the height information out from that box. So as a last step, all right, there's gonna be actually quite a few last steps here, but as the last step to getting a stamp type texture out, what I wanna do is show you guys how we can use cops to start to composite together more of like a brush shape. Okay, so let's drop down a shape note and inside of this shape note, I'm gonna select a circle. All right, and you can see that the, if we're to actually put this into view, you can see that the shape, the circle shape is at 1920 by 1080. So, you know, again, like I said, cops is really meant for compositing stuff, but you can do texture work inside of it. All right, but the reason why this is at 1920 by 1080 because, you know, we're dealing mostly with compositing, but we can go and override the size of this by going to the image tab. Okay, and then what we can do is we can select the SOP import and just copy the override size for the X and Y, or in this case, we should actually use the scale because this is the resolution that I wanna go to. We're gonna copy the parameter and paste that in for both the X and the Y because I'm gonna keep this all square. So, inside the scale node, let's just do the same. Let's copy the X and paste that into the Y value there. Cool, so now this is basically the main texture size controller right here. Awesome. So now what I wanna do is I wanna transform my circle because I don't need it to be, you know, completely up against the borders. All right, so I'm gonna use a transform and I'm gonna scale this down to something 0.5 and 0.5. All right, so this means that we keep our resolution at 512, but we're also just scaling down the circle itself. All right, so now I wanna blur this, so I'm gonna drop down a blur node, okay? There we go. And this is because I want to have a falloff for my particular circle. And I want something like 400 or no, too much. That's pretty good. I like that right there. All right, so now what I wanna do is we can go and we can then mask this out. Let's use a mask node for this, I believe is mask. Well, let's just take a look at this. So what I wanna do is just bring in my height here and put in the mask and put this on height and there we go. Again, we have to come up here. So, you know what, this is kind of annoying to constantly have to switch over this view over here. And honestly, in this particular graph, we're never using that mask. So let's just put in a delete node here. All right, inside of delete node allows us to delete planes. So I'm gonna delete the mask plane and then feed that into that scale node. And there we go. So now we're getting just the area where our circle is. So yeah, the mask was the node that I use quite often here for making these turning stamps. All right, so let me wire that into my Rop node here. All right, and let's just organize this a little bit just because it bothers me when it's not organized. All right, so I just hit Shift L on the keyboard. All right, cool, very nice. All right, so what I wanna do is select my Rop node now and render that again. Boom, there we go, already done. Let's go and transfer that new file. So I'm gonna select that and paste it into Unity there. Then go into Unity itself and there we go. So now we have a perfect type of brush, but it's got real world height map information in it. So one other thing that we should make sure to do is take care of the compression. You can always not compress it basically and then set the format to 32 bit and apply. Let's just get as the most resolution as possible. All right, so let's come up here and I'm gonna actually use the IndiePixel menu. Go to Scene Tools and I'm gonna create a new level group. There we go. I'm gonna drag the light into the lighting group and inside of the geo group here, I am going to create a new terrain. Now again, remember this is 2018.3 so it's got the new terrain system and stuff in it. So super cool. All right, so let's go and do a couple things first here. I'm gonna go to Settings and go into my resolution, my height map resolution I'm gonna set to 1025. All right, resize it. That way we get a little bit more resolution for all this stuff. Okay, so inside of the terrain inspector, I'm gonna go back to the brush and what I wanna do is I want to, Stem terrain is what I wanna do but I wanna create a new brush over here. All right, so let's take a look at that. So what I'm gonna do is come into my art folder here that I have and now you can do this in any folder but I wanna go and create, so I'm gonna right click and create new brush and this is gonna be called Mountain Brush 002. All right, and then I wanna go to my Textures. Let me actually make a new folder also. So I'm gonna make a new folder here called Brushes and just drag my Mountain Brush 02 into there. All right, so with my brushes or with my brush selected, the new Mountain Brush 02 selected, I'm gonna drag and drop my stamp that I just created inside of Houdini right there. All right, so now that's all set up. So when I go back to my terrain, you'll notice I have this new brush right here, Mountain Brush 02. And if I were to hover over my terrain and increase the stamp height here, so let's say that we're doing like 100 meters. It's probably gonna be a lot. Now we have a cool new stamp and let's actually just make a little more room for all this here. Let's go back to terrain. So it's probably pretty high, we don't need all that. Let's put it to like something like 20. Now, this is where the artistic side of things come into play. These stamps really are just here to allow artists to block things in. Okay, so here I have brush eyes all the way at its max and opacity. All right, and all I wanna do is just stamp in some terrain over here. And now let's click off that. Now you can see as I zoom in, let's actually decrease the amount of lighting that we have here from this guy. All right, so as I zoom in, you can see that we're getting all that subtlety from our terrain stamp. All right, now, this is just one of those first steps in building out cool terrains, but that's how you build stamps using Houdini and import them inside of Unity. All right, so hopefully you guys, found that interesting. The next thing that I wanna do is start to get a little bit more information from the actual terrain to create terrain layers and export out the masks and stuff like that. But what I wanted to do was show you guys the general process for just getting the height of information in and out of Houdini and then into Unity so we can create stamps. All right, super cool. I love this stuff. The new terrain system's coming along it just fine as well. You can see it blends it very nicely. All right, so I'm gonna leave you guys there. And in the next video, we're going to take this a little bit further and start to get some masks generated and start to utilize more of the OSM curves and stuff like that. All right, so I will talk to you guys here shortly. Thanks so much.