Wednesday, March 26, 2008

Road Overlays and Draping

X-Plane 9 allows you to put roads in an overlay DSF, but this isn't actually that useful yet.  The problem is that roads are specified using MSL elevations - that is, they are positioned in absolute space.  So you have to know where the ground is to build a road, which defeats the whole idea of an overlay.

This dates back to X-Plane 8.0 - originally all scenery load was done when a DSF was loaded, with the sim paused.  In that condition, keeping scenery load fast was a high priority.  So I set roads up to be "pre-draped" (that is, their heights are pre-determined when building the DSF). Back in the day it was a win.

Now we have multiple cores and DSF loads in the background, so we very easily could "drape" a DSF...but it gets weirder.  A road's sub-type is specified in the DSF - and sub-types are used to define bridges.

Now that's not incompatible with a "draped" scheme - imagine a road whose height is specified AGL, so a height of 0 means "run the road along the base mesh" and a height of 10 means "10 meters above the base mesh."  Now you would set the road type to overpass as the height went from 0 up to 10 meters, then back to 0, forming a bridge.

The only problem is what happens if the ground is really weird looking.  In practice what we want to do is keep the road's slope as constant as possible and build out bridges based on that. The effect can be hard to see, but if you look at bridges in the US scenery, you'll see that sometimes the banks to a river slope down but the road stays horizontal, forms a bridge, and then stays flat as the banks come up again.  This happens because our road processing code (in the DSF builder) tries to limit road slope.

That's not an easy effect to create in an'd basically have to increase the road AGL at the rate the base mesh's AGL is decreasing (if only you could know that).

So the questions I am debating now are:
  • Are AGL-draped roads useful if we don't know what the base mesh will be like?
  • Does it make sense to have some other abstraction to help smooth roads when the base mesh is bumpy (and can we make something that is both simple and useful)?
Like most philosophical things I debate, this isn't scheduled to go into the sim that soon. Improved shaders, a more complete airplane SDK, and a better texture pager are all ahead of road improvements, which pushes roads out quite a bit I think.


Photos said...

Hi Ben,

Actually, I sincerely think that the only thing we need is tools for modifiing base scenery. We lack of custom scenery and that's maybe because of the tool that doesn't come. We need (in my opinion) WED to be fully operationnal (road, mesh, texture editing) before to have nice shadows or reflects that kill CPU nad GPU. We have nice rivers now, but still ugly position for them...

Dan31 said...

I want to be able to change the position of the river. Specialy now than I use PhotoSceneryX. The same for the road. Plane simulator meen that we fly on a plane over a country. With photoscenery we could fly over our home. Help us to make good custom scenery and forget about shader. Please.

krz said...

why not shrink-wrap the roads to the unknown surface in the direction of planet center? could be done after loading the terrain. this way could lead to maximum terrain dependance while nothing is hardcoded

Benjamin Supnik said...

The problem with shrink-wrapping is that some roads (like major highways) are likely to have a bridge over very small but steep changes in terrain, to keep the slope of the road constant.

To do this with a shrink-wrap approach we'd have to have some parameters to control the shrink-wrap and some idea of how to change road types when we bridge.

The change-to-bridge operation would further be tricky because right now roads only change type at junctions, so we'd have to allocate new junctions.

krz said...

mmmh thats a nice thing..but i guess you already find those steep steps in an automated way (angle-delta-lenght-ratio?). if such a step occurs you could add some transformation to the next/previous few road-edges to lift them up gradually to "bridge" the steep step.

a shrink-wrap approach would be very userfriendly since peoples could just paint over their g2xpl scenery from top/down view without having to worry about elevation.

i see this as a future proof method since its easy to handle and can be applied without lots of special cases. personally i dont find steep steps in roads annoying. they usually occur because the roads dont follow their real directions.

i would love to see a easy way to edit roads (in worldbuilder?) and a way to integrate community changes to the official global scenery. maybe road-data could be downloaded from a official server (with a smart versioning system to reduce server heat)?

with good tools a good global scenery can be created with the indirect help of the big geo-players like google. i think this cant be avoided - but it could be better supported ;)

Anonymous said...

road and in extension all network elements is the weakest part of X-Plane (with low-alt texture) :

- very bad positionning
- no spline (curve)
- no tunnel (for the road)

anyhow, perhaps the future is only to have a good photo-realistic database.

but I agree with other, a good scenery editor will be a good start (why not using Sketchup !!)