Board index FlightGear Development Canvas

Improved camera configuration options

Canvas is FlightGear's new fully scriptable 2D drawing system that will allow you to easily create new instruments, HUDs and even GUI dialogs and custom GUI widgets, without having to write C++ code and without having to rebuild FlightGear.

Improved camera configuration options

Postby Zan » Fri Oct 14, 2011 7:05 am

Hi all.

I've been working on improving the camera configuration system in FG. It is almost done, but needs some cleanup before I can put up a merge request. Here is the list of new features:
  • Support for setting the rendering order of cameras
  • Can set the clear mask (color, depth and stencil buffer separately)
  • Can set the texture format in render-to-texture (which already was there, but had almost no use before this update), rgb, rgba, depth or depth-stencil at the moment.
  • Can set the texture type (normalized 2d or rectangle)
  • Support for multiple render targets, via just specifying multiple texture targets. This needs modification to shaders though, but works.
  • Can set whether camera uses scene data or a custom model (e.g. screen aligned quad)
  • Can bind render target textures to texture units for rendering to screen. (In the future should allow using these in models by specifying the texture name...)

Maybe I forgot something, but those are the main points. And what this allows:
  • Rendering a different view to texture, then binding that to a texture unit to be used in a model on another camera:
    Image
    (Rear view is rendered first, then cube has an effect/shader which draws that view on all sides of the cube. The view updates when moving, so could be used in aircraft models etc.)
  • "Real" reflections on aircraft. Might work with some tuning?
  • Distorted views etc. (which are used in simulators with multiple projectors) without the need to change source code and compile for editing.
  • Post processing effects, here is an example of blue filtering the scene. Everything is rendered to texture, and then a filter is applied to that texture in post processing:
    Image
  • Chaining of post processing effects.

Note though that the camera settings need to be done in preferences.xml, so an aircraft model cannot define any new views. Also, the camera positions are relative to the current view (i.e. cockpit, chase etc) and cannot be fixed on the aircraft itself. And rendering to texture while using that texture in the scene has undefined result.

I'm trying to expand this so that cameras could select which parts of scene they render. For example opaque objects to a texture, then do something with it, render to screen and then render transparent objects. And after that some post processing, like bloom, to whole scene maybe. Or deferred lighting allowing multiple lights...

Maybe someone finds this interesting. I'm not sure if this should be under "Effects and Shaders" though...

Zan
Zan
 
Posts: 121
Joined: Tue Oct 20, 2009 10:28 am

Re: Improved camera configuration options

Postby HHS » Fri Oct 14, 2011 11:14 am

Great work! :D

But there are some things I don't understand yet and would like to know:

-Rendering a different view to texture, then binding that to a texture unit to be used in a model on another camera:
(Rear view is rendered first, then cube has an effect/shader which draws that view on all sides of the cube. The view updates when moving, so could be used in aircraft models etc.)
-"Real" reflections on aircraft. Might work with some tuning?


vs.

Note though that the camera settings need to be done in preferences.xml, so an aircraft model cannot define any new views. Also, the camera positions are relative to the current view (i.e. cockpit, chase etc) and cannot be fixed on the aircraft itself.


Mean I can specify a rearmirror view for use in fighters, towing aircraft, car, etc... but has to define a camera in preferences.xml which creates this view?
And whenever I change the view from cockpit to chase, the camera shows now a view relativ to the chase-view?

Can I define several more views in preferences.xml like rear view, side-view etc. together and select later on the model which view I want to use?

Would it be possible to have "real" reflections on the surface like water as X-Plane or MSFS shows? And if so, how strong would be the effect on framerate?

Many questions I know, but anyway: great new features!
Many thanks to you Zan!
Up, up and away
User avatar
HHS
Retired
 
Posts: 3624
Joined: Thu Jul 19, 2007 8:09 am
Version: GIT

Re: Improved camera configuration options

Postby Hooray » Fri Oct 14, 2011 5:27 pm

HHS is probably asking about aircraft-specific "mirror textures", as previously discussed in a number of threads:
viewtopic.php?f=6&t=6184
viewtopic.php?f=13&t=6514
viewtopic.php?f=4&t=3353&p=31276&p31252

Looking at what Zan accomplished already, I don't think it will take very long for those options to become also available to aircraft developers.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11325
Joined: Tue Mar 25, 2008 8:40 am

Re: Improved camera configuration options

Postby Zan » Fri Oct 14, 2011 7:33 pm

HHS wrote in Fri Oct 14, 2011 11:14 am:Mean I can specify a rearmirror view for use in fighters, towing aircraft, car, etc... but has to define a camera in preferences.xml which creates this view?

Yes, currently the cameras are created on startup, and there is not yet any way to dynamically add them. Though it should be possible somehow.

And whenever I change the view from cockpit to chase, the camera shows now a view relativ to the chase-view?

Correct. But if you use that texture in a mirror inside the cockpit, most likely you wont see this "glitch". To use cameras centered on the aircraft (or any other point), we would need to switch to CompositeViewer in the code I think. I have not looked how big a change that would be, but I guess it's not trivial.

Can I define several more views in preferences.xml like rear view, side-view etc. together and select later on the model which view I want to use?

Mm, you can render all the views to different textures and then probably with some animation or similar it could be possible to select which texture to render. But I have not yet figured out how to add those textures to cache, so that they could easily be used on models.

Would it be possible to have "real" reflections on the surface like water as X-Plane or MSFS shows? And if so, how strong would be the effect on framerate?

I don't really know how the reflections are implemented in X-Plane or MSFS, but in theory we could render all 6 directions around the aircraft and use that as the cube map for reflection shader. Maybe similar system would work with water too.

All cameras render the scene again, so in my example I almost halved my framerate when using the rear view. But then again, it can be rendered in lower resolution, limited range etc. so the hit would not be that large.

Zan
Zan
 
Posts: 121
Joined: Tue Oct 20, 2009 10:28 am

Re: Improved camera configuration options

Postby gluon » Sat Oct 15, 2011 6:59 am

So if I get it right, this could also be used someday to render one of the views (like helicopter view, fly-by view etc.) into a "window" inside the current view window?
That would definitively be a nice feature I also like very much about FSX and have missed in FlightGear for a long time.

I also saw a video of an A340, which had a camera outside that was displayed in the middle of the console. Wait, maybe I can find it.
Ah, this is even better: http://www.youtube.com/watch?v=XgG8xDLI82w

Zan, your putting a lot of effort into improving FG and I think your doing an excellent job. Thank you :)
gluon
 
Posts: 68
Joined: Tue Aug 18, 2009 7:43 am

Re: Improved camera configuration options

Postby Hooray » Sat Oct 15, 2011 8:31 am

gluon wrote in Sat Oct 15, 2011 6:59 am:So if I get it right, this could also be used someday to render one of the views (like helicopter view, fly-by view etc.) into a "window" inside the current view window?


gluon, you can already have multiple view windows:

http://wiki.flightgear.org/Howto:_Confi ... ew_windows
http://gitorious.org/fg/fgdata/blobs/ma ... ultiscreen


Zan wrote in Fri Oct 14, 2011 7:33 pm:To use cameras centered on the aircraft (or any other point), we would need to switch to CompositeViewer in the code I think. I have not looked how big a change that would be, but I guess it's not trivial.


Yes, your point regarding CompositeViewer is correct, there has been some talk about this on the devel mailing list, and the move to CompositeViewer seems to be under consideration either way:

http://www.mail-archive.com/flightgear- ... 17001.html
Tim Moore wrote:Future Possibilities.

The cameras in a camera group don't need to render directly to the
screen. They can render to a texture which can be used either in the
scene, like in a video screen in the instrument panel, or for distortion
correction in a projected or dome environment.

Open Scene Graph supports a CompositeViewer object that supports
rendering from several widely separated viewpoints, complete with
support for multiple terrain pager threads. We could move to
CompositeViewer and support simultaneous views from e.g., the tower, AI
models, drones, etc.


http://www.mail-archive.com/flightgear- ... 27134.html
Tim Moore wrote:Neither of these are supported at the present time, but it would be a good
project. We would have to start using a different OSG class,
CompositeViewer, to support multiple views from independent view points. Our
terrain pager would need a complete overhaul to use the PagedLOD scheme of
OSG, and the Flightgear view manager would need to be aware multiple active
views.


http://www.mail-archive.com/flightgear- ... 17263.html
Tim Moore wrote:It would make sense to implement that as a
scene graph in its own right with its own pager. That would require a change in
current fg architecture to use a CompositeViewer instead of a single Viewer,
but we're contemplating that anyway.


http://www.mail-archive.com/flightgear- ... 28869.html
Tim Moore wrote:Yes, and that's not really supported by the current architecture, neither by
the tile cache nor by osgViewer::Viewer. We would need to move to a
CompositeViewer model, which supports several scene graphs, and rely
completely on the osg database paging machinery.
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11325
Joined: Tue Mar 25, 2008 8:40 am

Re: Improved camera configuration options

Postby gluon » Sat Oct 22, 2011 9:40 am

gluon, you can already have multiple view windows:

http://wiki.flightgear.org/Howto:_Confi ... ew_windows
http://gitorious.org/fg/fgdata/blobs/ma ... ultiscreen


Oh, wow, I obviously didn't know that. So I'll have to play around with this sometime. Maybe I can find a way to expose this so the non-tech savvy can enjoy it.
gluon
 
Posts: 68
Joined: Tue Aug 18, 2009 7:43 am

Re: Improved camera configuration options

Postby Hooray » Wed Feb 22, 2012 3:27 pm

Update: We are currently looking into this and asked Zan for his input, so that we could reuse some of his code to render external views to instrument textures, this would be required for features found in the real B787 and A380 aircraft.
Your feedback is appreciated, please see: http://wiki.flightgear.org/Howto:_Use_a ... Instrument
Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11325
Joined: Tue Mar 25, 2008 8:40 am

Re: Improved camera configuration options

Postby Hooray » Sat Feb 06, 2016 6:14 pm

Please don't send support requests by PM, instead post your questions on the forum so that all users can contribute and benefit
Thanks & all the best,
Hooray
Help write next month's newsletter !
pui2canvas | MapStructure | Canvas Development | Programming resources
Hooray
 
Posts: 11325
Joined: Tue Mar 25, 2008 8:40 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 5 guests