Compositor: Difference between revisions

Jump to navigation Jump to search
1,350 bytes added ,  13 May 2020
no edit summary
mNo edit summary
No edit summary
(32 intermediate revisions by 4 users not shown)
Line 1: Line 1:
{{Template:Non-stable|version=2019.2|build_flags=-DENABLE_COMPOSITOR=ON|progress=100}}
{{forum|47|Effects & Shaders}}
{{forum|47|Effects & Shaders}}


Line 9: Line 5:
|name        = Compositor Framework
|name        = Compositor Framework
|started    = 01/2018 (Available since FlightGear 2019.2)
|started    = 01/2018 (Available since FlightGear 2019.2)
|description = Dynamic rendering pipeline configured via the property tree and XML
|description = Dynamic rendering pipeline configured via the [[Property tree]] and [[PropertyList XML File|XML]]
|status      = Stable
|status      = Stable (merged and actively maintained)
|developers  = Fernando García Liñán <ref>https://sourceforge.net/u/fgarlin/profile/</ref>
|developers  = Fernando García Liñán <ref>https://sourceforge.net/u/fgarlin/profile/</ref>
|changelog = https://sourceforge.net/u/fgarlin/profile/feed.rss
|changelog = https://sourceforge.net/u/fgarlin/profile/feed.rss
Line 18: Line 14:
* {{fgdata file|Compositor}}
* {{fgdata file|Compositor}}
}}
}}


The '''Compositor''' aims to bring multi-pass rendering to FlightGear. It encapsulates a rendering pipeline and exposes its parameters to a [[Property Tree]] interface. At startup, FlightGear reads the pipeline definition file for each physical viewport defined on the [[Howto:Configure camera view windows|CameraGroup settings]]. If no Compositor file is specified for a physical camera, the one given by the <code>--compositor=</code> startup command will be used. If such startup option is not used either, FlightGear will look for a valid Compositor file in $FG_ROOT/Compositor/default.xml
The '''Compositor''' aims to bring multi-pass rendering to FlightGear. It encapsulates a rendering pipeline and exposes its parameters to a [[Property Tree]] interface. At startup, FlightGear reads the pipeline definition file for each physical viewport defined on the [[Howto:Configure camera view windows|CameraGroup settings]]. If no Compositor file is specified for a physical camera, the one given by the <code>--compositor=</code> startup command will be used. If such startup option is not used either, FlightGear will look for a valid Compositor file in $FG_ROOT/Compositor/default.xml


The Compositor introduces a new dedicated fgdata directory for new/custom rendering pipelines: {{Fgdata file|Compositor}}.
The Compositor introduces a new dedicated fgdata directory for new/custom rendering pipelines: {{Fgdata file|Compositor}}.
The framework is now included in the latest stable release ([[Changelog_2020.1|FlightGear v2020.1]]) as a separate binary. Developers are encouraged to test the Compositor with their personal projects and report any breakages. Also keep in mind that some features might not work/look as intended - see [[#Known Issues|Known Issues]].


== Background ==
== Background ==
Line 218: Line 218:
==== Rendering correct depth ====
==== Rendering correct depth ====


The ALS pipeline uses a logarithmic depth buffer. This is accomplished by writing to <tt>gl_FragDepth</tt> in the fragment shader or by modifying <tt>gl_Position.z</tt> in the vertex shader. The 2nd option is faster but doesn't work for very large polygons (like the terrain), so you should use it by default unless visual bugs appear.
The ALS pipeline uses a logarithmic depth buffer. This is accomplished by writing to <tt>gl_FragDepth</tt> in the fragment shader or by modifying <tt>gl_Position.z</tt> in the vertex shader. The second option is faster but doesn't work for polygons that intersect the near plane of the camera (e.g. terrain), so you should use it by default unless visual bugs appear.


* '''1st option'''.
* '''1st option'''
Add the following to the vertex shader:
Add the following to the vertex shader:
<syntaxhighlight lang="cplusplus">
<syntaxhighlight lang="glsl">
uniform float fg_Fcoef;
uniform float fg_Fcoef;
[...]
[...]
Line 229: Line 229:
</syntaxhighlight>
</syntaxhighlight>


* '''2nd option'''.
* '''2nd option'''
Add the following to the vertex shader:
Add the following to the vertex shader:
<syntaxhighlight lang="cplusplus">
<syntaxhighlight lang="glsl">
varying float flogz;
varying float flogz;
[...]
[...]
Line 238: Line 238:
</syntaxhighlight>
</syntaxhighlight>
And the following to the fragment shader:
And the following to the fragment shader:
<syntaxhighlight lang="cplusplus">
<syntaxhighlight lang="glsl">
uniform float fg_Fcoef;
uniform float fg_Fcoef;
varying float flogz;
varying float flogz;
Line 246: Line 246:
</syntaxhighlight>
</syntaxhighlight>


== Technical notes of each pipeline ==
== Pipeline technical notes ==


=== Default (Low-Spec) ===
=== Default (Low-Spec) ===
Line 255: Line 255:


=== ALS ===
=== ALS ===
{{See also|ALS technical notes}}


The ALS pipeline tries to bring multipass rendering to the current ALS framework, effectively combining the best from ALS and Project Rembrandt.
The ALS pipeline tries to bring multipass rendering to the current ALS framework, effectively combining the best from ALS and Project Rembrandt.
Line 595: Line 596:
! scope="row"| <tt>near-m, far-m</tt>
! scope="row"| <tt>near-m, far-m</tt>
| {{No}}
| {{No}}
| Valid Effect file
| float (meters)
|
|
| They specify the depth range of the shadow map
| They specify the depth range of the shadow map
Line 601: Line 602:


== TODO ==
== TODO ==
{{See also|Post FlightGear 2020.2 LTS changes}}


* Bring back distortion correction.
* Bring back distortion correction.
* Some kind of versioning system to be able to make breaking changes in the future if/when the compositor is updated in any significant way, without people having to manually update their configs.
* Some kind of versioning system to be able to make breaking changes in the future if/when the compositor is updated in any significant way, without people having to manually update their configs.
* Bring back [[Howto:Canvas View Camera Element|Canvas integration]] so aircraft devs have access to the rendering pipeline. This allows to render exterior views in cockpit displays etc.
* Rework node masks ({{simgear file|simgear/scene/util/RenderConstants.hxx}}). Each node type should have its own node mask bit, e.g. trees should only have <tt>TREE_BIT</tt> enabled, the main aircraft should only have <tt>AIRCRAFT_BIT</tt> enabled etc. This allows the Compositor cameras to properly filter scene graph nodes based on the cull mask. Shadow cameras can then choose what geometry they render dynamically.
* Automatically calculate light source attenuation based on radius and radius based on attenuation.
* Automatically calculate light source attenuation based on radius and radius based on attenuation.
* Add clustered shading to every Effect as a separate technique.
* Proper shader quality settings for both low-spec and ALS pipelines.
* Launcher and UI:
** [[Integrated Qt5 Launcher]]
** [[About dialog]]
** Rendering dialog
* Separate [[Developing using CMake|cmake build target (binary)]] for a [http://download.flightgear.org/builds/nightly/ "preview" binary] with the [[Compositor]] enabled to get more testing/feedback and contributions from early-adopters <ref>https://sourceforge.net/p/flightgear/mailman/message/36977221/</ref> <ref>https://sourceforge.net/p/flightgear/mailman/message/36954518/</ref> <ref>https://sourceforge.net/p/flightgear/mailman/message/36679177/</ref> <ref>https://sourceforge.net/p/flightgear/mailman/message/37000737/</ref> {{Progressbar|90}}


== Known Issues ==
== Known Issues ==


* Setting a buffer scale factor different from 1.0 and rendering to it might not scale the splash screen correctly.
* Setting a buffer scale factor different from 1.0 and rendering to it might not scale the splash screen correctly.
* Clustered shading crashes FG if compiled under OSG 3.6. This is related to osg::TextureBuffer changing definition from OSG 3.4 to OSG 3.6 (Images vs BufferData).
* [[Earthview]] doesn't work.
* There is some kind of moiré pattern at certain sunlight angles (specially at dusk/dawn). Shadow acne.
* There is some kind of moiré pattern at certain sunlight angles (specially at dusk/dawn). Shadow acne.
* hud.eff doesn't work under the ALS pipeline.
* Spotlights sometimes disappear at certain view angles.
* Spotlights sometimes disappear at certain view angles.
* Some effects might not be ported to ALS completely. Feel free to play around with the shader settings to get something that works.
* CRT effect as a default Effect. Look into reflect.eff
* osgText doesn't work. See the 777 displays as well as some EC135 instruments. osgText doesn't use Effects so they are being rendered with incorrect depth.
* Reloading shaders doesn't work.
* Random buildings don't use correct depth.


== References ==
== References ==
Line 621: Line 632:
== Related content ==
== Related content ==
=== Wiki articles ===
=== Wiki articles ===
* [[Canvas View Camera Element]]
* [[CompositeViewer Support]]
* [[Uniform Buffer Objects]]
* [[Uniform Buffer Objects]]
* [[CompositeViewer Support]]
* [[FlightGear CIGI Support (Common Image Generator Interface)]]
* [[FlightGear CIGI Support (Common Image Generator Interface)]]


Line 629: Line 641:
* {{forum link|t=35095|text=Clustered Forward Rendering}} (12/2018)
* {{forum link|t=35095|text=Clustered Forward Rendering}} (12/2018)
* {{forum link|t=33045|text=Getting started with RTT}}
* {{forum link|t=33045|text=Getting started with RTT}}
* {{forum link|t=32846|text=Canvas::View Development}}
* {{forum link|t=23929|text=Gear View in Cockpit}}
* {{forum link|t=20057|text=Rear-View mirror}}
* {{forum link|t=18905|text=Progress on synthetic terrain}}
* {{forum link|t=17184|text=Instruments with heightmaps}}


[[Category:Core development projects]]
[[Category:Core development projects]]
342

edits

Navigation menu