Wednesday, April 4, 2012

Road interpolator

Build 3053 fixes several issues with the road system, making it much more robust. The road interpolator, described in an earlier blog post, works by generating road surfaces from relatively simple vector definitions. The algorithm puts some limits on the allowed road curvature and the width of transitional areas where the road sides are blended with terrain. However, the old implementation of the interpolator had several bugs of its own. On the following screenshots: first the new, enhanced implementation, second the old one in some problematic areas:

The precision problems first appeared on the road markings in tighter turns - the center lines started to deform and vanish. Another very common defect was the occurrence of high sharp spikes at the road sides. It could be partly suppressed by narrowing the transitional widths and loosening the turns, but the issues were still there and some types of roads could not be done at all.

In some cases the road surface folded and deformed, as on the following screen:

What changed in the road system is not the core algorithm itself, but rather the setup that omits the geometry shader (speeding it all up), and uses a finer tesselation so that the inner algorithm is more stable as the result.
Additionally it also dynamically shrinks the transitional width of the inner side of turns, which helps to reduce conflicting overlapping areas where multiple road segments try to adjust the road sides.

The new implementation also changes the transition from road sides to rocks. However, this part will need more tweaking, as it's still possible to create roads that are blocked by large rocky outcrops. It can be helped by moving the road a bit outwards.