Shader

From FlightGear wiki
Jump to navigation Jump to search
The (advanced) shader dialog, as seen on 2.6.0.

A shader is a set of software instructions, which is used primarily to calculate rendering effects on graphics hardware, like water reflections and shadows.

Shaders in FlightGear

Note  for Power Users and Developers.

Compositor rendering settings rework on 'next' branch or nightly builds (2020.4) as at July 2021:

If you don't check the "Use Shaders" checkbox, FG will try to use the fixed pipeline for everything that doesn't require shaders (basically everything except clouds and trees). This may translate to a performance gain in old/low-power GPUs like Intel integrated cards.

If you do check the "Use Shaders" checkbox, FG will then try to use shaders for everything. This may translate to a performance gain in higher-end GPUs like desktop discrete cards.

The performance gains are highly variable though, i.e. you may find that more modern Intel GPUs performs much better with the "Use Shaders" checkbox enabled. That's why the option is there, so the user can experiment with their own system.[1]

FlightGear supports shaders since the switch from PLIB to OSG (FlightGear 1.9.0). FlightGear 2.0 added the ability to program shaders and effects more easily (without modifying the core code) and use them for terrain and model materials. Old hard-coded shaders like the chrome shader or the random trees in the scenery were converted to the new system.

The Performance vs Quality slider in the View > Rendering Options dialog provides basic control. At the right most position, all enabled shaders will be shown at maximum quality. Most shaders are simple on/off, but some of the more demanding shaders have intermediate steps. Powerfull graphics cards have no problem with the maximum quality setting, but most cards (even modern ones) need a finetuned setting to maintain reasonable framerates.

FlightGear 2.6.0

As of 2.6.0, you can change individual shader's settings in the Shader Options dialog, which can be reached via the button in the Rendering Options dialog. Some aircraft are equipped with custom shaders, those will show up under "Aircraft" in the very same dialog. Setting the Performance vs Quality slider all the way to the left will disable all shaders.

Another novelty is the so called uber shader; one effect that controls several shaders. This allows an aircraft (or any model actually) to have lightmap, normalmap as well as reflection map applied. For details and usage instructions, see $FG_ROOT/Docs/README.effects.

Disabling Shaders

It's possible that the FlightGear default shader settings are not supported with your hardware/drivers, so that the process will be killed by the OS because it's trying to do something not supported by your computer. If you are experiencing full system crashes, you should see System Crashes instead.

By default, FlightGear 2.6+ will assume a certain runtime environment and certain GPU features which may not be suppported by most older cards (e.g. shader support), such as GeForce 6/7 generation hardware and most older hardware (older than 4-5 years), so that it can be expected that FG will probably not work on such computers "out of the box" and may get terminated by your operating system eventually, i.e. the default startup settings will need to be customized accordingly, to disable all unsupported default features. See Troubleshooting performance issues, Problematic Video Cards and FlightGear Hardware Recommendations for more details.

Also, make sure you've got the newest driver for your video card installed and running without errors. A suggestion for a thorough updating procedure can be found at Graphics drivers configuration.

Use the following startup arguments to disable shaders altogether:

  • --prop:/sim/rendering/quality-level=0
  • --prop:/sim/rendering/shaders/quality-level=0

For the future, it makes sense (at a minimum) to make sure these features that require newer hardware can be turned off so that people with older hardware can still run the basic code and see the base scene. In some cases it may make sense to have a backup scheme available so older hardware can see something, even if it's slower or less detailed. (For instance, we have a couple runway light schemes floating around.) But at some point we do need to decide where to draw the line.[2]

Gallery

Image:SnowAtAltitude1.jpg Image:SnowAtAltitude2.jpg Image:SnowAtAltitude1.jpg Image:SnowAtAltitude2.jpg

Scenery around LFLJ with the snow effect disabled (left) and enabled (right).

Scenery around TNCM with water reflections disabled (left) and enabled (right).

References

Related content

Wiki articles

Older shaders

Source code

Non-inclusive list of C++ source code files: