mirror of
				https://github.com/OpenMW/openmw.git
				synced 2025-11-04 02:56:39 +00:00 
			
		
		
		
	(cherry picked from commit 496b3aef88b8fd867dcdd23a6ca43144573b1b2f) Stereo friendly water (cherry picked from commit 0e22c55e48a7f965367d3d430c1bef5357b22748) Option to disable per view mapping. Include memory header De-hardcode settings and buffers. formatting error Update water.cpp (whitespace) Update water.cpp (more whitespace) include render order c array -> c++ array
		
			
				
	
	
		
			68 lines
		
	
	
	
		
			2.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
			
		
		
	
	
			68 lines
		
	
	
	
		
			2.8 KiB
		
	
	
	
		
			C++
		
	
	
	
	
	
#ifndef OPENMW_RTT_H
 | 
						|
#define OPENMW_RTT_H
 | 
						|
 | 
						|
#include <osg/Node>
 | 
						|
 | 
						|
#include <map>
 | 
						|
#include <memory>
 | 
						|
 | 
						|
namespace osg
 | 
						|
{
 | 
						|
    class Texture2D;
 | 
						|
    class Camera;
 | 
						|
}
 | 
						|
 | 
						|
namespace osgUtil
 | 
						|
{
 | 
						|
    class CullVisitor;
 | 
						|
}
 | 
						|
 | 
						|
namespace SceneUtil
 | 
						|
{
 | 
						|
    /// @brief Implements per-view RTT operations.
 | 
						|
    /// @par With a naive RTT implementation, subsequent views of multiple views will overwrite the results of the previous views, leading to
 | 
						|
    ///     the results of the last view being broadcast to all views. An error in all cases where the RTT result depends on the view.
 | 
						|
    /// @par If using an RTTNode this is solved by mapping RTT operations to CullVisitors, which will be unique per view. This requires
 | 
						|
    ///     instancing one camera per view, and traversing only the camera mapped to that CV during cull traversals.
 | 
						|
    /// @par Camera settings should be effectuated by overriding the setDefaults() and apply() methods, following a pattern similar to SceneUtil::StateSetUpdater
 | 
						|
    /// @par When using the RTT texture in your statesets, it is recommended to use SceneUtil::StateSetUpdater as a cull callback to handle this as the appropriate
 | 
						|
    ///     textures can be retrieved during SceneUtil::StateSetUpdater::Apply()
 | 
						|
    /// @par For any of COLOR_BUFFER or DEPTH_BUFFER not added during setDefaults(), RTTNode will attach a default buffer. The default color buffer has an internal format of GL_RGB.
 | 
						|
    ///     The default depth buffer has internal format GL_DEPTH_COMPONENT24, source format GL_DEPTH_COMPONENT, and source type GL_UNSIGNED_INT. Default wrap is CLAMP_TO_EDGE and filter LINEAR.
 | 
						|
    class RTTNode : public osg::Node
 | 
						|
    {
 | 
						|
    public:
 | 
						|
        RTTNode(uint32_t textureWidth, uint32_t textureHeight, int renderOrderNum, bool doPerViewMapping);
 | 
						|
        ~RTTNode();
 | 
						|
 | 
						|
        osg::Texture* getColorTexture(osgUtil::CullVisitor* cv);
 | 
						|
 | 
						|
        osg::Texture* getDepthTexture(osgUtil::CullVisitor* cv);
 | 
						|
 | 
						|
 | 
						|
        /// Apply state - to override in derived classes
 | 
						|
        /// @note Due to the view mapping approach you *have* to apply all camera settings, even if they have not changed since the last frame.
 | 
						|
        virtual void setDefaults(osg::Camera* camera) {};
 | 
						|
 | 
						|
        /// Set default settings - optionally override in derived classes
 | 
						|
        virtual void apply(osg::Camera* camera) {};
 | 
						|
 | 
						|
        void cull(osgUtil::CullVisitor* cv);
 | 
						|
 | 
						|
    private:
 | 
						|
        struct ViewDependentData
 | 
						|
        {
 | 
						|
            osg::ref_ptr<osg::Camera> mCamera;
 | 
						|
        };
 | 
						|
 | 
						|
        ViewDependentData* getViewDependentData(osgUtil::CullVisitor* cv);
 | 
						|
 | 
						|
        typedef std::map< osgUtil::CullVisitor*, std::unique_ptr<ViewDependentData> >  ViewDependentDataMap;
 | 
						|
        ViewDependentDataMap mViewDependentDataMap;
 | 
						|
        uint32_t mTextureWidth;
 | 
						|
        uint32_t mTextureHeight;
 | 
						|
        int mRenderOrderNum;
 | 
						|
        bool mDoPerViewMapping;
 | 
						|
    };
 | 
						|
}
 | 
						|
#endif
 |