Geometry scripting - creating static mesh with shorter distance edge points deforms materials applied

So now I want to extend the script to add a column at both sides of the static mesh, but the distance of the added points should just be 1/5 of the distance of the other points. So I’ve calculated the new distance, so far so good. But since shorter distance the applied material is also squeezed in. Basically I want the material to understand that the distance between these points is 1/5. Adding screenshot as a reference. Hope I’m making sense :slight_smile:

We are generating over 100 static meshes, so need to have a way to automatically do this.

As of now we use UE5.1, but that is not a requirement, can use later versions.

Thanks!

//Jonas

Steps to Reproduce
We have a blueprint using geometry scripting to generate static meshes (eg a warped planes) based on y,z points defined in a csv-file. Attaching screenshot of the script

Hi Jonas,

From your screenshot, it seems that you need to adjust the UV coordinates of your dynamic mesh. Node “Append Rectangle XY” creates a flat grid mesh on the XY plane with evenly spaced vertices (laid out according to the input parameters) and UVs (normalized to the [0,1] range on both dimensions). Your generator then squeezes the vertex coordinates on the edges, but currently does not adjust the UV coordinates accordingly, which results in the distortion you see.

I believe you want to regenerate the UVs so that they match the adjusted vertex positions, but rescaled to the [0,1] range across the mesh bounding box. You can probably achieve this after building the entire mesh by using nodes “Get Mesh Bounding Box” and “Set Mesh UVs from Planar Projection”.

Please let me know how it goes.

Best regards,

Vitor

Thanks Vitor,

Good not totally lost then, about what I think’s going on also :grinning_face: Played a bit with the UV nodes in geometry scripting, but not quite understand… But the “Set Mesh UVs from Planar Projection” seems as it could work. But there is a lot of tweaking to the Plane transform. Don’t really get if I in some way can calculate how it should be, or if it’s just to test. Do you have any insights here? Using these settings but still a bit off

[Image Removed]The “Get Mesh Bounding Box”, don’t think that is needed, or what was the intention with it? Think it will take all points in the “Target mesh” if not adding any.

Thanks!

//Jonas

Hey again,

Think I sort of got it. Since my planes are generated in y/z, the rotation got me lost. Setting Scale to the mesh size, and fixing the Rotation and finally tweaking Location. But now I’m not sure this is what I want… So all these generated planes has different geometry, and the UVs must follow that geometry. What this seams to do is just to flatten all out, a warped plane to visualize, how it should look, except the edges:

[Image Removed]How it turns out:

[Image Removed]Thanks!

//Jonas

Thanks Vitor!

It was quite an obvious thing to fix UV before warping when you say it :grin: As doing now the first plane is always unwarped, so I first create that one and fix UVs. Then this dynamic mesh is then used as template for all the warped planes.

Yes, the UV plane rotation - the checker texture is really helpful! First result looked weird and looking at my previously attached pictures, I noticed I didn’t get the rotation correct…

Looks as it’s working now, just need to run some more tests to verify everything.

Super thanks again!

//Jonas

Hi Jonas,

Sorry about the delay.

I suggest you use a texture coordinate checker that also allows you to clearly visualize whether your coordinates are oriented properly and not mirrored. One place where you can create and download customized textures for this purpose is on this link.

From your last screenshots, it seems that, besides the geometry grid adjustment on the side borders, you are also applying some kind of warping to the generated plane, and that you do want to see the effect of that warping on the applied texture.

If I understand correctly, in this case you should use “Set Mesh UVs from Planar Projection” after adjusting the side borders of the grid, but before applying the warping. This should make the texture conform to the warped geometry.

I experimented a bit and was able to put this together, maybe it is of some use: Dynamic Mesh Script posted by anonymous | blueprintUE | PasteBin For Unreal Engine

Result:

[Image Removed]About the transform input on the “Set Mesh UVs from Planar Projection” node, I think you got the idea:

  • The translation should define the mesh coordinates that will be mapped to UV (0,0), on the mesh coordinate frame
  • The rotation should be used to adjust the UVs from the XY plane to your desired plane, and to orient them correctly. A checker texture is useful here to make sure your coordinates point where you want them to. The rotation takes place around the origin in the translated coordinate frame.
  • The scale should define the size of the mesh area that is mapped to UVs [0,1], already in the translated and rotated coordinate frame.
  • Just like component and actor transforms, translation rotation and scale are done one after the other, in that order, considering a moving reference frame (a frame that is transformed along with each step)

Please let me know if you this helps and if you are able to achieve your desired result. And don’t hesitate to ask if you need further assistance.

Best regards,

Vitor