Skip to content
Tech News
← Back to articles

The simple geometry behind any road

read original get Road Design Geometry Kit → more articles
Why This Matters

This article highlights a novel approach to procedural road generation using simple geometric principles, emphasizing the importance of efficient data structures like profiles for creating smooth, parallel road paths. This methodology offers game developers a more accurate and mathematically elegant way to model roads, improving realism and performance. For consumers, this means more realistic virtual environments and enhanced gaming experiences driven by advanced procedural techniques.

Key Takeaways

In the last blog post, I explained what sits at the backbone of procedurally generated roads: the data structure, aka the minimum information you need to describe any piece of road infrastructure. The answer to that fundamental question was a set of abstract cross-sections of the road, each storing a snapshot of how the road looks at that specific point (or, should I say, line). I called them simply: profiles.

A good analogy I didn’t have the inspiration to make at the moment was to compare them with Bezier splines. To store a Bezier spline, you don’t need to save the entire curve explicitly, but just anchor points and handle positions. With a bit of math and a few formulas, you can reconstruct the actual path at any time by interpolating between the control points.

The profile-based representation works the same in my system. The profiles are the control information, and the actual geometry defining the road path is the interpolated result of those profiles.

In this blog post, I’ll go over how I am computing the purple part. How to interpolate between these green profiles to generate beautifully smooth, parallel paths?

The Geometry Problem

In my first post, I explained why I embarked on this journey: I found most game devs seemed to be using the wrong tool for the job, rendering roads by expanding a centerline Bezier spline. I knew from the start I wanted to use only lines and circular arcs to build the actual road shape.

With the prerequisites fixed, we reduced our problem to a geometry one:

Given two profiles at arbitrary positions and orientations, how do we connect their respective endpoints using smooth parallel arcs?

A simple geometric property of circles instantly gets us one simplification for free. Points equally spaced along a radius trace concentric arcs when rotated around the same center. As long as our profiles are equal in length, we only need to solve the path for one pair of corresponding endpoints. Applying the same construction across the profile naturally results in parallel paths.

The problem is then reduced to:

... continue reading