OpenWalnut
1.4.0
|
00001 //--------------------------------------------------------------------------- 00002 // 00003 // Project: OpenWalnut ( http://www.openwalnut.org ) 00004 // 00005 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS 00006 // For more information see http://www.openwalnut.org/copying 00007 // 00008 // This file is part of OpenWalnut. 00009 // 00010 // OpenWalnut is free software: you can redistribute it and/or modify 00011 // it under the terms of the GNU Lesser General Public License as published by 00012 // the Free Software Foundation, either version 3 of the License, or 00013 // (at your option) any later version. 00014 // 00015 // OpenWalnut is distributed in the hope that it will be useful, 00016 // but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 // GNU Lesser General Public License for more details. 00019 // 00020 // You should have received a copy of the GNU Lesser General Public License 00021 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>. 00022 // 00023 //--------------------------------------------------------------------------- 00024 00025 #ifndef WGEPOSTPROCESSORMERGEOP_H 00026 #define WGEPOSTPROCESSORMERGEOP_H 00027 00028 #include <string> 00029 00030 #include <boost/shared_ptr.hpp> 00031 00032 #include <osg/Texture2D> 00033 00034 #include "../shaders/WGEShader.h" 00035 #include "../shaders/WGEShaderCodeInjector.h" 00036 00037 #include "WGEPostprocessor.h" 00038 00039 /** 00040 * MergeOp is a operator to merge multiple input texture. The merge operation can be defined by the user. 00041 */ 00042 class WGEPostprocessorMergeOp: public WGEPostprocessor 00043 { 00044 public: 00045 /** 00046 * Convenience typedef for a boost::shared_ptr< WGEPostprocessorMergeOp >. 00047 */ 00048 typedef boost::shared_ptr< WGEPostprocessorMergeOp > SPtr; 00049 00050 /** 00051 * Convenience typedef for a boost::shared_ptr< const WGEPostprocessorMergeOp >. 00052 */ 00053 typedef boost::shared_ptr< const WGEPostprocessorMergeOp > ConstSPtr; 00054 00055 /** 00056 * Default constructor. 00057 */ 00058 WGEPostprocessorMergeOp(); 00059 00060 /** 00061 * Constructor. We implement a public constructor which can take more textures as input 00062 * 00063 * \param offscreen use this offscreen node to add your texture pass' 00064 * \param tex0 texture to filter 00065 * \param tex1 texture to filter 00066 * \param tex2 texture to filter 00067 * \param tex3 texture to filter 00068 * \param tex4 texture to filter 00069 * \param tex5 texture to filter 00070 * \param tex6 texture to filter 00071 * \param tex7 texture to filter 00072 */ 00073 WGEPostprocessorMergeOp( osg::ref_ptr< WGEOffscreenRenderNode > offscreen, 00074 osg::ref_ptr< osg::Texture2D > tex0, 00075 osg::ref_ptr< osg::Texture2D > tex1 = osg::ref_ptr< osg::Texture2D >(), 00076 osg::ref_ptr< osg::Texture2D > tex2 = osg::ref_ptr< osg::Texture2D >(), 00077 osg::ref_ptr< osg::Texture2D > tex3 = osg::ref_ptr< osg::Texture2D >(), 00078 osg::ref_ptr< osg::Texture2D > tex4 = osg::ref_ptr< osg::Texture2D >(), 00079 osg::ref_ptr< osg::Texture2D > tex5 = osg::ref_ptr< osg::Texture2D >(), 00080 osg::ref_ptr< osg::Texture2D > tex6 = osg::ref_ptr< osg::Texture2D >(), 00081 osg::ref_ptr< osg::Texture2D > tex7 = osg::ref_ptr< osg::Texture2D >() ); 00082 00083 /** 00084 * Destructor. 00085 */ 00086 virtual ~WGEPostprocessorMergeOp(); 00087 00088 /** 00089 * Create instance. Uses the protected constructor. Implement it if you derive from this class! 00090 * 00091 * \param offscreen use this offscreen node to add your texture pass' 00092 * \param gbuffer the input textures you should use 00093 * \returns shared pointer to the created insteance 00094 */ 00095 virtual WGEPostprocessor::SPtr create( osg::ref_ptr< WGEOffscreenRenderNode > offscreen, 00096 const PostprocessorInput& gbuffer ) const; 00097 00098 /** 00099 * Set the GLSL code inserted into the shader as merging operation. If none was set, the mix command is used for each incoming texture. The 00100 * code you write here should not make any assumptions to the environment it is inserted. What you have is a vec4 named color, initialized 00101 * with vec4( 1.0 ). Set your final color to this vec4. It will be the result. 00102 * 00103 * \param code the code as string 00104 */ 00105 void setGLSLMergeCode( std::string code ); 00106 protected: 00107 private: 00108 /** 00109 * The shader used for merging 00110 */ 00111 WGEShader::RefPtr m_mergeOpShader; 00112 00113 /** 00114 * This preprocessor handles insertion of the custom merge code. 00115 */ 00116 WGEShaderCodeInjector::SPtr m_codeInjector; 00117 }; 00118 00119 #endif // WGEPOSTPROCESSORMERGEOP_H 00120