How to use heightmap to displace vertex points in a procedural mesh

So I actually want to ask how to go about this.

With C++ in unreal I managed to get all the pixel data of all the pixels that I need from my 2D textures and store it as an int 8 bits in the range of 0 to 255 , I also manage to covert the pixel data from converted int to floats that have a range between 0 and 1.

I want to actually displace the mesh, offset the vertex points on a mesh that I already have that has a 3D shape. I can do this with noise from various noise libs that I use like simplex noise, my vertices in the mesh distorts/offsets from the original position to the offset of the noise and I get a distorted/modified mesh by noise. So I tried applying the same rules to the mesh that I usually apply with noise, this time trying to offset the vertexes of the mesh with floats obtained from converted color codes(pixel data), but it does not work and what I get is totally not the heightmap at all on my mesh.

There is a way to create mesh from pixel data but with new vertices and new triangles, but that would be a whole new mesh, not the mesh I have, and this can be done, but instead of creating new vertex points I want to offset the ones already that I have with float values I obtained from my pixel data.

Is it possible to offset the vertex points for my mesh with the pixel data that I have ? Is it something there that I’m not getting, do the floats need some format, or do I need to turn my floats into some type of noise that is continius. I use Procedural Mesh Component or Runtime Mesh Component, so I want this in C++.

The material node offers tesselation with displacement but this offers no collision at all and I could not find a way to give collision to the offset data from the node, I also want this in C++ oriented so later I have better control to improve things.

Where to after I get the floats from my pixels.

Can you use WPO instead of displacement?

If you know the distance you push stuff in/out, can you then scale the collision bounds by the same amount?

EG: if your mesh is 100 units wide and you push out by 10 on each side, scale the collision by 1.2?

Use a material parameter collection to capture the necessary values so you can reference it in a BP.

World Position Offset , that is in the material node.
You saying to use the World Possition Offset ?
I don’t know if the modified verts get saved as in recorder inside the vertex array with World position offset, if so later I will not be able to calculate vertices for other things from my Vertex array data maybe since the position of the vertices inside the vertice array remains the same or do they modify ?

Maybe it has nothing to do with the vertice array that provides the data to the PMC sections and component. I think it’s a shader that does things behind the scene without modifying anything inside the vert array that you use with procedural meshes, I could be wrong so I need to check the data.

This is how I modify/offset positions in the vert array.
“Vertexes possitions old data from mesh [z axis] + Pixel new data”
So I’m using FVectors with float values to insert new data inside my array so I can modify it and give it a new value replacing the old one(actually adding on top of it with the offset representing a float value)since I only want to offset what is inside the array not add new verts.

This will offset the data inside the array, the vertex position on the z inside the vetex data will get displaced inside the array, so it’s recorded there as a change "old data + pixel data = total sum new float number on the z recorder inside this array, works with noise, does not work with floats that I got from my pixels, and I checked the values and they are accurate, it’s the actual pixels converted to float values.

I really wanted a C++ solution.

It does displace in a strange way, a bunch of vertexes get displaced for one single pixel, so for one pixel a group of vertexes get displaced, I don’t understand why it does this, I need one vert for 1 pixel ?

Regarding WPO it would be a solution I think If I could dump this data inside a new array from what WPO vertex offset is if the offset includes not just the offset but the whole new data off the mesh with the offset included.

Is there anyway to get the data from the WPO offset ?

Use a material parameter collection to capture the necessary values so you can reference it in a BP.
Is this it , will it give the float data ?
How do I get the values from the node in C++

I’m a blueprints guy; I can code in C++ but choose not to; the visual-presentation of BP’s makes it MUCH easier for me to code, digest, etc. I’m a visual person.

I’m also of the mind ‘just make the material do it’ as you can very often find a material-centric solution so it can be run on the GPU.

SO! I don’t know how in C++ might be able to bridge this gap. I’m more thinking of a path you might be able to leverage… However, since BPs are really encapsulated C++ code, anything a BP can do C++ ought to be able to do as well.

Look into Custom Primative Data?

I actually created a heightmap system with procedural mesh component but it’s all new mesh, so it’s not with modifing the old mesh

So I created this and it works good but now I need to find a way to fit my mesh onto the old mesh, use relative positioning from the main actor, or should I go with something else , anyone know a way to make out of two meshes one mesh, to fit a mesh that is flat made out of a grid line on a 3d mesh that I already have.

Pushing/offseting vertices upwards just does not work in systems like rmc and pmc with pixel data on an existing mesh.

I solved my problem, I can now imprint on an existing mesh a heightmap. At least in a primitive form for now but it’s a start. Problem is that with blue prints I don’t think you can format your mesh, how the vertex order go’s on the mesh and that is very important for me. It’s worth getting into blue prints just a bit I think, but how would you format a mesh, I mean it’s vertex points to form a square and then the next 4 vertex points form a square and so on. Is this even possible in blue prints ? so your mesh has squares 4 by 4 by 4 , a mesh formed from vertices that are aranged like quads so you can draw indices on them on the vertices that form squares on your mesh, like a grid line that gets built by a nested patern.

At this point, I am not sure I would know.

1 Like