OpenWalnut  1.4.0
WGEPostprocessorMergeOp.h
1 //---------------------------------------------------------------------------
2 //
3 // Project: OpenWalnut ( http://www.openwalnut.org )
4 //
5 // Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6 // For more information see http://www.openwalnut.org/copying
7 //
8 // This file is part of OpenWalnut.
9 //
10 // OpenWalnut is free software: you can redistribute it and/or modify
11 // it under the terms of the GNU Lesser General Public License as published by
12 // the Free Software Foundation, either version 3 of the License, or
13 // (at your option) any later version.
14 //
15 // OpenWalnut is distributed in the hope that it will be useful,
16 // but WITHOUT ANY WARRANTY; without even the implied warranty of
17 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 // GNU Lesser General Public License for more details.
19 //
20 // You should have received a copy of the GNU Lesser General Public License
21 // along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
22 //
23 //---------------------------------------------------------------------------
24 
25 #ifndef WGEPOSTPROCESSORMERGEOP_H
26 #define WGEPOSTPROCESSORMERGEOP_H
27 
28 #include <string>
29 
30 #ifndef Q_MOC_RUN
31 #include <boost/shared_ptr.hpp>
32 #endif
33 
34 #include <osg/Texture2D>
35 
36 #include "../shaders/WGEShader.h"
37 #include "../shaders/WGEShaderCodeInjector.h"
38 
39 #include "WGEPostprocessor.h"
40 
41 /**
42  * MergeOp is a operator to merge multiple input texture. The merge operation can be defined by the user.
43  */
45 {
46 public:
47  /**
48  * Convenience typedef for a boost::shared_ptr< WGEPostprocessorMergeOp >.
49  */
50  typedef boost::shared_ptr< WGEPostprocessorMergeOp > SPtr;
51 
52  /**
53  * Convenience typedef for a boost::shared_ptr< const WGEPostprocessorMergeOp >.
54  */
55  typedef boost::shared_ptr< const WGEPostprocessorMergeOp > ConstSPtr;
56 
57  /**
58  * Default constructor.
59  */
61 
62  /**
63  * Constructor. We implement a public constructor which can take more textures as input
64  *
65  * \param offscreen use this offscreen node to add your texture pass'
66  * \param tex0 texture to filter
67  * \param tex1 texture to filter
68  * \param tex2 texture to filter
69  * \param tex3 texture to filter
70  * \param tex4 texture to filter
71  * \param tex5 texture to filter
72  * \param tex6 texture to filter
73  * \param tex7 texture to filter
74  */
75  WGEPostprocessorMergeOp( osg::ref_ptr< WGEOffscreenRenderNode > offscreen,
76  osg::ref_ptr< osg::Texture2D > tex0,
77  osg::ref_ptr< osg::Texture2D > tex1 = osg::ref_ptr< osg::Texture2D >(),
78  osg::ref_ptr< osg::Texture2D > tex2 = osg::ref_ptr< osg::Texture2D >(),
79  osg::ref_ptr< osg::Texture2D > tex3 = osg::ref_ptr< osg::Texture2D >(),
80  osg::ref_ptr< osg::Texture2D > tex4 = osg::ref_ptr< osg::Texture2D >(),
81  osg::ref_ptr< osg::Texture2D > tex5 = osg::ref_ptr< osg::Texture2D >(),
82  osg::ref_ptr< osg::Texture2D > tex6 = osg::ref_ptr< osg::Texture2D >(),
83  osg::ref_ptr< osg::Texture2D > tex7 = osg::ref_ptr< osg::Texture2D >() );
84 
85  /**
86  * Destructor.
87  */
88  virtual ~WGEPostprocessorMergeOp();
89 
90  /**
91  * Create instance. Uses the protected constructor. Implement it if you derive from this class!
92  *
93  * \param offscreen use this offscreen node to add your texture pass'
94  * \param gbuffer the input textures you should use
95  * \returns shared pointer to the created insteance
96  */
97  virtual WGEPostprocessor::SPtr create( osg::ref_ptr< WGEOffscreenRenderNode > offscreen,
98  const PostprocessorInput& gbuffer ) const;
99 
100  /**
101  * 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
102  * code you write here should not make any assumptions to the environment it is inserted. What you have is a vec4 named color, initialized
103  * with vec4( 1.0 ). Set your final color to this vec4. It will be the result.
104  *
105  * \param code the code as string
106  */
107  void setGLSLMergeCode( std::string code );
108 protected:
109 private:
110  /**
111  * The shader used for merging
112  */
114 
115  /**
116  * This preprocessor handles insertion of the custom merge code.
117  */
119 };
120 
121 #endif // WGEPOSTPROCESSORMERGEOP_H
122 
This class encapsulates a G-Buffer.
WGEShader::RefPtr m_mergeOpShader
The shader used for merging.
boost::shared_ptr< WGEPostprocessor > SPtr
Convenience typedef for an osg::ref_ptr< WGEPostprocessor >.
MergeOp is a operator to merge multiple input texture.
The base class for all custom post-processors.
boost::shared_ptr< WGEPostprocessorMergeOp > SPtr
Convenience typedef for a boost::shared_ptr< WGEPostprocessorMergeOp >.
osg::ref_ptr< WGEShader > RefPtr
Convenience typedef for an osg::ref_ptr.
Definition: WGEShader.h:57
boost::shared_ptr< WGEShaderCodeInjector > SPtr
Shortcut for a shared_ptr.
void setGLSLMergeCode(std::string code)
Set the GLSL code inserted into the shader as merging operation.
virtual ~WGEPostprocessorMergeOp()
Destructor.
WGEPostprocessorMergeOp()
Default constructor.
WGEShaderCodeInjector::SPtr m_codeInjector
This preprocessor handles insertion of the custom merge code.
virtual WGEPostprocessor::SPtr create(osg::ref_ptr< WGEOffscreenRenderNode > offscreen, const PostprocessorInput &gbuffer) const
Create instance.
boost::shared_ptr< const WGEPostprocessorMergeOp > ConstSPtr
Convenience typedef for a boost::shared_ptr< const WGEPostprocessorMergeOp >.