Is there a quick/easy way to displace a mesh?

I’m very new to UE, but do have some experience in 3dsmax from ages ago. I’m trying to simply displace some geometry, a plane in fact. The plane has to be high enough resolution to suit the map, but I could in theory just create the plane in 3dsmax and bring it into UE if that’s easier. In 3dsmax it takes 10 seconds, but I’m just not seeing any straight forward modifier or setting for a height/displacement map related to geometry.

My maps at 640x640, 16-bit greyscale pngs. Textures, normals, etc are not important. I merely trying to displace and light the geometry with a flat, grey material. I saw some tutorials online, but they were don’t so many steps in the blueprints. I figured it would be good to ask here before building what seems like a complex blueprint for what seems like should be a simple thing.

I did come across Landscapes, and in theory a landscape seems to simply be a displaced plane in some sense, but I was having trouble resizing it to make it usable for what I want.

Any suggestions or pointers to the right direction is much appreciated!

@wedouglas1 I think you need to deform the mesh before you import into UE. Also, it’s possible to import with heightmap:

@wedouglas1 Basically UE wants you to make the whole thing internally, hence the difficulty here…

In the material for the mesh you would plug in your height map into the World Position Offset input, which would use the existing vertices of the mesh and displace them. Alternately, you can use the World Displacement input which uses a tessellation value that automatically subdivides the mesh on the GPU.

Thanks for the replies. Interestingly, and maybe it’s just how I’m doing it, using a material to displace the mesh seems to have much worse performance. I created a 640x640 segmented plane in Blender, exported to .fbx, and imported that into UE. My displacement map was 640x640, so I figured I’d use that to ensure quality. I’m on a weak laptop right now, but the performance was very, very bad.

However, when I created a landscape with the same height map, the performance was massively better. In both cases I would have thought it was just displaced geometry with the same amount of mesh complexity. I’m wondering then if it’s better to just use landscapes than materials.

Any thoughts on this?

Landscape uses a dynamically optimized mesh, parts of the landscape that are closer to the camera have a higher level of subdivision than it does further away. The tessellation feature of the material is also an optimized option that’s better for performance than using a pre-subdivided mesh. It can also change the level of tessellation depending on how close you are to the mesh.

From experience:
don’t rely on 1 mesh with many vertices to get displacement going. This will bog down both the GPU and the CPU causing a bottleneck due to the face occlusion cannot work on a large mesh that’s always seen.
Basically anything over 1000x1000 verts immediately halves your FPS.
Even at 640x640 you’ll bottleneck your GPU and that’s what you are noticing with performance.

Instead, if you want to do stuff your self, make a smaller mesh of maybe around 50m, tile them all together with snapping, and apply a material that uses the same displacement map with World coordinates.

World Position - Mask R,G - Divide Map Size, Multiply .5

World Position - Mask R,G - Divide Half Map Size. You can get the map size from selecting the landscape, and using the X or Y location (including - or +). they should be the same number.

On top of it, like the landscape you should consider at least 5 levels of LODs on the plan mesh. so that you can adjust the number of triangles based on distance.
My 50m mesh has 150x150 vertex at LOD0, 100x100 at LOD1, 50x50 (1:1) at LOD2, 30x30 at LOD3, 25x25(.5:1) at LOD4, and 10x10 at LOD5
This does help reduce the GPU load on constant distortion or formulas.

Another thing, the Tessellation Multiplier.
What that does is add geometry. so with a Tess multiplier of 2 my initial mesh becomes 300x300 vertices, and so on. This obviously starts to bottleneck things again if you have too many tris on screen.

Last but not least, there are some different techniques, it depends on what you are doing and what you need.
look into Alembic / Geometry Cache
and Morph Targets.
In both cases these use the same baseline GPU side calculation to distort the meshes, but the first one is much faster and a static mesh, the second one a skeletal mesh with an empty skeleton.

Hope that helps,
Best of luck.

Thanks for your suggestions. I’m curious though about your suggestion of tiling and world position. Are you saying that tiling smaller meshes would still have better performance than a single mesh even though the amount of vertices and faces being seen by the camera are the same?

The reason I ask is because we’re trying to render the entire displaced geometry/landscape. For example, a satellite view of geography. The entire map is always being viewed.

So interestingly I pre-displaced our mesh in blender and then imported that mesh into UE. The performance difference between a 640x640 static mesh pre-displaced and the 640x640 static mesh being displaced with a material is enormous. Does this make sense?

If your computer is not as fast as newer one, and assuming you have a large world, then ya world comp would be preferred,reminding you can work on one tile at a time.

It does, the GPU ends up bottle necking when you displace a lot of verts.

And no you would not see benefits between having tiles and having a single mesh if you always display the whole mesh. But, you would see benefits if you properly use LODs because the amount of displacement vertices from afar is drastically reduced.

another consideration is the fact that importing a 1760x1760 mesh with vertices every 1m is near impossible. The engine just doesn’t like large meshes with a lot of geometry to begin with.

If you are using this mesh as an ocean/water, the best way to go is tiling or in case you really are far away with the camera only using normals to fake the waves.
I cant really think of any other reason one would need to displace a single huge mesh in real time so…

Got it. Yeah, it’s not for game development, it’s more for visualization of data.

Unfortunately LOD isn’t possible. There is technically some LOD that is sufficient that is less than the the max, but we aren’t creating the geometry from an artistic perspective and it’s dynamic. We need to preserve detail because we don’t know what kind of detail there may or may not be in any given mesh. Preservation of edges is very important and I’m not really sure how to preserve edges in our raw data. It’s really best that we just use the max quality we have.

I stumbled across RMC, which seems promising. It looks like it’s displacing meshes in real time with significant geometry. Procedural meshes might work since x,y values of the grid are always constant and only z values are changing with each new mesh.

If you can convert your data to a matrix of vertices where the Z changes you are essentially recreating the old old Cave game where you run about the cave until you hit the wall and explode.

either way, since you don’t have to worry about much of anything, you can bring in the data as an excel sheet (csv).
then you can create the material (UE4 - Programmatically create a new material and inner nodes - Isara Tech.) and loop the array of data in however you need.

A BP alternative would be using parameters or material parameter collections, but if every row is a collection it’s going to be pretty rough without looping.

Either way, ue4 is not exactly friendly when it comes to modifying meshes at run time…

Our application has potentially high throughput needs, so I’m a bit concerned about how working in a non-run-time environment would create a bottleneck. I’m not sure it’s viable to create a mesh, import a mesh, build the scene, etc. If we’re doing 10s of thousands of these a day, I feel like that would add up very quickly. Even if scene was simple, it seems like a lot of overheard that would otherwise be unnecessary. It’s unfortunate that UE isn’t friendly with regards to run-time mesh modifying.

I was just looking at a unity tutorial that made this look really straight forward and so I’m surprised to hear that it’s not also a common thing in UE. I feel like landscape and mesh modifications are pretty common in a lot of games (user character creation sections where head shapes change with a slider), though perhaps these are done differently with blending or something.

I’ve been looking into a couple possibilities:

Procedural Mesh Component
Run-time Mesh Component (open source project)

I’m actually already kind of procedurally generating the meshes right now and have the z values stored in a single text file, so getting them into a matrix should be quite simple.

You could potentially go the Voxel way.
We all have no idea what you are trying to represent, so it’s hard to give you suggestions…

If I were you I’d look into making a system that takes in the same data format you are given by whatever other software produces it and compute it in real time into what you need.

Not sure why you’d need UE4 for that either, it seems more of a basic matrix / C++ display sort of thing. especially if you need accuracy. unless you are somehow trying to leverage other functions like dynamic lights or something.

The character face changes are done with either mesh swaps, bone/animations, or morph targets. Basically it’s all smoke and mirrors.