HDR Pipeline: Difference between revisions

Jump to navigation Jump to search
3,399 bytes removed ,  24 July 2021
no edit summary
m (→‎Status: https://sourceforge.net/p/flightgear/mailman/message/37325148/)
No edit summary
Line 1: Line 1:
{{Main article|Compositor}}
{{Main article|Compositor}}


{{Experimental|disclaimer=Fernando does not provide any guarantees whatsoever about if or when the HDR pipeline will be "production-ready" though, so the recommendation for aircraft devs willing to update their 3D models would be to wait for a bit (to the end of the year or when 2021.x comes out) to see if it's worth the effort.<ref>https://sourceforge.net/p/flightgear/mailman/message/37260910/</ref>}}
{{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 8:
<!--[[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-preview-04-2021.png
|image      = HDR-pipeline-c172p-sky.png
|name        = HDR Pipeline
|name        = HDR Pipeline
|started    = 04/2021 (early proof-of-concept)
|started    = 04/2021
|description =  
|description = A modern rendering pipeline that targets relatively powerful systems
|status      =  
|status      = Active
|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}}
* {{fgdata file|Compositor/HDR}}
* {{flightgear file|src/Viewer}}
* {{fgdata file|Effects/HDR}}
* {{fgdata file|Compositor}}
* {{fgdata file|Shaders/HDR}}
-->
 
}}
}}


 
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>.
[[File:Experimental-HDR-pipeline-preview-04-2021.png|thumb|Unfortunately trying to load any scenery crashes FG instantly. Isuspect it's due to the core/compatibility profile issues I describedearlier.<ref>https://sourceforge.net/p/flightgear/mailman/message/37262097/</ref>]]
 
{{Stub}}


== Background ==
== Background ==
After getting convinced to pursue this by some of the core devs, for
the past couple of days Fernando has been working on a new Compositor
pipeline. It's still very much experimental (trying to load any
scenery crashes FG!), but it's somewhat working under very special
circumstances.


This is currently using the most popular PBR model for real time
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.
applications. This particular BRDF has also been recommended by the
glTF spec, so it shouldn't be too bad. :)
See https://github.com/KhronosGroup/glTF/blob/master/specification/2.0/README.md#appendix-b-brdf-implementation


== Status ==
== Status ==
'''Last updated: 07/2021'''
'''Last updated: 07/2021'''


Fernando's long term project from now on will be the "HDR" pipeline, which will be strictly OpenGL 4.2 compatible.<ref>https://sourceforge.net/p/flightgear/mailman/message/37148595/</ref>
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.
 
Since everything on this pipeline relies on the core profile, I'm
basically waiting for the move to happen so I can do the depth
reversal trick.<ref>https://sourceforge.net/p/flightgear/mailman/message/37260288/</ref>
 
 
Again, this is all *very* experimental for now. A lot of things are broken because I'm forcing the use of core profile shaders (thanks
Nvidia for letting me do this under a compatibility profile context!), so this is nowhere near usable. Still, I'm planning to release this to next in the next week or so because it doesn't break anything: everything is in FGData and on a different compositor pipeline, so
Classic and the C++ core are completely unaffected. In general the move to the core profile will probably fix a lot of the issues that
this pipeline currently has.<ref>https://sourceforge.net/p/flightgear/mailman/message/37260282/</ref>
 
 
The HDR pipeline will have bloom enabled all the time. Fernando won't be adding new features to ALS, so if someone doesn't like bloom they can use ALS.<ref>https://sourceforge.net/p/flightgear/mailman/message/37287369/</ref>
 
As of 07/2021, Fernando pushed a big commit to fgdata that implements the 1st version of the HDR pipeline. It's nowhere near usable (as I mentioned in some of Fernando's earlier mails on the subject), but it's a first step.
 
The main thing he'd like to check is that the Classic pipeline still works as it should and that he didn't introduce any regressions. For
those running next please let him know if there is anything different.
 
And for those adventurous enough to test the HDR pipeline (just for curiosity purposes though, it's too early for bug reports now), you can enable it by running FG with
 
 
<code>--compositor=Compositor/HDR/hdr</code>
 
You need to start in the middle of the ocean as attempting to render any terrain will crash FG. Fernando's recommendation would be to just remove your --fg-scenery parameters and to start at any aircraft carrier so you have some solid ground to stand on.<ref>https://sourceforge.net/p/flightgear/mailman/message/37325148/</ref>
 
Actually, WS 3.0 works with the HDR pipeline. WS 3.0 seems to work perfectly with GL 3 features right out of
the box. Fernando pushed a small commit to fgdata that adds some placeholder shaders.<ref>https://sourceforge.net/p/flightgear/mailman/message/37325154/</ref>
 
== Objective ==
For now, the main goal is definitely increasing motivation to get on with moving to [[OpenGL#Status|Core profile]].<ref>https://sourceforge.net/p/flightgear/mailman/message/37260288/</ref>
 
== Requirements ==
No compute shaders required, so Mac should work fine as long as we are
using at least GL 3.3. :) <ref>https://sourceforge.net/p/flightgear/mailman/message/37260288/</ref>


== Ramifications ==
== Ramifications ==
Line 116: Line 67:
cubemap.<ref>https://sourceforge.net/p/flightgear/mailman/message/37260296/</ref>
cubemap.<ref>https://sourceforge.net/p/flightgear/mailman/message/37260296/</ref>


== Implementation Details ==
== Implementation details ==


A few implementation details for the curious:
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.


* It's a deferred renderer. Most post-processing effects integrate very nicely with a deferred pipeline, and modern forward rendering techniques usually require a depth prepass. I haven't found an easy way to share culling results between passes in OSG so that the main forward pass reuses the culling information gathered during the depth prepass, so I preferred to just go deferred.
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.


* Entirely PBR-based. Old/legacy materials try to "translate" from the legacy ambient/diffuse/specular model to PBR metalness/roughness. Still, the classic pipeline isn't going anywhere. If a particular aircraft is very broken under this pipeline, the user is free to use ALS/classic.
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.


* HDR and eye adaptation. Lighting values are written to HDR buffers and then tone mapped based on a exposure setting. This 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. Maybe the pilot is wearing sunglasses? :)
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.


* Real time environment mapping. At the start of the frame we render to a cubemap and subsequent passes use this information to evaluate indirect lighting.
Near the end of the rendering process, miscellaneous post-processing passes like FXAA and ambient occlusion are used.


* Miscellaneous post-processing passes like ambient occlusions, FXAA,bloom, etc.
== Roadmap ==
<ref>https://sourceforge.net/p/flightgear/mailman/message/37260282/</ref>


== Roadmap ==
* Support PBR through glTF models.
For now, the initial plan is to only support PBR through glTF models, and glTF
does support using numerical values for the whole material instead of
a texture.<ref>https://sourceforge.net/p/flightgear/mailman/message/37262898/</ref>


== Gallery ==
== Gallery ==
Here are some screenshots of the c172p on the Nimitz. Aircraft carriers are a nice substitute to actual terrain :)


<gallery>
<gallery>
Early-HDR-Pipeline-Preview-2020-c172-cockpit.png|Early-HDR-Pipeline-Preview-2020
Early-HDR-Pipeline-Preview-2020-c172-cockpit.png
HDR-Pipeline-Preview-wing.png|Early Compositor preview (HDR Pipeline)
HDR-Pipeline-Preview-wing.png
C172p-cockpit-HDR-pipeline-preview.png|c172p cockpit (experimental HDR preview)
C172p-cockpit-HDR-pipeline-preview.png
HDR-sunset-preview-2020.png|sunset showing the experimental HDR pipeline
HDR-sunset-preview-2020.png
HDR-pipeline-c172p-sky2.png
</gallery>
</gallery>
== Known Issues ==
Unfortunately trying to load any scenery crashes FG instantly. I
suspect it's due to the core/compatibility profile issues I described
earlier.<ref>https://sourceforge.net/p/flightgear/mailman/message/37262097/</ref>
Mac only supports up to OpenGL 4.1, which doesn't have compute
shaders. Compute functionality is only accessible through Metal (or
MoltenVK as you mentioned).
The advantages to compute shaders are many, but again we can't use
them easily. In an ideal world Mac offers proper support for OpenGL
and we don't have to even switch to VulkanSceneGraph, but that's not
the case unfortunately. <ref>https://sourceforge.net/p/flightgear/mailman/message/37262898/</ref>


== References ==
== References ==
354

edits

Navigation menu