VR-Forces 5.0.3 Developer's Guide
 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) 2021 MAK Technologies, Inc.
3 * All rights reserved.
4 *****************************************************************************/
5 
6 #pragma once
7 
11 
13 
15 
16 #include <osg/Camera>
17 #include <osg/Texture>
18 #include <osg/Program>
19 #include <osg/Shader>
20 #include <osg/Texture2D>
21 #include <osg/Geode>
22 
23 #include <map>
24 
25 #include <boost/unordered_map.hpp>
26 
27 namespace makVrv
28 {
29  class DtChannel;
30  class DtWindow;
31 
32  // When attaching / detaching buffers from the camera
33  // You need to call setCameraRequiresSetUp since there is (and will be)
34  // a bug in OSG's camera caching behavior
36  class DtPostProcessorCullVistorCallback : public osg::NodeCallback
37  {
38  public:
39 
40  DtPostProcessorCullVistorCallback() : osg::NodeCallback(), myDirty(true)
41  {
42  //intentional nop
43  }
44 
45  // Callback method called by the NodeVisitor when visiting a node.
46  virtual void operator()(osg::Node* node, osg::NodeVisitor* nv);
47 
49  virtual void setDirty(bool flag);
50 
51  protected:
52 
53  bool myDirty;
54  };
55 
56 
67  {
68  public:
69  friend class DtPostProcessManager;
70 
74  DtPostProcessor(DtDe& de, const std::string& postProcessType, bool handles2D);
75 
77  virtual ~DtPostProcessor();
78 
84  virtual void setFragmentShaderSource(const char *source);
85 
91  virtual void setVertexShaderSource(const char *source);
92 
98  virtual void setFragmentShaderFile(const std::string& fileName);
99 
105  virtual void setVertexShaderFile(const std::string& fileName);
106 
107 
112  virtual void setInputTexture(const DtChannel *channel, osg::Texture* texture);
113 
115  virtual bool update(DtChannel *channel) = 0;
116 
120  virtual osg::Texture* outputTexture();
121 
125  virtual void setIsFinalEffect(const DtChannel *channel, bool final);
126 
129  virtual osg::Camera* cameraForChannel(const DtChannel *channel);
130 
133  virtual void slot_releaseResources();
134 
137  virtual void releaseGLObjects();
138 
140  virtual bool hasEffect(const std::string& effect);
141 
143  virtual bool effectEnabled(const std::string& effect);
144 
146  virtual bool anyEffectEnabled();
147 
149  virtual bool enableEffect(const std::string& effect);
153  virtual bool disableEffect(const std::string& effect);
155 
157  virtual std::list<std::string> supportedEffects();
158 
161  virtual bool handles2D() const;
162 
164  virtual const std::string& type() const;
165 
167  virtual void enablePostProcessor();
169  virtual void disablePostProcessor();
171 
173  virtual bool postProcessorEnabled() const;
174 
179  virtual bool needsOcclusionTexture() const;
180 
181  protected:
182 
183  // A list of sub-effects that can be enabled/disabled
184  typedef boost::unordered_map<std::string, bool> EffectMap;
185 
186  virtual bool effectItrEnabled(const EffectMap::iterator &effect);
187 
188  virtual void initialize();
189 
193  virtual void addEffect(std::string effect);
194 
196  virtual void setEnablePostProcessor(bool enabled);
197 
198  protected:
199 
205 
206  typedef std::map<const DtChannel*, osg::ref_ptr<osg::Camera> > CameraMap;
208 
211 
212  // The category of this post effect ex. "dof", "wateronscreen"
213  std::string myType;
214 
215 
216  EffectMap myEffects; // ex. { {"rainsplash",true}, {"oceanspray",false} }
217 
218  //Needed in order to mark the correct callbacks dirty to avoid
219  // extra calls to set camera requres setup.
221  typedef std::map< const DtChannel*, CallbackRefPtr > CallbackMap;
222 
224 
227  };
228 
233  {
234  public:
237 
240 
242  virtual ~DtPostProcessorCreator();
243 
244  protected:
246  virtual DtPostProcessor* create(DtDe& de, const std::string& postProcessorType) = 0;
247  };
248 }
std::map< const DtChannel *, osg::ref_ptr< osg::Camera > > CameraMap
Definition: DtPostProcessor.h:206
bool myDirty
Definition: DtPostProcessor.h:53
CameraMap myCameraMap
Definition: DtPostProcessor.h:207
DtPostProcessorCreator is the common base class for all post processor creators.
Definition: DtPostProcessor.h:232
osg::ref_ptr< osg::Program > myProgram
Definition: DtPostProcessor.h:201
osg::ref_ptr< osg::Shader > myVertexShader
Definition: DtPostProcessor.h:203
Factory to create the specific DtPostProcessors registered when vrvOsg starts up. ...
Definition: DtPostProcessorFactory.h:26
DtPostProcessorCullVistorCallback()
Definition: DtPostProcessor.h:40
osg::ref_ptr< osg::Texture > myOutputTexture
Definition: DtPostProcessor.h:200
virtual void setDirty(bool flag)
setter for the dirty flag
DtSignalConnectionManager mySignals
Definition: DtPostProcessor.h:226
osg::ref_ptr< osg::Geode > myQuad
Definition: DtPostProcessor.h:204
bool myHandles2DFlag
Definition: DtPostProcessor.h:209
The abstract Channel Class.
Definition: DtChannel.h:35
bool myEnabledFlag
Definition: DtPostProcessor.h:210
EffectMap myEffects
Definition: DtPostProcessor.h:216
std::map< const DtChannel *, CallbackRefPtr > CallbackMap
Definition: DtPostProcessor.h:221
This class provides the OSG-specific management of post-processing effects.
Definition: DtPostProcessManager.h:25
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
std::string myType
Definition: DtPostProcessor.h:213
#define DT_DLL_VRVPOSTPROCESSOR
Definition: vrvPostProcessor.h:19
const char * source
Definition: lz4.h:442
Contains DLL export macros.
osg::ref_ptr< osg::Shader > myFragmentShader
Definition: DtPostProcessor.h:202
Base class to provide boost signal/slot management.
osg::ref_ptr< DtPostProcessorCullVistorCallback > CallbackRefPtr
Definition: DtPostProcessor.h:220
Definition: DtPostProcessor.h:36
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer, DtDeCommunicator, as well as a DtDisplay and other things.
Definition: DtDe.h:70
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
DtDe & myDe
Definition: DtPostProcessor.h:225
boost::unordered_map< std::string, bool > EffectMap
Definition: DtPostProcessor.h:184
CallbackMap myCullCallbackMap
Definition: DtPostProcessor.h:223
This class provides the OSG-specific implementation of a post processor. A post processor has a type ...
Definition: DtPostProcessor.h:66

Document ID: Generated on Thu Jun 1 17:58:13 EDT 2023 from SVN revision 255404
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)