Mesh Deformation Along Spline Curves with PCG

Hello Unreal Engine Community,

I have a challenge that I’m hoping you can help me with. I’m currently working on a project that involves creating a curved road using a spline and procedural content generation (PCG). I have a single 500x500 road mesh, but when I add curves to the spline, I’m encountering issues with the mesh connections not working smoothly.

Do any of you have experience with using procedural content generation to deform meshes based on spline curvature in Unreal Engine? Or perhaps you have ideas on how I can effectively address this problem?

Any assistance or insights would be greatly appreciated.

Thank you!


You just need to have the tris connect it seems.

Basically you are nearly there but only working on quads when you should be working tris, I think.

Can’t really be sure since you did not share the generation script’s code.

If you aren’t generating this on the fly using a procedural mesh component, then whatver you set up for the spline mesh is incorrect (and should that be the case I can link a decent enought tutorial to follow).

Hey, first of all thank you for your help!

Here I am with additional Information.

This is my PCG Graph, it’s pretty simple. I’m getting the spline data and sampling some points and project it to the landscape. Then I’m transforming the points to match the left and right part of the road and spawn a static mesh.

Spline Sampler

Transform Points



This is my static mesh I’m working with.

I know that the stretching part would be possible with spline meshes or the landscape spline. But I don’t know if I have the customization options that I have with PCG, because I also have other road meshes I want to randomaly place instead of the normal road, for example a road with a drain on the side.

Im also very interested in this. I believe it’s beyond the scope of PCG.

I’m not sure it’s possible to affect geometry beyond just spawning static meshes, as it would involve entirely new duplicate/modified meshes in memory :confused:

Instead the approach would be having a kit of parts with predefined lengths/angles/slopes and spawn the right piece at the right place.

I dont think you’ll ever get anywhere with this.

Even if fully instanced you are dealing with a massive amount of meshes for something as simple as a road.

Further, because its linked to a spline the mesh instances are all custom deformed making it impossible to instance.

The proper way to do this is to generate the mesh on the fly.

Not to generate a road out of pre-cut mesh parts.

You can “parse” a pre-cut mesh part to mimic its final shape, read the vertex and transfer it over to the final mesh component.

Being you are just using a spawner it’s not going to do that for you(op) or work.

And @Nebukam its totally possible, it’s partly what is supposed to happen.
There is a ton of new content on this.

You are looking for acrual mesh generation, Not mesh placement.

Mesh placement will almost never work with splines in normal like environment scenarios.

I though only the spline deformer could actually “edit” the geometry, didn’t knew that was something doable directly from PCG graphs? (Unless we talk about creating a straight line of assets that is then fed to a procedurally spline deformer later in that same graph?)

A spline is a collection of point/transform data.
You can use it any way you see fit.
In this case, along a Procedural Mesh Component likely.

I see what you mean; I was stuck on “ creating a curved road using a spline and procedural content generation (PCG)” but indeed nothing prevents you from using both systems.

1 Like

I’m currently doing something similar, but I am using Spline Mesh to create the seamless curving road in a blueprint, then passing the spline that I use for the road to the PCG component (in my case it is also in the same blueprint actor) to use to exclude the generation of other PCG assets along the road. I use Get Spline Data and Filter By Tag to retrieve the spline from the component in the blueprint.
It would be nice if PCG could generate smooth spline meshes too though so that I could use the same rules to configure the road rather than script them in blueprint.

One way to do this is to first create road with landscape spline and then use that spline in PCG graph :handshake: road will be deformed and you can spawn stuff along that spline with pcg!

Landscape spline is useless.

A regular spline can apply the same effects onto the landscape via bluetility script.

So don’t waste time making a spline that’s going to only be accessible in editor.

Make a spline both your game and the editor can use…

2 Likes

Do you have links for any material or documentation about this acrual mesh generation stuff?

Usually just procedural mesh component does the trick.

But it depends.

For instance, I wouldn’t want a road to be generated at runtime unless the game called for it to be changed at runtime.

So you have several approaches to the problem:

  • A road kit with fixed and instance capable pieces
  • A spline that makes a road out of meshes which you then “bake”.
  • a mix of the 2? You can combine instances to custom turns of the spline that are then baked to meshes in order to improve performance a bit.

Generally speaking use anything but the engine.
A GIS program with vector shapes can define the road points much better - and from real world data.

You make an exporter that takes those points into unreal to use as a spline (because you will still need that spline for gameplay).

You also export to a DCC like Blender or Houdini where you do/set up the actual modeling work.

If you take enough care during the modeling process you end up able to import and use instances of the same object for most of the road /within reason.

Eventually, you may need to subdivide the engine’s spline to add car lanes, or similar options.
Havent really found a “no touch” way to do this yet, as when you move splines around the curves often need adjusting…

1 Like

Thanks for your input. My project uses runtime-loaded real world data to generate the splines. I’m currently focusing on creating dynamic junctions where these splines intersect, and I’m considering procedural mesh generation for this, but i can’t find much about this topic online.

Given your expertise, do you have any specific advice or methods for efficiently generating these junctions dynamically at runtime?

Here is an exaple of what i’m trying to achieve:

Appreciate your help.

There is a lot more to intersections and splines than making a material and adjusting a mesh…

You can probably start by creating a procedural mesh at the junction.

I would do so by calculating the angle splits between the several splines that intersect at the intersecrion point.
Each angle will become the starting tris that the intersection is based on.

There is almost no chance that the mesh will align with the end of the spline piece, so instead of attempting that, I would fake it by creating a piece of procedural mesh with more vertex at the joint.
Then I’d levarage a vertex shader to adjust the position of the vertex up/down to match the spline mesh (Distance to nearest surface or even distance field gradient).

Simply making sure the meshes (road and junction) can not cast a shadow is likely enough for most discrepancies to be overlooked by a player.

For your use case, i would probably also try and levarage RVT to output the meshes into a diffuse to then use as the unrelying paint for the mesh - this avoids or cures many visible issues and potentially also allows you to merge dofferntly colored bits of road when the intersecrion comes up.

Anyway, the hard part of playing with mesh generation/mesh sections is learning to think and model on a Tris By Tris basis.

I think intersections make a good jumping in point to learn over the fact their spline interesction point is alwyas the final tip of all the tris which will make up the road…
You can literally build pieces outwards from it and increase the complexity as you understand more of how to use the system…

Unfortunately, I don’t really see any good tutorials on the subject or I’d share.

The proc mesh compoent is often hijacked to do things like vehicle collision deformation, or shoot and change the object type stuff.

1 Like