Compositor: Difference between revisions

Jump to navigation Jump to search
m
+-cat: Core development projects → Compositor
mNo edit summary
m (+-cat: Core development projects → Compositor)
(42 intermediate revisions by 5 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 (merged and actively maintained)
|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
|folders =  
|folders =  
* {{simgear file|simgear/scene/viewer}}
* {{flightgear file|src/Viewer}}
* {{flightgear file|src/Viewer}}
* {{simgear file|simgear/scene/viewer}}
* {{fgdata file|Compositor}}
* {{fgdata file|Compositor}}
|ticket-label = 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 <tt>$FG_ROOT/Compositor/default.xml</tt>.


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 170: Line 171:
* <tt>'''attenuation'''</tt>. Three-component vector where <code><c></code> specifies the constant factor, <code><l></code> specifies the linear factor and <code><nowiki><q></nowiki></code> specifies the quadratic factor. These factors are plugged into the OpenGL light attenuation formula [[File:Spotlight_attenuation.png]] where d is the distance of the fragment to the light source. See this [http://wiki.ogre3d.org/tiki-index.php?page=-Point+Light+Attenuation table] for a list of attenuation values based on the range of the light.
* <tt>'''attenuation'''</tt>. Three-component vector where <code><c></code> specifies the constant factor, <code><l></code> specifies the linear factor and <code><nowiki><q></nowiki></code> specifies the quadratic factor. These factors are plugged into the OpenGL light attenuation formula [[File:Spotlight_attenuation.png]] where d is the distance of the fragment to the light source. See this [http://wiki.ogre3d.org/tiki-index.php?page=-Point+Light+Attenuation table] for a list of attenuation values based on the range of the light.
* <tt>'''range-m'''</tt>. Maximum range from the light source position in meters. This value will be used by the renderers to determine if a fragment is illuminated by this source. Every fragment outside this range isn't guaranteed to be affected by the light, even if the attenuation factor isn't 0 in that particular fragment.
* <tt>'''range-m'''</tt>. Maximum range from the light source position in meters. This value will be used by the renderers to determine if a fragment is illuminated by this source. Every fragment outside this range isn't guaranteed to be affected by the light, even if the attenuation factor isn't 0 in that particular fragment.
* <tt>'''cutoff'''</tt>. Only available in <tt>spot</tt> lights. It specifies the maximum spread angle of a light source. Only values in the range 0 90 are accepted. If the angle between the direction of the light and the direction from the light to the fragment being lighted is greater than the spot cutoff angle, it won't be lit.
* <tt>'''spot-cutoff'''</tt>. Only available in <tt>spot</tt> lights. It specifies the maximum spread angle of a light source. Only values in the range 0 90 are accepted. If the angle between the direction of the light and the direction from the light to the fragment being lighted is greater than the spot cutoff angle, it won't be lit.
* <tt>'''exponent'''</tt>. Only available in <tt>spot</tt> lights. Higher spot exponents result in a more focused light source, regardless of the spot cutoff angle.
* <tt>'''spot-exponent'''</tt>. Only available in <tt>spot</tt> lights. Higher spot exponents result in a more focused light source, regardless of the spot cutoff angle.
* <tt>'''debug-color'''</tt> ('''Optional'''). Sets the color of the debug light volume. By default it's red.
* <tt>'''debug-color'''</tt> ('''Optional'''). Sets the color of the debug light volume. By default it's red.
|}
|}
Line 218: Line 219:
==== 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 polygons that intersect of the near plane of the camera (e.g. 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 230:
</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 239:
</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 247:
</syntaxhighlight>
</syntaxhighlight>


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


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


=== 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 578: Line 580:
|}
|}


==== shadow-map ====
==== csm ====
Renders the scene from a light's point of view.
Implements Cascaded Shadow Mapping by rendering the scene from a light's point of view (the Sun by default). For now it only supports directional light sources. There has to be one <tt>csm</tt> pass for each cascade.
{| class="wikitable" style="text-align: center; font-size: 85%; width: auto; table-layout: fixed;
{| class="wikitable" style="text-align: center; font-size: 85%; width: auto; table-layout: fixed;
! scope="col" | Parameter Name
! scope="col" | Parameter Name
Line 588: Line 590:
|-
|-
! scope="row"| <tt>light-name</tt>
! scope="row"| <tt>light-name</tt>
| {{No}}
| {{Yes}}
| Valid light name that exists in the scene graph
| Valid light name that exists in the scene graph
|
| <tt>FGLightSource</tt> (Sun)
| The name of the <tt>osg::LightSource</tt> to use for this shadow map
| The name of the <tt>osg::LightSource</tt> to use for this shadow map
|-
! scope="row"| <tt>render-at-night</tt>
| {{Yes}}
| bool
| true
| Whether to render the shadows at night or not
|-
|-
! 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 609:


== 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.
* Rework [[Draw masks|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.
* 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.
* 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]]
** Rendering dialog


== Known Issues ==
== Known Issues ==
 
See [https://sourceforge.net/p/flightgear/codetickets/search/?q=%21status%3AInvalid+%26%26+%21status%3ADuplicate+%26%26+%21status%3AFixed+%26%26+%21status%3ADone++%26%26+labels%3ACompositor open SourceForge tickets with the Compositor label].
* 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.
* hud.eff doesn't work under the ALS pipeline.
* Spotlights sometimes disappear at certain view angles.


== References ==
== References ==
Line 621: Line 628:
== 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 637:
* {{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:Compositor]]

Navigation menu