Showing posts with label roads. Show all posts
Showing posts with label roads. Show all posts

Wednesday, March 27, 2013

Craters

Terrain generator in Outerra contains a vector stage that can be used to overlay procedural geometry over the generated terrain. It's used, for example, to create the spline-based roads that seamlessly blend with the underlying terrain, and allows generating fine road geometry where even the road paint can have thickness (a few millimeters).

Dynamic craters are the latest addition into the vector overlay processor.



Craters are dynamically created, specifying their diameter and depth. The algorithm recognizes the type of surface and generates a different shape for asphalt/concrete and dirt. Asphalt is just bent outwards a bit, whereas the dirt is strewn around a lot more.

They get created generally under half a second, which is quick enough with a reserve, given that the creation will be hidden by the explosion's particle effects. The crater shape is also immediately reflected in the collision data.



The shape of the crater also depends on the specified explosion depth, deeper epicenters tend to create steeper edges.



The number of craters is practically unlimited; a single crater definition takes only 64 bits. For now the created craters are kept in a buffer indefinitely, but they are not persisted (yet) between the sessions. Just as the roads, craters only affect the dynamic performance, i.e. when the observer is moving and new terrain tiles have to be generated.

The largest crater that can be currently created is around 1km in diameter. Here are also some older screens showing the evolution of the crater rendering algorithm.



Edit: a video showcasing the craters:


@cameni

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.

new
old

Tuesday, March 6, 2012

Road tool

A short article explaining some of the basic functions of the road editor tool in Anteworld game in sandbox mode. This is the first part that will be extended later as the improvements to the road tool will be made.

***

Roads

Roads in Outerra engine can be created by opening the road tool from sandbox menu. The tool allows you to create new roads or to modify the existing ones. New roads are created by placing way points (ctrl+LMB), both the existing and new roads can be modified by selecting road node and adjusting its attributes or position.

Here are the keys that can be used with the road tool (you can find them in the help tab of the road tool as well):
mmove the way point on the terrain, copying the terrain contours
shift+mmove the way point on the terrain, with the height locked to the original value
vadjust height of the way point
qmove to the next way point
shift+qmove to the previous way point
bappend a new way point

After the nodes are placed or adjusted, you can press the make road button to physically create the road or to rebuild it with adjusted parameters.

You can also select the road type and markings. The selection is limited at the moment; the road system will support much more road types, profiles and markings when it's finished.




Road nodes

Selected node is show with a node selector, drawn as three concentric circles. The circles show the widths of three important road node dimensions: yellow for road width, orange for border extension of the road, and finally the red showing width of transitional area on the road sides.


While the meaning of the first two should be immediately obvious, the transitional width needs some explanation. It specifies the width of the area across which the height of the road surface transitions into the surrounding terrain. If you are creating roads that are roughly at the same level with the terrain, its effect is not that visible. As soon as the road is elevated above or below the terrain, or the terrain is sloped, the effect of the transitional value shows.

The following pictures show the effect of the transitional width value on how the road is blended with the terrain. Just the single selected node has its transitional value changed:
8m transitional width
23m transitional width
1m transitional width


 Tangents


Roads are created from the placed way points using Cubic Hermite splines (for the interested, the algorithm has been briefly described in an earlier blog post). The splines allow for arbitrary selection of tangent (= the direction of the road at given point). Engine supports three ways of computing the tangents:
  • By default it's computed to be parallel with the line between two neighboring way points. This is OK in most cases when you are freely drawing the road.
  • Fit to match the direction of previous segment
  • Fit to match the direction of following segment
Use the latter two if you want to keep the incoming/outgoing road straight up until the turn, so that the nodes behind or before the turn don't affect the tangents:

Tangent computed from two neighbor nodes
Tangent set to match the previous road segment

Connecting roads

Until there's a tool that will snap roads together, you can only try to join them manually. Here are a few tricks how to do it.

Initial state

Move the last node a bit back (using 'm'), and place additional node at the end of the connecting road. Enlarge the road width to get rid of the sharp connection, and move the node so that there's no gap.


The road you are connecting to is usually slightly sloped, and you need to adjust slant of the road node with which you are connecting, together with the height of the node. The height can be changed either using the elevation± slider, or by entering vertical-move mode using key 'v'.


At the moment the width of the road is not yet actually spline-interpolated, but you can select between two modes using the width interpolation flag.
Linear width interpolation

Wednesday, June 9, 2010

Dirt Roads

In the previous post about roads in Outerra I mentioned that different road types can be created by using road profiles. Here comes one example.

Dirt roads are using the very same mechanism as normal roads, in fact the only difference is that road nodes here contain a different road type identifier. That is used to look up the corresponding road profile in shaders that generate the roads, and it determines other things as well - the pavement and border materials, for example.

Road profile specifies "exactness" values across the road width, in range from 0 to 1. Normal roads have value 1 across the whole road width, meaning that the elevation given by the road spline interpolation is exact and the resulting surface will be smooth and level. Values less than 1 will cause that the computed surface elevation is blended with the actual underlying terrain elevation with given blending coefficient. Additionally, the less exact the road surface elevation is, the more it is randomized by fractal to make it rougher.


The roughness created by the fractal noise can vary with the road type. The depth of the furrows can be determined by setting road surface under the terrain by a specific amount, and it can change node by node. On the sample road above it creates deeper or shallower parts. Or even a ridge when the way points are not set densely enough to follow the terrain accurately.

Here is a road that was created from way points lying 0.4m (on average) below the terrain surface with high roughness:



Another one that was put only slightly under the terrain and the roughness is low:


Lastly, few screen shots how it all looks in the terrain.


In order to utilize the generated detail we also set a finer level to be used for vehicle physics. In the previous video with Tatra truck the resolution for physics was around 1.2m, and it was quite visible. In the following video the resolution for physics is around 0.15m, 8 times better. The wheels are simulated as simple ray casts so it may be occasionally visible. Also, Angrypig toyed with the suspension and I left it in for the video; Tatra truck now sways way too much, but at least it serves to show the response to the terrain shape.


Forum topic here.

Tuesday, May 25, 2010

Integrating Vector Data - Roads

You may remember an earlier blog about roads where the approach and algorithms for creating spline based roads were outlined. At that time it was just a concept of how it may work, with many unresolved issues.

In the past weeks I occupied myself with integrating the road system into the engine, making it more robust and powerful on the way. The road way points now contain additional information such as road type, width, marking style and more that will allow to make a variety of road types, also including forest roads with ruts, for example.

As you can see on the following screenshots, the roads are completely integrated into the terrain - no terrain poking through the road surface ever. The integration also modifies the surrounding terrain to make the embedment natural. Side of the road is initially smooth up to a specified border width (can be specified per road spline node), and after that the fractal roughness gradually takes on.



Depressions are filled and an embankment is created.


 Routing the road through a rock or hill makes rocky slopes with defined steepness on the side(s).



More screenshots showing the creation process and the results, with varying level of detail.



The trees are automatically removed from the road surface and its border area, although sometimes you can see branches hanging over the road.


Splines allow for some mad road shapes but it still fits into the terrain :)




Terrain under the road is initially roughly prepared - gaps are filled and excess volume is cut out. This is being done at tile with resolution ~10m, so that fractal algorithm can refine it down naturally. Previously, when the road cut into a hill, the cut was unnaturally smooth. Now only the road border is smooth, gradually transitioning into a rougher fractal structure.

In the following screenshots you can see the process documented:


I. Placing the waypoints - this is currently being done as you move over the terrain pressing a build-road key, later a built-in editor will allow for better editing modes and options.



II. Rough terrain treatment - note this is actually hidden within the process, I've visualized it here just to show what effect it has on the terrain.



III. Finalizing the road




The engine has no problems with terrain resolution (as is apparently the case with many planetary engines), to the extent that asphalt can have actual thickness - I think it's 3cm now (~1.2inch).



Other notable features are
  • vector data are automatically partitioned and indexed in quad-tree managing the terrain
  • overlay dirt textures per road type
  • roads can connect, additional helper code will be needed to adjust the spline points and their attributes so that the connection is smoother
  • the same system is also used for terrain leveling, with or without pavement placing or with gravel surface etc.

Finally the process can be seen on the YouTube video. Original uploaded video was 500MB with good quality, but the recompression step on YouTube reduced it considerably.


The same system is used also for runways, here's a teaser screenshot for upcoming video where Angrypig tries to properly land at .. you can guess where this is from :-)



The corresponding discussion topic on Outerra Forums can be found here
See also the dirt roads