Feature Stencil model driver
This driver uses a stencil buffer technique to drape vector data on the terrain. The technique is based on a method described by Schneider and Klein.
Configuration
This driver supports the following sub-elements:
<features> Describes the features to render required <style> Defines overall appearance of the vector data optional <class> Defines one or more feature classes for categorization of features optional <extrusion_distance> Distance to extrude the stencil volumes in each direction. If you have single features that span large areas (like a polygon of the entire US) you may need to increase this number to avoid seeing z-buffer interference. optional, default="300000"
Example
See the feature_stencil_drape_polygons.earth sample in the repo
<map name="Feature Stencil Demo" type="geocentric">
<image name="world" driver="gdal">
<url>../data/world.tif</url>
</image>
<model name="states" driver="feature_stencil">
<!-- Configure the OGR feature driver to read the shapefile. -->
<features name="world" driver="ogr">
<url>../data/world.shp</url>
<ogr_driver>ESRI Shapefile</ogr_driver>
</features>
<!-- Since some countries span large areas on the globe, we need to
use a larger-than-normal extrusion distance on the stencil
volumes. (300000 is the default.) -->
<extrusion_distance>400000</extrusion_distance>
<style type="text/css">
world {
fill: #ffff80;
fill-opacity: 0.4;
}
</style>
</model>
</map>
Developers Note
This driver uses the OpenGL stencil buffer. If you are using this driver from code, you need to make sure you have allocated an OSG viewer with sufficient stencil bits.
If you are using osgviewer, whether you get stencil bits varies by platform. You can force it to allocate stencil bits like so:
osgviewer --stencil file.earth
If you are using the driver from code, make sure to allocate stencil bits BEFORE creating your viewer, like so:
osg::DisplaySettings::instance()->setMinimumNumStencilBits( 8 );
...
osgViewer::Viewer viewer(args);
