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