Scenery LoD

From FlightGear wiki
Jump to navigation Jump to search

Given the large distances that need to drawn in FlightGear, we use Level of Detail (LoD) to control how much of the scenery that is rendered at what distance to ensure frame-rates are reasonable.

How LoD is Controlled

There are three ranges that can be configured:

The range at which detailed scenery objects are displayed. Default value is 1500 m.
The range at which trees are displayed. Note that to avoid forests suddenly appearing, trees are slowly faded in from 2xRough range. Default value 9 km.
The range at which the underlying terrain mesh is displayed. Default value 30 km.

Scenery LoD is controlled from the View->Adjust LOD Ranges menu item in the simulator.

It should always be the case that Detailed < Rough < Bare. So in the dialog the Rough and Bare ranges are controlled as a delta on top of the Detailed range. Specifically the following properties

  • /sim/rendering/static-lod/detailed - Defaults value 1500m
  • /sim/rendering/static-lod/rough-delta - Defaults value 7500
  • /sim/rendering/static-lod/bare-delta - underlying terrain mesh. Default value 21000

So the ranges are calculated as follows:

  • Detailed = /sim/rendering/static-lod/detailed
  • Rough = /sim/rendering/static-lod/rough = /sim/rendering/static-lod/detailed + /sim/rendering/static-lod/rough-delta
  • Bare = /sim/rendering/static-lod/bare = /sim/rendering/static-lod/detailed + /sim/rendering/static-lod/rough-delta + /sim/rendering/static-lod/bare-delta

How LoD works

A scenery tile contains all three components - an underlying terrain mesh, trees (defined by the materials definition), and objects defined by the STG file for the tile.

The set of scenery tiles that are to be loaded/unloaded are re-calculated each time the view changes to a different tile location (aka "bucket"), and based on the Bare range. If /sim/tile-cache/enable=true, then a cache is used to keep the 100 most recent tiles loaded. Otherwise, they are unloaded as soon a they go out of range.

The terrain mesh is loaded in a separate thread, and FlightGear creates PagedLoD objects for the trees and objects. The PagedLoD is a piece of OSG code that will automatically load the required scenery when it comes into view and within the required range, then unload it if required when it goes out of view/range. So as you approach a tile, firstly the terrain mesh will be loaded, then the trees and then the scenery objects.

Obviously we need to unload objects otherwise memory usage will increase continually. OSG keeps this in check by limiting the number of PagedLoDs that are loaded at any time. To keep below the limit, it has a concept of object "expiring" after they have been out of view/range for a period of time. Once an object has expired

The way in which PagedLoD objects are unloaded is controlled through two properties:

  • /sim/rendering/plod-minimum-expiry-time-secs - This is the minimum time before a PagedLoD will be unloaded (expired). Default value is 180 seconds.
  • /sim/rendering/max-paged-lod - This is the maximum number of loaded PagedLoD nodes that OSG will keep. Once this limit is reached, OSG will unload expired PagedLoD nodes, starting with "inactive" ones - those out of view. Default value is 200.

Note that PagedLoD nodes are also used for AI aircraft, so there can be interactions in behaviour with high numbers of AI aircraft and scenery tiles.