The ScreenLOD that was introduced in 2.0 is meant to be an "automatic" LOD node. Traditionally, level of detail nodes have been based on the distance to the viewer. However, there is no distinction between very small objects and very large objects that are the same distance away. This node instead makes an estimate of what percentage of the screen would the node use. It also takes into account triangle degradation within the node to pick the node that gives the best cost/performance for the image based on these factors. This node is easier to use than the !DistanceLOD because the user does not have to explicitly state when to switch to different LODs. Instead the user just adds the different levels into the node in decreasing complexity. There are also user tweakable settings that can be controlled to optimize the nodes behaviour to the users liking. They are demonstrated below with an explanation of each that follows.
#!cpp OSG::ScreenLODPtr lod_core; geom_lod = OSG::makeCoredNode < OSG::ScreenLOD > (&lod_core); while(you have more geometry LODs) OSG::NodeRefPtr lod_group(OSG::makeCoredNode < OSG::Group > ()); //Put your all geometry for this LOD into lod_group //Add your lod_group to the ScreenLOD node geom_lod->addChild(lod_group); RenderTraversalAction *tact = NULL; tact = RenderTraversalAction::create(); // Set the number of LODs to use, 0 indicates use all LODs tact->setScreenLODNumLevels(3); // Set the minimum coverage threshold(in percent) before highest LOD is not used tact->setScreenLODCoverageThreshold(0.01); //If object takes less than 1% of screen then choose other LODs // Adjust the slope of degradation when choosing LODs, higher=faster tact->setScreenLODDegradationFactor(1.5);
Number of Levels to Use
The user can control the number of levels to use by calling: tact->setScreenLODNumLevels(numberOfLevels). This will tell the node to not use any level higher than X. When set to 0, all LODs are used. When set to 1, only the highest LOD is used. Default is 0, so all LODs are used.
Screen Coverage Threshold
The node figures out how much of the screen the bounding box of the node will take up(a percentage). This percentage is then compared against the screen coverage threshold to determine whether to use a different LOD. If the node would take up less than the minimum needed to render at the highest LOD then a different LOD is chosen. The user can tweek this setting by calling: tact->setScreenLODCoverageThreshold(0.01). NOTE: Even if this is set higher, the rendering may not neccessarily get worse. The node still will pick the best LOD given how much of the screen is taking up and how fast the triangles within the node degrade. The default is 0.001, so 0.1%.
This setting allows the user to control the slope of degradation used in picking LODs for the objects. When set above 1.0, the selection of lower LODs happens faster. Conversely, when set below 1.0, lower LODs are picked slower. A user can adjust this level by calling: tact->setScreenLODDegradationFactor(theFactor). The default is 1.0, or don't adjust what the node is picking.
It is possible to take complete control over the LOD node and specify exactly what coverage percentages to use when selecting the LOD. To enable this amount of control, use the coverageOverride MField and specify the exact percentages. When you use this list, all other processing is disabled and only these values are used for selection.