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 #include <boost/shared_ptr.hpp>
31 
32 #include <osg/Texture2D>
33 
34 #include "../shaders/WGEShader.h"
35 #include "../shaders/WGEShaderCodeInjector.h"
36 
37 #include "WGEPostprocessor.h"
38 
39 /**
40  * MergeOp is a operator to merge multiple input texture. The merge operation can be defined by the user.
41  */
43 {
44 public:
45  /**
46  * Convenience typedef for a boost::shared_ptr< WGEPostprocessorMergeOp >.
47  */
48  typedef boost::shared_ptr< WGEPostprocessorMergeOp > SPtr;
49 
50  /**
51  * Convenience typedef for a boost::shared_ptr< const WGEPostprocessorMergeOp >.
52  */
53  typedef boost::shared_ptr< const WGEPostprocessorMergeOp > ConstSPtr;
54 
55  /**
56  * Default constructor.
57  */
59 
60  /**
61  * Constructor. We implement a public constructor which can take more textures as input
62  *
63  * \param offscreen use this offscreen node to add your texture pass'
64  * \param tex0 texture to filter
65  * \param tex1 texture to filter
66  * \param tex2 texture to filter
67  * \param tex3 texture to filter
68  * \param tex4 texture to filter
69  * \param tex5 texture to filter
70  * \param tex6 texture to filter
71  * \param tex7 texture to filter
72  */
73  WGEPostprocessorMergeOp( osg::ref_ptr< WGEOffscreenRenderNode > offscreen,
74  osg::ref_ptr< osg::Texture2D > tex0,
75  osg::ref_ptr< osg::Texture2D > tex1 = osg::ref_ptr< osg::Texture2D >(),
76  osg::ref_ptr< osg::Texture2D > tex2 = osg::ref_ptr< osg::Texture2D >(),
77  osg::ref_ptr< osg::Texture2D > tex3 = osg::ref_ptr< osg::Texture2D >(),
78  osg::ref_ptr< osg::Texture2D > tex4 = osg::ref_ptr< osg::Texture2D >(),
79  osg::ref_ptr< osg::Texture2D > tex5 = osg::ref_ptr< osg::Texture2D >(),
80  osg::ref_ptr< osg::Texture2D > tex6 = osg::ref_ptr< osg::Texture2D >(),
81  osg::ref_ptr< osg::Texture2D > tex7 = osg::ref_ptr< osg::Texture2D >() );
82 
83  /**
84  * Destructor.
85  */
86  virtual ~WGEPostprocessorMergeOp();
87 
88  /**
89  * Create instance. Uses the protected constructor. Implement it if you derive from this class!
90  *
91  * \param offscreen use this offscreen node to add your texture pass'
92  * \param gbuffer the input textures you should use
93  * \returns shared pointer to the created insteance
94  */
95  virtual WGEPostprocessor::SPtr create( osg::ref_ptr< WGEOffscreenRenderNode > offscreen,
96  const PostprocessorInput& gbuffer ) const;
97 
98  /**
99  * 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
100  * code you write here should not make any assumptions to the environment it is inserted. What you have is a vec4 named color, initialized
101  * with vec4( 1.0 ). Set your final color to this vec4. It will be the result.
102  *
103  * \param code the code as string
104  */
105  void setGLSLMergeCode( std::string code );
106 protected:
107 private:
108  /**
109  * The shader used for merging
110  */
112 
113  /**
114  * This preprocessor handles insertion of the custom merge code.
115  */
117 };
118 
119 #endif // WGEPOSTPROCESSORMERGEOP_H
120 
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:53
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 >.