Compositor: Difference between revisions

Jump to navigation Jump to search
4,501 bytes added ,  7 November 2019
no edit summary
No edit summary
(5 intermediate revisions by the same user not shown)
Line 47: Line 47:
   }}</ref>
   }}</ref>


Zan's original patches can still be found in his newcameras branches which allow the user to define the rendering pipeline in preferences.xml:
Zan's original patches can still be found in his newcameras branches which allow the user to define the rendering pipeline in preferences.xml: [https://gitorious.org/fg/zans-flightgear?p=fg:zans-flightgear.git;a=shortlog;h=refs/heads/newcameras FlightGear], [https://gitorious.org/fg/zans-simgear?p=fg:zans-simgear.git;a=log;h=refs/heads/newcameras SimGear].
 
* [https://gitorious.org/fg/zans-flightgear?p=fg:zans-flightgear.git;a=shortlog;h=refs/heads/newcameras FlightGear]
* [https://gitorious.org/fg/zans-simgear?p=fg:zans-simgear.git;a=log;h=refs/heads/newcameras SimGear]


At that point, it didn't have everything Rembrandt's pipeline needs, but most likely could be easily enhanced to support those things.  
At that point, it didn't have everything Rembrandt's pipeline needs, but most likely could be easily enhanced to support those things.  
Line 80: Line 77:


Currently the Compositor can only be enabled at compile time via the <code>-DENABLE_COMPOSITOR=ON</code> CMake flag in FlightGear. SimGear doesn't require any extra parameters. Once you have a binary with the Compositor enabled and you run it, you will be presented with the default rendering pipeline. At the time of writing, this is the low spec rendering pipeline. If you want to try the ALS pipeline, start FlightGear with the command line argument: <code>--compositor=Compositor/ALS/als</code>
Currently the Compositor can only be enabled at compile time via the <code>-DENABLE_COMPOSITOR=ON</code> CMake flag in FlightGear. SimGear doesn't require any extra parameters. Once you have a binary with the Compositor enabled and you run it, you will be presented with the default rendering pipeline. At the time of writing, this is the low spec rendering pipeline. If you want to try the ALS pipeline, start FlightGear with the command line argument: <code>--compositor=Compositor/ALS/als</code>
== Notes for aircraft developers ==
=== Lights ===
The Compositor introduces a new way of defining lights that is renderer agnostic, so every rendering pipeline will be able to access the lights that have been implemented like this. As of 2019/11, the only pipeline that supports dynamic lights is the ALS pipeline. The resulting light volumes can be visualized for debugging purposes by setting the property <tt>/sim/debug/show-light-volumes</tt> to true.
{|cellpadding=20|
|valign=top style="width: 20%;"|
<syntaxhighlight lang="xml">
<light>
  <name>my-spotlight</name>
  <type>spot</type>
  <position>
    <x-m>-7.7476</x-m>
    <y-m>0</y-m>
    <z-m>-1.7990</z-m>
  </position>
  <direction>
    <x>-1.0</x>
    <y>0</y>
    <z>-0.013</z>
  </direction>
  <ambient>
    <r>0.03</r>
    <g>0.03</g>
    <b>0.03</b>
    <a>1</a>
  </ambient>
  <diffuse>
    <r>0.95</r>
    <g>0.9</g>
    <b>0.9</b>
    <a>1</a>
  </diffuse>
  <specular>
    <r>0.95</r>
    <g>0.9</g>
    <b>0.9</b>
    <a>1</a>
  </specular>
  <attenuation>
    <c>1.0</c>
    <l>0.09</l>
    <q>0.032</q>
  </attenuation>
  <exponent>5</exponent>
  <cutoff>40</cutoff>
  <range-m>50</range-m>
</light>
</syntaxhighlight>
|valign=top style="width: 80%;"|
* <tt>'''name'''</tt>. An <code><animation></code> will be able to reference the light by this name. Most animations will work as expected (rotate, translate, spin etc).
* <tt>'''type'''</tt>. <tt>spot</tt> or <tt>point</tt>.
* <tt>'''position'''</tt>. The position of the light source in model space and in meters.
* <tt>'''direction'''</tt>. Only available in <tt>spot</tt> lights. It indicates the direction of the spotlight. This parameter can be specified in three different ways:
{| class="wikitable" style="border: 1px solid darkgray;"
! scope="col" style="width:33%;" |Direction vector
! scope="col" style="width:33%;" |Look-at point
! scope="col" style="width:33%;" |Rotation angles
|-
| style="padding: 10px" | A vector in model space that specifies the direction. Doesn't have to be normalized.
<syntaxhighlight lang="xml">
<x>-1.0</x>
<y>0</y>
<z>-0.013</z>
</syntaxhighlight>
| style="padding: 10px" | The spotlight will calculate its direction by looking at this position from the light position. The point is in model space and in meters.
<syntaxhighlight lang="xml">
<lookat-x-m>-8.031</lookat-x-m>
<lookat-y-m>0</lookat-y-m>
<lookat-z-m>-2</lookat-z-m>
</syntaxhighlight>
| style="padding: 10px" | A three angle rotation in degrees that rotates the spotlight around the three axes. A 0 degree angle in all axes makes the spotlight point downwards (negative Z).
<syntaxhighlight lang="xml">
<pitch-deg>90</pitch-deg>
<roll-deg>0</roll-deg>
<heading-deg>0</heading-deg>
</syntaxhighlight>
|}
* <tt>'''ambient'''</tt>, <tt>'''diffuse'''</tt> and <tt>'''specular'''</tt>. Four-component vectors that specify the light color.
* <tt>'''attenuation'''</tt> ('''Optional'''). 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. If no attenuation has been specified, the inverse-square law will be used. 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> ('''Optional'''). 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. If no value has been specified, it will be calculated automatically based on the attenuation.
* <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>'''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.
|}


== Pipelines ==
== Pipelines ==
Line 282: Line 366:


* Bring back distortion correction.
* Bring back distortion correction.
* Add spotlight support to clustered shading.
* 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 Canvas integration so aircraft devs have access to the rendering pipeline. This allows to render exterior views in cockpit displays etc.
* Bring back Canvas integration so aircraft devs have access to the rendering pipeline. This allows to render exterior views in cockpit displays etc.
343

edits

Navigation menu