HDR Pipeline: Difference between revisions

Jump to navigation Jump to search
1,081 bytes removed ,  3 April 2023
no edit summary
No edit summary
No edit summary
Line 1: Line 1:
{{Main article|Compositor}}
{{Main article|Compositor}}
{{Experimental|disclaimer=Aircraft developers are not yet encouraged to update their models to use PBR as the HDR pipeline will not be production-ready for some time.<ref>https://sourceforge.net/p/flightgear/mailman/message/37260910/</ref>}}


{{forum|47|Effects & Shaders}}
{{forum|47|Effects & Shaders}}
Line 8: Line 6:
<!--[[File:HDR-pipeline-preview-04-2021.png|thumb|HDR Pipeline preview screen shot]]
<!--[[File:HDR-pipeline-preview-04-2021.png|thumb|HDR Pipeline preview screen shot]]
-->
-->
|image      = HDR pipeline c172p over Edinburgh 2.png
|name        = HDR Pipeline
|name        = HDR Pipeline
|started    = 04/2021
|started    = 04/2021
|description = A modern rendering pipeline that targets relatively powerful systems
|description = A modern rendering pipeline that targets relatively powerful systems
|status      = Active
|status      = In-development
|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 21: Line 18:
}}
}}


The '''HDR pipeline''' is a [[Compositor]]-based rendering pipeline that attempts to bring modern rendering techniques to FlightGear, namely high dynamic range (HDR) and physically based rendering (PBR). It is implemented entirely in FGData using XML for the Compositor pipeline definition and [[Effects]], and GLSL for shaders. As of 07/2021, the HDR pipeline is not yet usable for normal flying, but it can be enabled with the command line argument <code>--compositor=Compositor/HDR/hdr</code>.
The '''HDR Pipeline''' is a [[Compositor]]-based rendering pipeline that attempts to bring modern rendering techniques to FlightGear, namely [https://en.wikipedia.org/wiki/High_dynamic_range high dynamic range (HDR)] and [https://en.wikipedia.org/wiki/Physically_based_rendering physically based rendering (PBR)]. It is implemented entirely in [[$FG_ROOT]] using XML for the Compositor pipeline definition and [[Effects]], and GLSL for shaders. The pipeline can be enabled with the command line argument <code>--compositor=Compositor/HDR/hdr</code>.


== Background ==
== Background ==


The [[Classic pipeline]] still relies on legacy OpenGL features, so rather than improving or reworking it, the idea of creating an entirely separate rendering pipeline from scratch started taking shape. The [[Compositor]] played the biggest role in enabling this effort as it allows the creation of new rendering pipelines entirely in FGData space without any C++ changes whatsoever, greatly reducing the amount of work that had to be done and making the iterative process of testing and debugging much more comfortable and faster.
The [[Classic pipeline]] relies on legacy OpenGL features, so rather than improving or reworking it, the idea of creating an entirely separate rendering pipeline from scratch started taking shape. The [[Compositor]] played the biggest role in enabling this effort as it allows the creation of new rendering pipelines entirely in FGData space without any C++ changes whatsoever, greatly reducing the amount of work that had to be done and making the iterative process of testing and debugging much faster.


== Status ==
== Status ==
'''Last updated: 07/2021'''
'''Last updated: 04/2023'''
 
The HDR pipeline is not yet ready for day-to-day flying, but it is currently available on <tt>next</tt> for anyone adventurous enough to try it. Expect a lot of breakage though.
 
== PBR and glTF ==
 
This pipeline introduces a PBR Effect ({{fgdata file|Effects/model-pbr.eff}}). This Effect can be used as usual by adding an <tt><effect></tt> tag in the model XML and configuring it like you would configure model-combined. However, the recommended way to use PBR is through the [[glTF]] file format.


== Implementation details ==
The HDR pipeline is more or less stable, and is currently available on <tt>next</tt> for anyone adventurous enough to try it. The main issue is that [[PUI]] is not compatible, so there is no in-sim GUI. You will need to configure everything beforehand using the [[FlightGear Qt launcher|launcher]], [[command line options]], or with external tools like [[Phi]].


The HDR pipeline implements a deferred rendering pipeline. Instead of computing the lighting right away, the pipeline writes information about the geometry (normals, materials...) to a series of textures that are later used to light the scene on a full-screen pass. This is identical to how [[Project Rembrandt|Rembrandt]] worked. The main motivation behind implementing a deferred renderer is to keep forward passes to a minimum. FlightGear's scene graph is not very well optimized, so traversing it as few times as possible is always going to yield better performance. The alternative was to implement a modern hybrid forward renderer with a depth pre-pass, but we would be traversing the scene graph twice in this case.
== Notes for aircraft developers ==


The pipeline is designed to only work with PBR values, so both materials and lighting are internally assumed to be based on real-life magnitudes. Old/legacy materials try to "translate" from the legacy ambient/diffuse/specular model to PBR metalness/roughness. This may result in some incorrect lighting on aircraft that are completely unaware of the HDR pipeline though.
The HDR pipeline handles lighting in a completely different manner compared to [[Atmospheric light scattering|ALS]]. The pipeline will attempt to "translate" classic Effects so they display correctly by making some assumptions. These assumptions are not always correct, so your aircraft might not display correctly under the HDR pipeline. In this section we describe some steps you can follow to leverage all the power of the HDR pipeline.


All lighting computations are done in HDR space, i.e. colour values are not clamped to the [0,1] range until the end of the rendering process. HDR colour values are transformed into LDR values that can be displayed on a monitor by tone mapping. A exposure parameter is calculated automatically based on the average scene luminance (like a camera on the Auto setting would do), but there is the possibility of lowering/increasing the exposure manually if the user feels like the scene is too bright/dark.
=== PBR and glTF ===


To allow truly PBR-based materials, real time environment mapping is used. At the start of the frame we render to a cubemap and subsequent passes use this information to evaluate indirect lighting.
Physically-based rendering (PBR) refers to the concept of using realistic shading/lighting models along with measured surface values to accurately represent real-world materials. See this [https://marmoset.co/posts/physically-based-rendering-and-you-can-too/ webpage] for an extensive introduction to PBR and how you can create physically-based assets for your aircraft.


Near the end of the rendering process, miscellaneous post-processing passes like FXAA and ambient occlusion are used.
This pipeline introduces a PBR Effect ({{fgdata file|Effects/model-pbr.eff}}). However, you don't need to assign this Effect manually. You can export your model from Blender to the [[glTF]] format and use it directly. The Blender exporter will take care of exporting the necessary textures and the FlightGear parser will automatically assign the PBR Effect to your model. Your model XML file would contain something like this:


== Gallery ==
<syntaxhighlight lang="xml">
<?xml version="1.0" encoding="utf-8"?>
<PropertyList>
    <path>my-aircraft.gltf</path>
    [...]
</PropertyList>
</syntaxhighlight>


<gallery widths="250" heights="250" perrow="5">
Although '''not recommended''', the PBR effect can be assigned as usual by adding an <tt><effect></tt> tag in the model XML and configuring it like you would configure [[Model-combined effect|model-combined]].
File:Early-HDR-Pipeline-Preview-2020-c172-cockpit.png
File:HDR-Pipeline-Preview-wing.png
File:HDR-pipeline-c172p-sky2.png
File:HDR pipeline c172p over Edinburgh.png
File:HDR-Earth-atmosphere-noon.png
File:HDR-Earth-atmosphere-sunrise.png
File:C172-HDR Pipeline Preview2.png
File:B747-HDR Prewiew2.png
File:B747-HDR Preview1.png
</gallery>


== References ==
== References ==
354

edits

Navigation menu