VR-Forces 4.10 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 
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 
175  protected:
176 
177  // A list of sub-effects that can be enabled/disabled
178  typedef boost::unordered_map<std::string, bool> EffectMap;
179 
180  virtual bool effectItrEnabled(const EffectMap::iterator &effect);
181 
182  virtual void initialize();
183 
187  virtual void addEffect(std::string effect);
188 
190  virtual void setEnablePostProcessor(bool enabled);
191 
192  protected:
193 
199 
200  typedef std::map<const DtChannel*, osg::ref_ptr<osg::Camera> > CameraMap;
202 
205 
206  // The category of this post effect ex. "dof", "wateronscreen"
207  std::string myType;
208 
209 
210  EffectMap myEffects; // ex. { {"rainsplash",true}, {"oceanspray",false} }
211 
212  //Needed in order to mark the correct callbacks dirty to avoid
213  // extra calls to set camera requres setup.
215  typedef std::map< const DtChannel*, CallbackRefPtr > CallbackMap;
216 
218 
221  };
222 
227  {
228  public:
231 
234 
236  virtual ~DtPostProcessorCreator();
237 
238  protected:
240  virtual DtPostProcessor* create(DtDe& de, const std::string& postProcessorType) = 0;
241  };
242 }
Diagonal crossing liens.
Definition: DtTacticalGraphicUtilities.h:93
std::map< const DtChannel *, osg::ref_ptr< osg::Camera > > CameraMap
Definition: DtPostProcessor.h:200
bool myDirty
Definition: DtPostProcessor.h:53
CameraMap myCameraMap
Definition: DtPostProcessor.h:201
DtPostProcessorCreator is the common base class for all post processor creators.
Definition: DtPostProcessor.h:226
osg::ref_ptr< osg::Program > myProgram
Definition: DtPostProcessor.h:195
osg::ref_ptr< osg::Shader > myVertexShader
Definition: DtPostProcessor.h:197
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:194
virtual void setDirty(bool flag)
setter for the dirty flag
DtSignalConnectionManager mySignals
Definition: DtPostProcessor.h:220
osg::ref_ptr< osg::Geode > myQuad
Definition: DtPostProcessor.h:198
bool myHandles2DFlag
Definition: DtPostProcessor.h:203
The abstract Channel Class.
Definition: DtChannel.h:30
bool myEnabledFlag
Definition: DtPostProcessor.h:204
EffectMap myEffects
Definition: DtPostProcessor.h:210
std::map< const DtChannel *, CallbackRefPtr > CallbackMap
Definition: DtPostProcessor.h:215
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:207
#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:196
Base class to provide boost signal/slot management.
osg::ref_ptr< DtPostProcessorCullVistorCallback > CallbackRefPtr
Definition: DtPostProcessor.h:214
Definition: DtPostProcessor.h:36
The DtDe is the core component of any VR-Vantage application.
Definition: DtDe.h:69
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
DtDe & myDe
Definition: DtPostProcessor.h:219
boost::unordered_map< std::string, bool > EffectMap
Definition: DtPostProcessor.h:178
CallbackMap myCullCallbackMap
Definition: DtPostProcessor.h:217
This class provides the OSG-specific implementation of a post processor.
Definition: DtPostProcessor.h:66

Document ID: Generated on Tue Sep 21 17:42:52 EDT 2021 from SVN revision 234861
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)