Board index FlightGear Development Canvas

Using Canvas to create reflections

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.

Using Canvas to create reflections

Postby MIG29pilot » Tue Dec 29, 2015 7:41 pm

According to the Wiki Article,
In FlightGear, a Canvas is a dynamically created image (OpenGL texture) that can be created and modified (drawn to) at runtime by using the Property Tree, i.e. via the built-in scripting language Nasal and setting a few properties via setprop() or its object-oriented wrapper props.nas

Canvas is all about rendering to a texture and updating it dynamically at run-time by modifying a sub-tree in the property tree that represents the texture (RTT) - its primary rendering primitives are:
  • text (via osgText)
  • vector graphics (via shivaVG/OpenVG)
  • static raster images (or dynamic images via osg::Image represented as another Canvas)
  • groups/maps - for grouping/nesting elements to arbitrary depths, and selectively controlling/transforming/clipping each sub-tree

Canvas itself maintains a FBO (frame buffer object ) for each texture, which is also the mechanism in use by Rembrandt. In other words, Canvas is an abstraction mechanism for RTT/FBO management via conventional FlightGear properties. A Canvas texture can optionally also respond to common GUI events to support keyboard/mouse interactions (e.g. drag&drop, hot-keys).

Could canvas be used to take a view from a certain area in a certain direction and render it onto a fuselage--in other words, to create a reflection?
User avatar
MIG29pilot
 
Posts: 1454
Joined: Tue May 19, 2015 4:03 pm
Location: 6 feet under Snow
Callsign: MIG29pilot
Version: 3.7nightly
OS: Windows 10

Re: Using Canvas to create reflections

Postby Hooray » Tue Dec 29, 2015 7:48 pm

Could canvas be used to take a view from a certain area in a certain direction and render it onto a fuselage--in other words, to create a reflection?


The answer to that is at least two-fold: Reflections are typically implemented using effects and shaders. For the time being, the Canvas system is not (yet) hooked up to the effects/shader system. However, we do have experimental code demonstrating that this is possible, i.e. proof-of-concept:

http://wiki.flightgear.org/Canvas_Devel ... 2F_Shaders
Image

The other thing is, if you want more than just a simple reflection (aka a mirror/tail cam view etc), you would need to add support for a dedicated Canvas Camera element:

http://wiki.flightgear.org/Canvas_Devel ... ng_Cameras
http://wiki.flightgear.org/Canvas_Sandbox
Image

While there's code doing this sort of thing, this also, isn't yet integrated with/exposed to Canvas - and it is also -at least in part- "blocked" by the ongoing PagedLOD work, which in turn blocks CompositeViewer adoption (having multiple independent viewers requires PagedLOD): http://wiki.flightgear.org/CompositeViewer_Support

Thus, to answer your question - none of this is directly supported, but it could be emulated by making creative use of shaders and effects - for instance, we have even seen Canvas-based liveries:

http://wiki.flightgear.org/Howto:Dynami ... via_Canvas
Image

Ultimately it all boils down to your exact use-case, but I guess it would be better to use just effects/shaders for now.
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: 11437
Joined: Tue Mar 25, 2008 8:40 am


Return to Canvas

Who is online

Users browsing this forum: No registered users and 2 guests