Uniform Buffer Objects: Difference between revisions

From FlightGear wiki
Jump to navigation Jump to search
Line 1: Line 1:
{{Stub}}
{{Stub}}
{{Rendering}}
{{Rendering}}
{{Affected by Compositor}}


== Background ==
== Background ==

Revision as of 13:53, 10 April 2020

This article is a stub. You can help the wiki by expanding it.
IMPORTANT: Some, and possibly most, of the features/ideas discussed below are likely to be affected, and possibly even deprecated, by the ongoing work on providing a property tree-configurable rendering pipeline accessible via XML using the new Compositor system available since FlightGear 2020.3 (11/2020): The main rendering pipeline (on next at least) is now the Compositor using ALS. The "classical renderer" and "Project Rembrandt" have been superseded. From the perspective of creating regional material definitions, you can just develop against ALS and you will be fine.[1]

Please see: Post FlightGear 2020.2 LTS changes for further information You are advised not to start working on anything directly related to this without first discussing/coordinating your ideas with other FlightGear contributors using the FlightGear developers mailing list or the Effects & Shaders subforum This is a link to the FlightGear forum.. talk page.

Compositor logo.png

Background

It would be nice if the Effects framework had a way to load arbitrary textures and make them available to effects.[2]

you can't pass arrays through the effect framework, so if you want to extend it, you have to write every extension explicitly anyway, arrays have no advantage. The idea is good, and I looked for a good solution when making the cloud shadows, but there is none, every array element has to be handed over separately.[3]

It does not seem possible now to directly expose an array, but I think it should be possible to use an array in the shader code and use eg. coordinates[3] as name in the effect file.[4]


different strategies doing this: for instance generating a shadow map not via a pass on the GPU as Rembrandt does but procedurally on the CPU from meta info. Now I'm generating it procedurally on the GPU from meta info and just need to pass the meta info. In the current state, I'm passing 32 uniforms to encode position information, which seems to work without significant loss of performance and gives a decent visual impression. It might still grow a bit more, but my current thinking is to try to get priority for everything in the field of view to get more bang for the buck. A texture seems a bit of an overkill for such a number, especially given that we run out of texture units in some effects already (the model shader is using 8 texture units already). [5]


If you want to pass substantial amounts of data, it is currently recommended to use a texture (with filtering disabled, probably) to pass the info. Since we don’t have much chance of using the ‘correct’ solution (UBOs) in the near future.[6]

The main challenge seems to be using a standard alignment/packing format for the passed data: https://www.opengl.org/wiki/Uniform_Buffer_Object#Layout_queries And it seems that even Tim Moore was originally planning on supporting UBOs: http://markmail.org/message/nk3dswtmkcrn2j4m http://forum.openscenegraph.org/viewtopic.php?t=12732[7]

if/when the Canvas system is sufficiently integrated with the effects/shader system, any camera (MFD/scenery, offscreen or not) can trivially make use of this functionality without requiring tons of custom code - at the mere cost of adding the corresponding Canvas Elements to the Canvas::Group registry, which would also work for slave-cameras (or those using OSG CompositeViewer)[8]

References

References
  1. https://sourceforge.net/p/flightgear/mailman/message/37758886/
  2. Tim Moore  (Tue, 24 Jul 2012 22:38:35 -0700).  Re: [Flightgear-devel] Passing arrays to a shader .
  3. Thorsten  (Oct 7th, 2014).  Re: ALS landing lights .
  4. Thomas Geymayer  (Mar 6th, 2014).  Re: [Flightgear-devel] Passing arrays to a shader .
  5. Renk Thorsten  (Mar 7th, 2014).  Re: [Flightgear-devel] Passing arrays to a shader .
  6. James Turner  (Mar 7th, 2014).  Re: [Flightgear-devel] Passing arrays to a shader .
  7. Hooray  (Oct 7th, 2014).  Re: ALS landing lights .
  8. Hooray  (Jan 25th, 2017).  Re: Creating a new uniform in C++ .