Uniform Buffer Objects

From FlightGear wiki
Revision as of 14:39, 2 September 2017 by Hooray (talk | contribs) (→‎Background)
Jump to navigation Jump to search
This article is a stub. You can help the wiki by expanding it.

Background

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

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.[2]

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.[3]


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). [4]


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.[5]

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[6]

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)[7]

References

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