UE5 Geometry Script - Displacement Map

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
in this video i'm going to show you how to create a procedural displacement mesh object using geometry script and unreal engine 5.0 so i've already created the blueprint actor and the variables we're going to need for this process so the first thing i'm going to do is grab is drag in the source mesh variable and get the source mesh this is a staticmesh asset variable that's an input public input to this procedure so i'm going to right click convert to validated get and then off the is valid pin i'm going to copy mesh from static mesh so i'm going to wire my target mesh in there to the two dynamic mesh and the source mesh asset to the from static mesh asset so i'm going to hook up the exact pin now if i compile this and i drag one of those to the level it's going to be empty but if i switch to modeling mode let's say let's make a sphere and let's just make a taurus 2 we're going to use that later so now if i go back to my displacement blueprint i have to select in the tree over here and i drag the sphere into the source mesh slot you see it updates to be the source mesh if i drag the torus in there becomes the torus so that's the copy operation so the next thing i'm going to do is i'm going to apply tessellation to this so off the dynamic mesh i'm going to drag a apply pn tessellation node and that's only going to do that on success of the copy so if the copy failed for some reason we wouldn't tessellate and i've got the subdivisions over here i'm going to drag that into the tessellation variable so now if i go back here maybe let's use the taurus again we zoom in and we see i can increase the tessellations and you see the torus gets rounder let's set that back to zero okay now we're going to get the displacement map which is the texture 2d asset get displacement map right click convert to validated get we're going to wire that up here if it's valid we're going to apply displacement from texture map that's that node is going to take the target mesh and the displacement map the option struct here we can drag off a pin to create a new option struct but you can also right click and say split struck pin and then you can just wire things in directly so i'm just going to wire in the magnitude which is the sort of height of the displacement i'm going to compile that and then i'm just going to put a recompute normals node off of here because uh this displace node doesn't automatically recompute the normals so we compile that and go back you see it still looks the same but if i drag this stones map in there you see it's being displaced now and if i increase the tessellation we start to get more and more of the detail we can go quite high here actually and i can drag say a different map in there too so now i have a procedural displacement object uh and so basically i could use things like the convert tool to bake this out into a fixed static mesh when i'm happy oh i dragged it in and made a material out of it um so the only thing you'll notice here is it's kind of chunky when i drag it around that's because it's quite expensive to recompute this displacement map so it's it works okay if i change the settings over here but if i actually want it in the scene it's expensive to move around so what we can do is we can basically disable this blueprint from recomputing when we're happy and i'll show you how to do that so that's what this be frozen parameter is for so i'm going to drag it in get the frozen value make a branch node off of that okay and then i'm going to shortcut here and so i'm only going to apply this this whole blueprint if frozen is false which is the default um so now we can compile and run the only problem is when we do that so if we check frozen it's going to disappear so why did that happen because the rebuild generated mesh event clears the mesh before it runs the blueprint so we have to do two things to change that behavior the first thing we have to do is select the blueprint itself go to the dynamic mesh actor section and uncheck reset on rebuild so what that's going to do is it's not going to clear the mesh each time the script runs now the problem is when we're not frozen that means we're going to copy this mesh each time and accumulate the mesh over and over so what we want to do is add a reset node before we do the rest of this so i'm going to just move this over a little bit more and the target mesh i'm going to basically pull off and there's just a reset function that clears the mesh so the false wire is up here now and then that we do that reset and then we pass that target into the two dynamic mesh here so now if we compile this so it's still slow but if we freeze it now it's fast and it's not being recomputed so if we go and change these parameters nothing will happen until we change the frozen setting if we put this back to zero it'll stay until we unfreeze it and then it'll recompute okay that's it for this video thanks for watching
Info
Channel: Ryan Schmidt
Views: 23,467
Rating: undefined out of 5
Keywords:
Id: HYCB3BC0_Ig
Channel Id: undefined
Length: 5min 13sec (313 seconds)
Published: Fri Feb 25 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.