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.
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).
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.
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.
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?)
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.
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 road will be deformed and you can spawn stuff along that spline with pcg!
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…
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?
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.