VR-Forces 4.8 Class Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtPostProcessor.h
Go to the documentation of this file.
1 /*****************************************************************************
2 * Copyright (c) 2020 MAK Technologies, Inc.
3 * All rights reserved.
4 *****************************************************************************/
5 
6 #pragma once
7 
11 
13 
14 #include <osg/Camera>
15 #include <osg/Texture>
16 #include <osg/Program>
17 #include <osg/Shader>
18 #include <osg/Texture2D>
19 #include <osg/Geode>
20 
21 #include <map>
22 
23 #include <boost/unordered_map.hpp>
24 
25 namespace makVrv
26 {
27  class DtChannel;
28 
29  // When attaching / detaching buffers from the camera
30  // You need to call setCameraRequiresSetUp since there is (and will be)
31  // a bug in OSG's camera caching behavior
33  class DtPostProcessorCullVistorCallback : public osg::NodeCallback
34  {
35  public:
36 
37  DtPostProcessorCullVistorCallback() : osg::NodeCallback(), myDirty(true)
38  {
39  }
40 
41  // Callback method called by the NodeVisitor when visiting a node.
42  virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
43 
45  virtual void setDirty(bool flag);
46 
47  protected:
48 
49  bool myDirty;
50  };
51 
52 
63  {
64  public:
65  friend class DtPostProcessManager;
66 
70  DtPostProcessor(const std::string& postProcessType, bool handles2D);
71 
73  virtual ~DtPostProcessor();
74 
80  virtual void setFragmentShaderSource(const char *source);
81 
87  virtual void setVertexShaderSource(const char *source);
88 
94  virtual void setFragmentShaderFile(const std::string& fileName);
95 
101  virtual void setVertexShaderFile(const std::string& fileName);
102 
103 
108  virtual void setInputTexture(const DtChannel *channel, osg::Texture* texture);
109 
111  virtual bool update(DtChannel *channel) = 0;
112 
116  virtual osg::Texture* outputTexture();
117 
121  virtual void setIsFinalEffect(const DtChannel *channel, bool final);
122 
125  virtual osg::Camera* cameraForChannel(const DtChannel *channel);
126 
127  virtual void releaseGLObjects();
128 
130  virtual bool hasEffect(const std::string& effect);
131 
133  virtual bool effectEnabled(const std::string& effect);
134 
136  virtual bool anyEffectEnabled();
137 
139  virtual bool enableEffect(const std::string& effect);
143  virtual bool disableEffect(const std::string& effect);
145 
147  virtual std::list<std::string> supportedEffects();
148 
151  virtual bool handles2D() const;
152 
154  virtual const std::string& type() const;
155 
157  virtual void enablePostProcessor();
159  virtual void disablePostProcessor();
161 
163  virtual bool postProcessorEnabled() const;
164 
165  protected:
166 
167  // A list of sub-effects that can be enabled/disabled
168  typedef boost::unordered_map<std::string, bool> EffectMap;
169 
170  virtual bool effectItrEnabled(EffectMap::iterator &effect);
171 
172  virtual void initialize();
173 
177  virtual void addEffect(std::string effect);
178 
180  virtual void setEnablePostProcessor(bool enabled);
181 
182  protected:
183 
189 
190  typedef std::map<const DtChannel*, osg::ref_ptr<osg::Camera> > CameraMap;
192 
195 
196  // The category of this post effect ex. "dof", "wateronscreen"
197  std::string myType;
198 
199 
200  EffectMap myEffects; // ex. { {"rainsplash",true}, {"oceanspray",false} }
201 
202  //Needed in order to mark the correct callbacks dirty to avoid
203  // extra calls to set camera requres setup.
205  typedef std::map< const DtChannel*, CallbackRefPtr > CallbackMap;
206 
208  };
209 
214  {
215  public:
218 
221 
223  virtual ~DtPostProcessorCreator();
224 
225  protected:
227  virtual DtPostProcessor* create(DtDe& de, const std::string& postProcessorType) = 0;
228  };
229 }
Diagonal crossing liens.
Definition: DtTacticalGraphicUtilities.h:93
std::map< const DtChannel *, osg::ref_ptr< osg::Camera > > CameraMap
Definition: DtPostProcessor.h:190
bool myDirty
Definition: DtPostProcessor.h:49
CameraMap myCameraMap
Definition: DtPostProcessor.h:191
DtPostProcessorCreator is the common base class for all post processor creators.
Definition: DtPostProcessor.h:213
osg::ref_ptr< osg::Program > myProgram
Definition: DtPostProcessor.h:185
osg::ref_ptr< osg::Shader > myVertexShader
Definition: DtPostProcessor.h:187
Factory to create the specific DtPostProcessors registered when vrvOsg starts up. ...
Definition: DtPostProcessorFactory.h:26
DtPostProcessorCullVistorCallback()
Definition: DtPostProcessor.h:37
osg::ref_ptr< osg::Texture > myOutputTexture
Definition: DtPostProcessor.h:184
virtual void setDirty(bool flag)
setter for the dirty flag
osg::ref_ptr< osg::Geode > myQuad
Definition: DtPostProcessor.h:188
bool myHandles2DFlag
Definition: DtPostProcessor.h:193
The abstract Channel Class.
Definition: DtChannel.h:29
bool myEnabledFlag
Definition: DtPostProcessor.h:194
EffectMap myEffects
Definition: DtPostProcessor.h:200
std::map< const DtChannel *, CallbackRefPtr > CallbackMap
Definition: DtPostProcessor.h:205
This class provides the OSG-specific management of post-processing effects.
Definition: DtPostProcessManager.h:25
std::string myType
Definition: DtPostProcessor.h:197
#define DT_DLL_VRVPOSTPROCESSOR
Definition: vrvPostProcessor.h:19
const char * source
Definition: lz4.h:436
Contains DLL export macros.
osg::ref_ptr< osg::Shader > myFragmentShader
Definition: DtPostProcessor.h:186
osg::ref_ptr< DtPostProcessorCullVistorCallback > CallbackRefPtr
Definition: DtPostProcessor.h:204
Definition: DtPostProcessor.h:33
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
boost::unordered_map< std::string, bool > EffectMap
Definition: DtPostProcessor.h:168
CallbackMap myCullCallbackMap
Definition: DtPostProcessor.h:207
This class provides the OSG-specific implementation of a post processor.
Definition: DtPostProcessor.h:62

Document ID: Generated on Thu Aug 27 10:56:05 EDT 2020 from SVN revision 217100
Copyright © 2005-2020 MAK Technologies. All Rights Reserved (www.mak.com)