Draw masks

From FlightGear wiki
Jump to navigation Jump to search
This article is a stub. You can help the wiki by expanding it.
Note  In its current form, this section/article is largely based on quotes collected from various related discussions/channels (devel list, forum etc) using the Instant-Cquotes script. Wiki users and other contributors are encouraged to help rewrite/edit contents accordingly to help get rid of unnecessary quoting (i.e. while the wiki is not intended to be a collection of quotes, quotes are sometimes the best/easiest way to bootstrap new articles, while also providing a good way to link back to related discussions in the archives).

While rewriting usually only entails changing first person speech to 3rd person. However, please try to retain references/links to the original discussion whenever possible.

FlightGear Draw masks GUI dialog procedurally created by the Canvas system.s
Property browser with draw masks shown
Cquote1.png Another goal is to add more node bits (and a GUI dialog to control them) so various categories of objects can be disabled during the update pass. This will mean the direct hit of, say, AI models vs particles vs random trees can be measured. Of course it won't account for resources (memory, textures) burned by such things, but would still help different people identify slowness on their setups.
— James Turner (Jul 19th, 2012). Re: [Flightgear-devel] Rendering passes question.
(powered by Instant-Cquotes)
Cquote2.png
var (width,height) = (320,160);
var title = 'Draw Masks';

var window = canvas.Window.new([width,height],"dialog").set('title',title);

window.del = func()
{
  print("Cleaning up window:",title,"\n");
  call(canvas.Window.del, [], me);
};

# adding a canvas to the new window and setting up background colors/transparency
var myCanvas = window.createCanvas().set("background", canvas.style.getColor("bg_color"));

# creating the top-level/root group which will contain all other elements/group
var root = myCanvas.createGroup();

var drawMasks = props.globals.getNode("/sim/rendering/draw-mask").getChildren();

# create a new layout
window.Layout = canvas.VBoxLayout.new();

# assign it to the Canvas
myCanvas.setLayout(window.Layout);


foreach(var mask; drawMasks) {

(func() {
var m = mask;

# print("Found mask:", mask.getName(), "=", mask.getValue() );

var checkbox = canvas.gui.widgets.CheckBox.new(root, canvas.style, {wordWrap: 0})
.setText( "render "  ~ m.getName() )
.listen("toggled", func(e) {
			      setprop(m.getPath(), e.detail.checked);
                            })
.setChecked(  m.getValue() );
window.Layout.addItem(checkbox);

}) ();

}
Cquote1.png There's so called "draw-masks" which are property-controlled switches for enabling/disabling rendering of certain scene details, including 1) scenery/terrain, 2) aircraft, 3) models, 4) clouds.This can be used for troubleshooting performance issues - you can basically toggle individual scene graphs on/off, to see if/how performance is affected.For example, if performance improves dramatically by disabling the terrain, you are mainly affected scenery complexity.Equally, disabling the (main) aircraft, will tell you if it's the complexity of the 777 3D model (cockpit).
— Hooray (Nov 29th, 2014). Re: FlightGear 3.2 with B777 running extremely slow.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png Beginning with FlightGear 3.1+, you can also toggle individual scenegraph traversal masks on/off (these can be changed at runtime using the Property browser:--prop:browser=/sim/rendering/draw-mask--prop:/sim/rendering/draw-mask/terrain=0--prop:/sim/rendering/draw-mask/aircraft=0--prop:/sim/rendering/draw-mask/models=0--prop:/sim/rendering/draw-mask/clouds=0
— Hooray (Nov 29th, 2014). Re: FlightGear 3.2 with B777 running extremely slow.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png Those draw masks will not prevent stuff from being loaded (=consuming RAM/memory), it will merely disable updates to the already loaded data. Which also applies to other stuff like aircraft.Which is why heavy aircraft like the 777-200 or the extra500 will still perform much worse than comparatively lightweight aircraft like the ufo, ogeL, santa or the default c172p (especially the 2D version is fairly lightweight).
— Hooray (Jul 5th, 2014). Re: Flatland.
(powered by Instant-Cquotes)
Cquote2.png


Cockpit

Cquote1.png How to hide cockpit when in Helicopter view or any outside view of the aircraft? My graphic card is weak, so many aircrafts that don't hide the cockpit when I change to Helicopter view will kill the smoothness...
— Jiawen (Jun 24th, 2015). Hide cockpit at Helicopter view?.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png I think he wants to only load the exterior model for better performance, as far as I know, there is no simple way to do that.
— firefly (Dec 29th, 2015). Re: Hide cockpit at Helicopter view?.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png It would be possible to allow dynamic draw masks to be configured "on demand", so that certain XML/model files could be loaded into a corresponding branch of the scenegraph, so that a new draw-mask property shows up in /sim/rendering/draw-masks, e.g. /sim/rendering/draw-masks/cockpit The model loader would need to be patched to parse such annotations (e.g. XML tags/attributes) so that the corresponding osg::Switch node can be added and a visitor registered to update it based on toggling a property.
— Hooray (Dec 29th, 2015). Re: Hide cockpit at Helicopter view?.
(powered by Instant-Cquotes)
Cquote2.png


Scenery

Note  For the time being, the Particle System does not use any of the standard Draw Masks, but a separate switch properly located at: /sim/rendering/particles (at some point, this will probably be unified by introducing an additional property[1] and phasing out this one over time, as per [1]).
Cquote1.png I'd like to see both LOD range and user settable masks in the .stg file.
— psadro_gm (Aug 12th, 2014). Re: No go airports for weak gpus ....
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png Instead of a whole new loader, I think we can just modify the existing .STG loader and ignore objects not in the draw mask?
Cquote2.png
Cquote1.png we should probably consider adding a dedicated draw-mask for such features, and maybe even a "factor" attribute to specify how many of those objects/models should be loaded/shown. Maybe, there is a way to procedurally add a "marker" (tag) to each model so that the loader in fg/sg can dynamically be told to enable, increase/decrease or disable such features ?
— Hooray (Nov 3rd, 2015). Re: Populate 3000 airports in one day.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png I agree. I think this is not very hard to implement. And I am not surprised that others had the same idea already before me.
— pommesschranke (Nov 8th, 2015). Re: Populate 3000 airports in one day.
(powered by Instant-Cquotes)
Cquote2.png
Cquote1.png My original response contains links to patches doing this - so you could basically adapt the patch to introduce a new draw-mask for autogen-based features.

That said, psadro_gm definitely is in a much better position to judge if/how the underlying scenery format could encode a corresponding bit pattern to distinguish different features, i.e. something like 4-5 bits would probably do for most purposes (looking at osm2city etc)

Feel free to get in touch if you need help with the C++ side of the draw masks - but like you say, something like that would ideally not just support on/off, but also an attribute to adjust scene complexity, i.e. scale up/down - especially for feature scaling purposes.
— Hooray (Nov 8th, 2015). Re: Populate 3000 airports in one day.
(powered by Instant-Cquotes)
Cquote2.png


Cquote1.png more and more features would get dedicated properties with draw-masks to disable/enable rendering and optionally customie things - this isn't too difficult to do, and it doesn't necessarily involve touching tons of STG/BTG files - it's mainly a change that would involve SimGear/FG, so that buildings (and other heavy stuff) would be loaded into dedicated sub-scene graph that can be easily disabled using an osg::switch node
— Hooray (Feb 3rd, 2015). Re: No go airports for weak gpus ....
(powered by Instant-Cquotes)
Cquote2.png


To open a property browser with the corresponding properties, use --prop:browser=/sim/rendering/draw-mask (can be also added to your fgfsrc file)