Procedural Track and Terrain
With this project I was aiming to create a procedurally generated track and terrain based on variable parameters. The track generation first finds the path for the road using random points and a bezier curve, when a new point is created there are checks to make sure that the track is not overlapping with any other. The random points are created based on the parameters for the track, so changing the maximum distance from the last point will create longer sections of straight road, and reducing the minimum turning angle will create sharper turns.
The track mesh is created from the bezier curve points with a tiling road texture. After the track is created the terrain is molded to fit the road, for each point of the terrain’s heightmap the nearby road are sampled to make sure the terrain smoothly meets the road. For the rest of the terrain I’m just using a simple perlin noise function to create variation.
In the screenshot above I am testing the track with the Edy Vehicle Physics Unity package. In the top right a created a simple track minimap using a camera only rendering a black line that follows the road.