osg::Group* run(osg::Node* node) { float radius = osgEarth::SpatialReference::get("wgs84")->getEllipsoid()->getRadiusEquator(); VirtualProgram* vp = VirtualProgram::getOrCreate(node->getOrCreateStateSet()); // Install the shader function: vp->setFunction("make_it_red", fragShader, ShaderComp::LOCATION_FRAGMENT_LIGHTING); // Set a maximum LOD range for the above function: vp->setFunctionMinRange( "make_it_red", 500000 ); vp->setFunctionMaxRange( "make_it_red", 1000000 ); osg::Group* g = new osg::Group(); // Install a callback that will convey the LOD range to the shader LOD. g->addCullCallback( new RangeUniformCullCallback() ); g->addChild( node ); return g; }