MeshTool builds a terrain mesh off of two forms of input data:

  • Elevation data in raster (2-d array/image) format.
  • Vector (linear polygon) format.

Now the density of triangles in X-Plane’s irregular mesh (see here and here for pictures of a typical irregular triangulation) is not related to the DEM density – that is, MeshTool picks and chooses from DEM points to make an irregular mesh with the best DEM points for the budget you specify (via MESH_SPECS).  Thus making a bigger DEM does not make a final mesh with more triangles.

The situation with shapefiles and vector data is very different.  MeshTool will add as many small triangles as are necessary to guarantee that every line segment in your shapefile’s polygons are represented in the final mesh.  That means that if you integrate a shapefile with 1,000,000 line segments, at least 1,000,000 line segments will be “cut into” the triangle mesh.

If you go back and look at those two mesh examples, the second image (lines only, no fill colors) shows this happening: the white vector river at the bottom of the canyon has very short line segments, and the mesh triangles become small to “capture” this detail, even though the underlying elevation is relatively flat (and thus larger triangles would suffice).

Put simply: MeshTool doesn’t reduce the resolution of your vector data, and your vector data directly influences the density of the final mesh.  What this means is: if you put a highly detailed shapefile into MeshTool, your final mesh will have a ton of triangles and MeshTool won’t fix it – there are no settings to control the coastline density because MeshTool doesn’t change coastline density.  (This even includes silly cases: if you have a coastline that is basically straight but cut into 300 segments, MeshTool will make 300 triangles despite there being no purpose to them.)

This has further implications about your triangle budget.  There are only so many triangles you can have in a DSF before MeshTool and X-Plane both start to run out of memory; therefore there is a real cost to having your shapfiles be too dense – your coastlines will take up triangle capacity and you’ll be forced to lower the MESH_SPECS that make the mountains more detailed.

My advice for now: if you can, use an external tool to “simplify” your shapefiles before you input them to MeshTool!

I do hope to address this in MeshTool 1.1 by providing a simplification algorithm in MeshTool itself – we have this code in the scenery tools code base from global-scenery generation, but it didn’t make it into MeshTool 1.0 as a feature.

About Ben Supnik

Ben is a software engineer who works on X-Plane; he spends most of his days drinking coffee and swearing at the computer -- sometimes at the same time.

4 comments on “Complex Shapefiles Make Big (and Wasteful) Meshes

  1. Hi 😉

    Maybe it’s time to separate the mesh from vector data ?
    All vectors draped over the mesh, with LOD’s… more above mesh when far from camera, and more “sticky” when close.

    1. I think we are getting there…not for v10, but it is something I am looking at. It’s tricky because a large amount of the x-plane scenery system provides capabilities on top of the irregular mesh.

      One possibility is to continue with a pre-cut, relatively low res irregular mesh, but then allow tessellation hardware to increase the res using a traditional linear DEM. DX11 hardware has a fairly high max tessellation factor, good throughput, and it does realtime LOD well.

  2. Thanks for reply 😉

    Your second possibility is great, but don’t solve the problem related by this topic…
    My solution/idea simplify the work on scenery, especially by a community… if two (or more) guys works on the same tile. And, as you said, meshtool “choose” the points… by my experience meshtool don’t choose two times the same points, and there comes problems with tile borders.

    sorry my bad english 😉
    Best Regards.

  3. Hey Ben,

    I was just looking at marinetraffic.com. I was wondering if we possible to intergrate their data for ships location, speed and direction in to X-plane. Just an idea, I know you fellows are busy. Cheers!

Comments are closed.