-
- SGMaterial *mat = matlib->find( "RWY_WHITE_LIGHTS" );
-
- osg::Geometry* geometry = new osg::Geometry;
- geometry->setName("Reil Lights " + mat->get_names().front());
- geometry->setVertexArray(vl);
- geometry->setNormalArray(nl);
- geometry->setNormalBinding(osg::Geometry::BIND_PER_VERTEX);
- geometry->setColorArray(cl);
- geometry->setColorBinding(osg::Geometry::BIND_PER_VERTEX);
- geometry->addPrimitiveSet(new osg::DrawArrays(GL_TRIANGLES, 0, vl->size()));
- osg::Geode* geode = new osg::Geode;
- geode->addDrawable(geometry);
-
- if ( mat != NULL ) {
- geode->setStateSet( mat->get_state() );
- } else {
- SG_LOG( SG_TERRAIN, SG_ALERT,
- "Warning: can't find material = RWY_WHITE_LIGHTS" );
+ // Basic stuff; no sprite or attenuation support
+ Pass *basicPass = new Pass;
+ basicPass->setRenderBinDetails(POINT_LIGHTS_BIN, "DepthSortedBin");
+ basicPass->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
+ StateAttributeFactory *attrFact = StateAttributeFactory::instance();
+ basicPass->setAttributeAndModes(attrFact->getStandardBlendFunc());
+ basicPass->setAttributeAndModes(attrFact->getStandardAlphaFunc());
+ if (directional) {
+ basicPass->setAttributeAndModes(attrFact->getCullFaceBack());
+ basicPass->setAttribute(polyMode.get());
+ }
+ Pass *attenuationPass = clone(basicPass, CopyOp::SHALLOW_COPY);
+ osg::Point* point = new osg::Point;
+ point->setMinSize(minSize);
+ point->setMaxSize(maxSize);
+ point->setSize(size);
+ point->setDistanceAttenuation(attenuation);
+ attenuationPass->setAttributeAndModes(point);
+ Pass *spritePass = clone(basicPass, CopyOp::SHALLOW_COPY);
+ spritePass->setTextureAttributeAndModes(0, pointSprite.get(),
+ osg::StateAttribute::ON);
+ Texture2D* texture = gen_standard_light_sprite();
+ spritePass->setTextureAttribute(0, texture);
+ spritePass->setTextureMode(0, GL_TEXTURE_2D,
+ osg::StateAttribute::ON);
+ spritePass->setTextureAttribute(0, attrFact->getStandardTexEnv());
+ Pass *combinedPass = clone(spritePass, CopyOp::SHALLOW_COPY);
+ combinedPass->setAttributeAndModes(point);
+ ref_ptr<Effect> effect = new Effect;
+ std::vector<std::string> parameterExtensions;
+
+ if (SGSceneFeatures::instance()->getEnablePointSpriteLights())
+ {
+ std::vector<std::string> combinedExtensions;
+ combinedExtensions.push_back("GL_ARB_point_sprite");
+ combinedExtensions.push_back("GL_ARB_point_parameters");
+ Technique* combinedTniq = new Technique;
+ combinedTniq->passes.push_back(combinedPass);
+ combinedTniq->setGLExtensionsPred(2.0, combinedExtensions);
+ effect->techniques.push_back(combinedTniq);
+ std::vector<std::string> spriteExtensions;
+ spriteExtensions.push_back(combinedExtensions.front());
+ Technique* spriteTniq = new Technique;
+ spriteTniq->passes.push_back(spritePass);
+ spriteTniq->setGLExtensionsPred(2.0, spriteExtensions);
+ effect->techniques.push_back(spriteTniq);
+ parameterExtensions.push_back(combinedExtensions.back());