Scenery LoD
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:
- Detailed
- The range at which detailed scenery objects are displayed. Default value is 1500 m.
- Rough
- 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.
- Bare
- 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.
WS3.0 LoD
WS3.0 tiles have and in-build LoD hierarchy using PagedLoD. The top level tile is 1x1 degree in size, and below that are 4 tiles of 0.5x0.5 degree and so on, down to the lowest LoD level. Different scenery features are available at different LoD levels.
The table below shows the default values for the WS3.0 tiles. As the earth is a sphere, the size of a 1x1 degree tile will vary with latitude. The table below assumes 45 degrees of latitude.
LoD Level | Tile Size
(degrees) |
Tile Size
(km) |
Tile radius
(km) |
LoD Range
(km) |
Road/Railways displayed? | Minimum road/railway width
(m) |
Random Vegetation? | Detailed water? |
---|---|---|---|---|---|---|---|---|
0 | 1x1 | 79x111 | 68 | n/a | No | 9999 | No | No |
1 | 0.5x0.5 | 40x56 | 34 | 204 | No | 9999 | No | No |
2 | 0.25x0.25 | 20x28 | 17 | 102 | No | 9999 | No | No |
3 | 0.125x0.125 | 10x14 | 8.5 | 51 | No | 20 | No | No |
4 | 0.0625x0.0625 | 5x7 | 4.3 | 26 | No | 10 | No | No |
5 | 0.0313 | 2.5x3.5 | 2.1 | 13 | Yes | 7 | No | No |
6 | 0.0156 | 1.2x1.7 | 1.1 | 7 | Yes | 3 | Yes | Yes |
Notes:
/sim/rendering/static-lod/line-features-lod-level
sets the minimum LoD level at which roads and railways are displayed. At LoD levels less than this, no line feature are generated. The default value is 5./sim/rendering/static-lod/vegetation-lod-level
sets the minimum LoD level at which random vegetation is generated. At LoD levels less than this no vegetation is generated. The default value is 6./sim/rendering/static-lod/lod-level[n]/line-features-min-width
set the minimum width of line features that will be generated for LoD Level "n".
This LoD configuration can be configured from the View -> Adjust LoD Ranges
.