I did a IR scene by making my own cull visitor. In order to make this efficient 
I had to put a virtual in front off osgUtil::CullVisitor::pushStateSet().

My cull visitor look like this

class SpectrumCullVisitor : public osgUtil::CullVisitor
{
public:
        SpectrumCullVisitor()
        {};

        SpectrumCullVisitor(MapCullSpectrumCallBack* spectrumCallBack)
        {
                _Callback = spectrumCallBack;
        };
        virtual ~SpectrumCullVisitor()
        {};

        //! Get Cull Map Callback
        MapCullSpectrumCallBack* Callback() const { return _Callback.get(); }
        //! Set Cull Map Callback
        void Callback(MapCullSpectrumCallBack* val) { _Callback = val; }

protected:
        //! Try to find alternative stat set if this fails push the stat set 
delivered from the graph
        void pushStateSet(const osg::StateSet* ss)
        {
                const osg::StateSet* pushSS = NULL;
                if (_Callback.get())
                {
                        //Look if there is a alternative stat set
                        pushSS = _Callback->GetMapedStateSet(ss);
                        if (pushSS)
                        {
                                //Alternative found using it in base function
                                CullVisitor::pushStateSet(pushSS);
                        }
                        else
                        {
                                //No alternative found cal bas function without 
switching
                                CullVisitor::pushStateSet(ss);
                        }
                }
                else
                {
                        //No Callback cal base without switching
                        CullVisitor::pushStateSet(ss);
                }
        };
private:
        osg::ref_ptr<MapCullSpectrumCallBack> _Callback;
};


And the callback like this:

class MapCullSpectrumCallBack : public osg::Referenced
{
public:
        MapCullSpectrumCallBack(const std::string& spectrum):
                _spectrum(spectrum)
        {};
        virtual ~MapCullSpectrumCallBack(){};

        const osg::StateSet* GetMapedStateSet( const osg::StateSet* ss ) const;
        bool InsertModifiedStatsetIfChanged(const osg::StateSet* ss);

        int CleanUp();

protected:
        osg::ref_ptr<osg::StateSet> CreateStatsetAlternative(const 
osg::StateSet* ss);
        std::string _spectrum;
        bool SwitchToSpectrumTextures( osg::StateSet* ss );
        bool SwitchToSpectrumShader( osg::StateSet* ss );

        std::string getFileSpectrumName( std::string name );
        typedef std::map<osg::ref_ptr<const 
osg::StateSet>,osg::ref_ptr<osg::StateSet>> StateMap;
        StateMap _StateMap;
};

You then have to populate the map in the callback with statset with alternative 
textures(IR).

Regars Ragnar
 

-----Ursprungligt meddelande-----
Från: osg-users-boun...@lists.openscenegraph.org 
[mailto:osg-users-boun...@lists.openscenegraph.org] För Steven Powers
Skickat: den 2 december 2010 21:12
Till: osg-users@lists.openscenegraph.org
Ämne: Re: [osg-users] Need help about Night Vision Effect

The easy/cheating way is to calculate the luminance of each pixel, amplify it, 
(color it green to fit the stereotype) then add electric noise.

This is easiest to do on a fragment shader.

Cheers,
Steven

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=34458#34458





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to