Shader: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
m (moved Shaders to Shader over redirect: Singular)
(+ References section. There was a stray reference at the bottom of the page.)
(21 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{forum|47|Effects & Shaders}}
[[File:Shader Options dialog.png|thumb|The (advanced) shader dialog, as seen on 2.6.0.]]
[[File:Shader Options dialog.png|thumb|The (advanced) shader dialog, as seen on 2.6.0.]]
{{Rendering}}
A '''shader''' is a set of software instructions, which is used primarily to calculate rendering effects on graphics hardware, like water reflections and shadows.
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 ==
== Shaders in FlightGear ==
[[FlightGear]] supports shaders since the switch from [[PLIB]] to [[OSG]] (FlightGear 1.9.0). FG 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.
[[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 <tt>View > Rendering Options</tt> dialog provides basic control. Setting it all the way to the left (Performance) will disable all shaders. At the right most position, all shaders will be shown at maximum quality. Most shaders are simple on/off, but some of the more demanding shaders have intermediate steps.
The Performance vs Quality slider in the <tt>View > Rendering Options</tt> 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.  


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. You can change individual shader's settings in the Shader Options dialog, which can be reached via the button in the Rendering Options dialog.
=== 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.


* [[Howto: Aircraft Reflection Shader|Aircraft reflection shader]]
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 {{readme file|effects}}.
* [[Howto: Use the normal map effect in aircraft|Normal map]]
* [[Howto: Lightmap|Lightmap]]


=== 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.<ref> {{cite web
  | url    = http://sourceforge.net/p/flightgear/mailman/message/18407232/
  | title  = <nowiki>Re: [Flightgear-devel] Shader based random trees and improved
random objects</nowiki>
  | author = <nowiki>Curtis Olson</nowiki>
  | date  = Jan 23rd, 2008
  | added  = Jan 23rd, 2008
  | script_version = 0.25
  }}
</ref>
== Gallery ==
{| cellpadding="0"
{| cellpadding="0"
|-
|-
Line 25: Line 49:
Scenery around [[TNCM]] with water reflections disabled (left) and enabled (right).
Scenery around [[TNCM]] with water reflections disabled (left) and enabled (right).
|}
|}
== References ==
<references/>


== Related content ==
== Related content ==
* [[Howto: Shader Programming in FlightGear|Shader Programming in FlightGear]]
=== Wiki articles ===
* [[Effect Framework]]
* [[Model-combined effect]]
* [[Procedural Texturing]]
* [[Project Rembrandt]]
* [[Project Rembrandt]]
* [[Howto:Shader programming in FlightGear]]
==== Older shaders ====
* [[Howto:Aircraft reflection shader]]
* [[Howto:Lightmap]]
* [[Howto:Use the normal map effect in aircraft]]
=== Source code ===
* {{fgdata file|Shaders}}
Non-inclusive list of C++ source code files:
* {{simgear file|simgear/scene/material/Effect.hxx}}
* {{simgear file|simgear/scene/material/Effect.cxx}}
[[Category: Shaders| ]]
[[Category:Menubar]]

Revision as of 17:07, 2 September 2019

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

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.[1]

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: