Easily Sculpt and Deform Landscapes With PCG

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
today I'll be showing you guys two different ways that you can deform the landscape with PCG so the first thing you're going to need to do is go into your plugins and turn on procedural content Generations this one right here turn it on and you're also going to need to search for patch which is the easiest way to get landscape patch you're going to turn this on as you can see it supports adding landscape patches which can be attached for meshes to affect the landscape as the mesh is repositioned and this is what we're going to be using to actually modify the landscape to turn both on and go ahead and restart your engine so to begin with the first one we're going to do is be able to actually deform the landscape and create paths that are either dug in or dug up from the landscape and the second one we're going to do is actually create an entire mountain range where we can pipe in your own textures for the mountains and things of that nature and spread them out for both scenarios what we need to do is create an actual landscape first let's go ahead and go to our landscape and I'm going to create this just as default so now we have have a big landscape I'll go ahead and delete the original floor that was there since we no longer need it and now we can get started so for the first one I'll make a new folder and this is going to be our PCG pathway and what we're going to do is create a new blueprint class it's going to be an actor call BP pathway deform because this is going to deform our pathway so in here what we need to do is actually add one of the new components we could just enabled which is patch so if I search patch we have landscape texture patches and just basic landscape Circle height patches for this one we're going to be using the default Circle height patch but we'll do the texture one next so if I put that in you're not going to see much here nothing has really changed you do have some settings on this you have a radius a fall off so let's actually make this a little bit smaller let's make it like 200 by 200 now here you need to specify the landscape for this we only have one landscape so just click on here and just enable it so it's going to work for our landscape and if I already just take this blueprint and just bring it out or try to you will see this drag drop the landscape patches layer in the list to choose where to edit the layer stack it should be inserted basically we need to enable editable layers so if I just click accept we're good to go and here in the outline you can see it has made a new patch manager so that creates one for you and gets everything assigned here is our Pathway to form it is just our blueprint but now if I pull this up and down you can see that it is now deforming and it's actually deforming the landscape so if I can just move this around as much as I want and I can make multiple of these and I can just deform this any way I want if I scale this it will follow accordingly so now what we need to do is actually have this populated through PCG I delete these and let's get ourselves a new blueprint class this is going to be our actual spline that we're going to use to create the pathway I'll call this BP landscape path and for the PCG component let's go ahead and create one so I'll make a PCG PG graph I'll go ahead and call this PCG pathway deform and here we're going to add a spline and it could be just a regular old spline and I'm just going to make this a bit longer by default and we also need to add a PCG component and with a PCG created let's go ahead and pipe in our current one so in our PCG graph it's going to be pretty straightforward we're going to get our spline data and we're going to sample it with a spline sampler and plug in our pathway into the level you can see that there's our spline so if I go ahead and vent this you can see there's are long points that are actually going to be spreading this out now for us we want ons spline but we don't want subdivision we want distance maybe because of the fall off that we have we've set the fall off here to 200 so I'm going to set the distance increment to 200 here as well then from here we want to spawn actor and the actor that we want to spawn is that pathway deform that we created and we go plug that in and instead of collapse actors we can either do merge PCG only or no merging in this we don't have any PCG inside of it so it doesn't matter which one we do we say no merging you can see it is now spawning all of these and if I take these and I move it up you can see it is actually being deformed but there's a few things that we need to do with this starting with the fact that we need to actually modify the position of them so let's get a transform points let's plug that into the spawn actor and for this one we're going to offset it somewhere between let's say let's do 100 you're going to move it into the ground 100 units this way we don't actually have to have the spline itself inside the ground we just have it be where this is you can immediately see it is now actually placing it where we want it I can move it up and I can move it down and it is deforming it accordingly so I can now draw this out and it will automatically deform to the location that I wanted to so we just carve it out now the actual fall off on this as you can see is the 200 units wide and the fall off 200 it's a little bit even everywhere so let's make a few changes to this let's go into our transform points and we can go ahead and give it a random value between 0 and 00 and then let's change the actual distance here to maybe be 400 and let's also change the scale let's go between 0.5 and 2 and here we are with this path and you can see it is now properly carving out the entire path and it is giving a little bit of variation and if we want to we can actually take this whole path up into the air and it will just carve it out and carve it in any way you want using this PCG as the spline now this is currently it's nice but this is just a simple spline setup and it's a little it's kind of small scale we probably want to use this for is to spread out an entire mountain range so let me show you how to do that that's a little bit more complicated if you guys are enjoying the tutorial so far I would love to hit the like button and while you're down there consider subscribing for more awesome tutorials like this so for this one I'm make a new folder call piece of mountain range and here we're going to need a few new things starting with a blueprint that is going to be an actor just like before and this is our mountain range deform and in here we need to add the patch but instead of adding a regular Circle patch we're going to add a texture patch immediately you can see it is now a large actual rectangle in here so this is has quite a a few extra settings let's start with actually setting up the landscape let's select the landscape here in the landscape manager the patch manager we can select because we've already dragged this into the scene it created one in the level so we can just select it here if not we could always have dragged it out and has would assign it and create it automatically but now we want to add controls for this because we want to modify a lot of this stuff from our main actual PCG graph and um blueprint that we create we don't want to modify it on each one of these individually although we will be able to do that as well so in the construction script we're going to add a few controls start with taking the lscape texture patch I'm going to set height Source mode and the mode that we're going to be using is texture asset that is the texture that we're going to be piping into this actual file the next one is I want to set blend mode what this is it allows us to change the blend of how the landscape performs so an alpha blend will just take the alpha of your your texture and use that to blend with the landscape additive We'll add the values together minimum we'll take the minimum value between your actual patch and the landscape itself and maximum of course will take the maximum value so it will never carve into the landscape it will only push out of the landscape now we want to control this I'm going to go ahead and promote this to a variable I'll just call this blend mode and I'll go ahead and make it exposed so we can control this on the individual node we also want to control the texture itself so I'm going to drag out and do set height texture asset and this is going to be the texture that's actually going to be driving this entire thing and again I'm going to promote the texture to a variable I just call this texture make it exposed the last thing I want to do is control the height of this PCH of landscape because we might want to have it lower or might want to have it higher now we can control this by scaling it that would work but there's another way of doing it as well so from here I'm going to search for sets height encoding settings and if I get this all plugged in then what we can do is take the settings and right click and split it and now we have zero settings in encoding and settings World space encoding scale so this right here is effectively our height scale now keep in mind this is based on the size of the actual patch so you have a very small patch the height is going to be relative to that size so it's going to be quite small if you scale it to be a thousand let's say by a thousand instead of one by one well that relative to that size the height is now going to be up to let's say a th000 instead of up to 1 this is kind of an overall scale of it based on the original size and instead of making this just a regular variable I'm going to make this two varibles so I'm going to promote to a variable and I'm going to call it height scale Min I'm going to detach it and duplicate it and I'm going to have the second one be Max make both of them exposed I'll bring that in and I'm going to grab ourselves a random float in range between Min and Max and that is going to be our actual World space encoding scale now I'm going to set the default of Max to be one and the minimum to be zero so it'll by default either basically not be existent or be at 1.0 strength relatively straightforward so now I'm going take it and just drag it out you'll see you'll get a rectangle in the scene but of course there's nothing here nothing's actually happening because we have not piped in any of these values I've gone ahead and created this hype map I just took a height map I found online and just gave it a fallof so that way we have effectively a little mountain range so I'll go ahead and plug that into our texture here you can see nothing has happened but if I drag it up and down it is deforming but we just don't see any height and that's because the height scale is just way too small so if I make this to be 100 you can see it starts to appear 1,000 again it is now larger so if I make this a value between 500 and 1500 see it starts to appear now it will only deform based on the resolution of your landscape so if I made this bigger you can see not only is it deforming more it is now has more resolution of the landscape to deform with and if I make a copy you could see that it is making copies but it's also cutting out into them as you see here so this is where the blending modes comes in so if I change this from alpha blend now to maximum it will only push up and I can do the same thing for the second one I can change it to maximum and it only push up and so effec we now have a mountain range which is awesome and it all Blends in together quite nicely we can go ahead and take this and move it over we can change the scale on this and it all deforms and we can also do things like minimum to cut into the Landscapes or maximum and it all depends on what you're trying to do of course you might see where we're going with this we can now implemented with PCG but there's going to be a few little extra caveats to get this to work properly so and remove all these patches and let's start with creating the PCG graph and this is going to be our PCG mountain range and our actual blueprint actor BP mountain range in our BP mountain range we want to go ahead and add our spline and we're going to do is delete this point right here right click on the point spline generation panel let's make it a large square and I'm going to make it quite large let's make it 5,000 units by 5,000 units and detail p search for closed we want to make it a closed loop and now if I drag this out you can see it's an extra point here so I want to delete that point and the original Point that's left you can see it is curved so I'm going to right click on this point spline Point type linear and now this is all set so now we want to add our PCG graph to here and plug in our PCG graph in here so now this is all set up let's open up our PCG mount range so like before we're going to get spline data and we're going to get a spline sampler and this one instead of spline is going to be on interior the point spacing let's set something up like every 500 uh units and we'll do 450 spacing and we want to check unbounded so now if I go ahead and Sample this you can see we're getting our points and they're quite nicely spread out we're probably going to need far less points than this so from here I'll go ahead and get ourselves a select points node and this will filter out let's say 75% the points will be gone we'll only keep 25% of them so now you can see we have far fewer points now we saw how big we needed to make that patch for it to kind of register so what we're going to do is I'm going to actually make this considerably bigger in scale but then I'm going to actually modify this sampler and change the distance here let's make it 1,000 units and 950 interior spacing and we're going to change it instead of keeping 0 25% we'll keep only 10% by setting it to .1 and that seems pretty good so from here we want to get a transform points and we don't want to actually move it up or down what we want to do is actually just rotate 360° and we want to maybe adjust the scale randomly so let's say between 1 and 3 now if I sample this you'll see it is properly doing that but we have a slight problem you'll see if I move this up right the points come with me and I want it to actually stick to the landscape now before in 52 we would use this but if I hover over it it says deprecated it is no longer going to be a thing in the future so let's not get used to it instead we're going to do is use a projection node and we're going to project these points into the projection but the projection Target instead of coming from this input we can get landscape data and we can use that plug into projection Target and if I sample this projection now if I move this up and down you can see it is still being projected onto the land now I can't go too high up at a certain point it'll stop projecting but you can see I now well Above This and it is still projecting onto this landscape and that's exactly what we want now from here we want to go ahead and spawn actor go select our mount range deform blueprint that we created plug that in and say no merging so now if we come here you can see well it's being placed but as you recall that value that we set is just it is just way too low it's just effectivly not doing anything so what we can do is we can go in here and let's choose the minimum scale to be something like 1,000 and the maximum scale to be 2 2000 by default but the other thing you might recall is we actually don't have a texture in here by default so for the time being I'm going to take my texture and set it to be the default in here and if I hit compile well you might notice we have a bit of a problem and if I move this to the side you can see immediately where the problem is it is triggering its own generation and we don't want it to trigger its own generation so let's fix that so in our BP Mount range where we have this PCG node search for the word generate and we want to change it from generate unload to generate on demand and we want to turn off regenerate PCG volume in editor so now if I come here and I move this it won't actually regenerate I need to go in PCG click clean up and generate and you'll see it is only generated once what we're going to do is actually expose these effectively to our main graph so in this PCG let's go and create some functions so I'll go ahead and make one called cleanup and one called generate for the generate one I'm going to get our PCG and just go generate force it and have that plugged in like so and for the cleanup we'll do something similar we'll drag this out and do cleanup plug this in and we want to remove all components and now if you click on either one of these you can make them call an editor so if we check that on for both of these in our actual blueprint here you can see under default we have clean up and generate so I can click clean up it'll go away and generate it'll generate only once if I keep clicking generate you will see it keeps building on top of itself we don't want that now you might be wondering why don't I just make this a single button let me show you if I take this cleanup for example and then I do the generate after in a single button and do the force as before and now click cleanup generates it great but if I click it again it will continue to build on itself and that just seems to be a bug if I have this disabled and click clean up it still Builds on itself it seems there needs to be a delay here here but we cannot add a delay in the construction script we could do it in the event graph but then you need to actually simulate or play for that stuff to actually happen so this is the best alternative so now we can just go ahead and click clean up generate whenever we want to actually generate this now as always the project files are going to be available on my patreon where you can join these wonderful people here in supporting what I do it really means a lot and if you'd like to join the community the link to the Discord is down below where we can help answer any questions you have so thank you so much again to my supporters and let's get back to it we already have the start of this landscape but we want to actually control these and we can we can go into each individual one because they are Blueprints and I can say okay you know what let's go ahead and move this one over let's maybe make this one 5,000 units high maybe move it over here and maybe set this one to be Max right we can do all this but then we have to do that for each individual one and we want to do that globally when we spawn all of them so that way when we go to our mount range and do the cleanup and generate again is still actually using all the settings we want so to do that what we're going to do is actually create all the variables in this graph that we created here what I can do is just clck come here and copy all the variables from one to the other so if I just click in here and paste I can just copy paste all of these variables as they are in the original into this one so now we have access to all the same variables they don't currently do anything but we have access to them and this assures that they're also named the same for convenience so we don't have to remember okay which one is this version which one is that version just named the same so now let's start exposing all of these to our PCG graphs so we can modify these at spawn and I'll start with blend mode and I'll go ahead and just take this I'm going to copy the name and then I'm going to go into our PCG graph and now we need to get ourselves a get actor property so we need to get access to this variable that we just created just paste it in and we also want to get an add attributes node now I want to preface this this matters of how you add it if I do add attribute here you can see that it is input is wild card and output is anything and if I plug this in here I can plug this now in here so in our case we're doing the projection here and if I drag out of here and do an add attribute you'll see the output is one of these and I can plug it in here but this will not actually not work we want to be a point output for so I'm going to change the order of this I'm going to change our projection to come earlier put our select points at the end I'm going to have our transform points first then I'm going to project our transform points then I'm going to filter them and now here we are left with this node so if I from here do an add attribute our output is going to be the same so this now this variable of blend mode we can plug in here and it's going to have this as the output we no longer need this two point if you use this twoo node it will not work so it is very important that you have the actual out points as the output so you can plug it directly into our spawn actor order is very important here and of course you want to plug in into our output Target for the attribute blend mode you can see it goes from blend mode into blend mode then in our spawn actor we can add some actor overrides so we go ahead and open this up and I'm going to pipe in for input source that blend mode variable in the input source and property Target in our case we have named everything the same so from two variables are all named the same so we don't need to worry about the naming setup but once we have everything plugged in if I clean up and generate it's going to be as before but let's say I change it to minimum and go clean up and generate well it's blank because it's not pushing anything up it's the minimum is the flat plane now for demonstration purpose I'm going to offset these points I'm going to add ourselves a transform points here and just before this I'm going to plug this in and I'm going to offset them between 1,000 down and 1,000 you can see what that does I can go a clean up generate so you can see some of them are up higher and some of them are pushed in so if I now set it to be minimum you can see it is only pushing them down or if I set this to be maximum it is only only going to push them up it'll never carve into it so this blend mode is now working correctly so get I'll get rid of this transfer points we don't actually want it and now let's go ahead and set up the other variables so we have texture height scale minimum and height scale maximum to make my life easy I'll go ahead and just take this and I'll just duplicate it three times I'll pipe that all in here in order and then plug in spawn actor right at the end for the spawn actor I'll go ahead and add three extra variables in here like so and now what we can do is come here and go in order so I'm going to grab texture I'm just copy the name go back to our PCG graph and then we want to replace the property name in the actor property the attribute name in here and in the spawn actor we want to pipe in texture in here and in here and then we go back and we do the same thing for minimum and maximum and here we are last one is in so now we have all of them piped in they're all set up correctly and again very important that the output here is points it all goes in Wild carbon out points so now I can go ahead and actually go ahead and even use our regular alphabet but I'll keep it on maximum I'll go clean up and generate you can see it has generated them but let's now change this to be height Max instead of 2,000 let's say 10,000 and we'll start at 5,000 so if I do clean up and generate you can see they're far Spike here so now we have this actually varied in height now we don't want to go that high of course maybe between up to 2,000 and we can even change the texture here so if I go ahead and select a noise I'll say this tiling noise and I go ahead and generate based on that we now have it now for this noise it is way too strong so let's actually just go something like 500 to 1,000 for this one and you can see we're now getting this noise actually pushed up in our case we want to keep it on the hype map because it looks a lot better but with this if I play around with the scale instead of 1 to three we going say 1 to let's say 10 for a very large range and in fact let's start it at three so we have a slightly larger Mounds overall these can of course be exposed to your blueprint as everything else just just through the actor property overrides in here but now when I clean up and generate you can see we're getting ourselves a nice mountain range now the beauty of this is these are still all individual setups so I can just take this and I can move it I can move it over I can change the values on this if I want a very specific number for height I can just set both of them to be the same and then we're good I can change the blending I can only keep the minimum and I can push this down and you can see it is pulling things down I can change to be a Max and then just really just push up this entire thing now of course in the setup it doesn't work but if I had a nice Alpha blend where it is Alpha out and has a gradient here this would work quite nicely and then when you're happy with it let's say instead of actually worrying about doing clean up and generate each time you can go ahead and just select your PCG and click clear PCG link and now I have a separate actor entirely so I can take this graph and just move it over and it's completely separated now from our actual separate blueprints here these are their own thing so now that they're separate I can do whatever what I want with them I can move them around I can scale them I can place them wherever I need and you can see we have just basically created a large amount of range relatively quickly with PCG and we have far more control now so now you're able to carve in with these paths with this mountain ranges and just really use PCG to make your life easier instead of having to manually sculpt a lot of the stuff and have a lot of more control just keep in mind you can add these texture versions or the sphere version to a one of your meshes so you're able to let's say have a house and below it you're going to just put one of these patches in and you can either do a custom shape with the texture or just use the circle ones and then wherever you place that mesh it'll automatically deform to that height so you can always guarantee that whatever object you have placed in the landscape will match on the ground to be the shape that you want now if you're interested in learning more how to use PCG check out this video right here where I show you how to use PCG to create your own back room style levels
Info
Channel: Procedural Minds
Views: 3,050
Rating: undefined out of 5
Keywords:
Id: IkWYtm1kaZs
Channel Id: undefined
Length: 24min 58sec (1498 seconds)
Published: Sun Mar 17 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.