VR-Forces 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) 2023 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 
76  DtPostProcessor(DtDe& de, const std::string& postProcessType, bool handles2D);
77 
79  virtual ~DtPostProcessor();
80 
86  virtual void setFragmentShaderSource(const char *source);
87 
93  virtual void setVertexShaderSource(const char *source);
94 
100  virtual void setFragmentShaderFile(const std::string& fileName);
101 
107  virtual void setVertexShaderFile(const std::string& fileName);
108 
109 
114  virtual void setInputTexture(const DtChannel *channel, osg::Texture* texture);
115 
117  virtual bool update(DtChannel *channel) = 0;
118 
122  virtual osg::Texture* outputTexture();
123 
127  virtual void setIsFinalEffect(const DtChannel *channel, bool final);
128 
131  virtual osg::Camera* cameraForChannel(const DtChannel *channel);
132 
135  virtual void slot_releaseResources();
136 
139  virtual void releaseGLObjects();
140 
142  virtual bool hasEffect(const std::string& effect);
143 
145  virtual bool effectEnabled(const std::string& effect);
146 
148  virtual bool anyEffectEnabled();
149 
151  virtual bool enableEffect(const std::string& effect);
155  virtual bool disableEffect(const std::string& effect);
157 
159  virtual std::list<std::string> supportedEffects();
160 
163  virtual bool handles2D() const;
164 
166  virtual const std::string& type() const;
167 
169  virtual void enablePostProcessor();
171  virtual void disablePostProcessor();
173 
175  virtual bool postProcessorEnabled();
176 
181  virtual bool needsOcclusionTexture() const;
182 
183  protected:
184 
185  // A list of sub-effects that can be enabled/disabled
186  typedef boost::unordered_map<std::string, bool> EffectMap;
187 
188  virtual bool effectItrEnabled(const EffectMap::iterator &effect) const;
189 
190  virtual void initialize();
191 
195  virtual void addEffect(std::string effect);
196 
198  virtual void setEnablePostProcessor(bool enabled);
199 
200  protected:
201 
207 
208  typedef std::map<const DtChannel*, osg::ref_ptr<osg::Camera> > CameraMap;
210 
213 
214  // The category of this post effect ex. "dof", "wateronscreen"
215  std::string myType;
216 
217 
218  EffectMap myEffects; // ex. { {"rainsplash",true}, {"oceanspray",false} }
219 
220  //Needed in order to mark the correct callbacks dirty to avoid
221  // extra calls to set camera requres setup.
223  typedef std::map< const DtChannel*, CallbackRefPtr > CallbackMap;
224 
226 
229  };
230 
235  {
236  public:
239 
242 
244  virtual ~DtPostProcessorCreator();
245 
246  protected:
248  virtual DtPostProcessor* create(DtDe& de, const std::string& postProcessorType) = 0;
249  };
250 }
std::map< const DtChannel *, osg::ref_ptr< osg::Camera > > CameraMap
Definition: DtPostProcessor.h:208
bool myDirty
Definition: DtPostProcessor.h:53
CameraMap myCameraMap
Definition: DtPostProcessor.h:209
DtPostProcessorCreator is the common base class for all post processor creators.
Definition: DtPostProcessor.h:234
osg::ref_ptr< osg::Program > myProgram
Definition: DtPostProcessor.h:203
osg::ref_ptr< osg::Shader > myVertexShader
Definition: DtPostProcessor.h:205
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:202
virtual void setDirty(bool flag)
setter for the dirty flag
DtSignalConnectionManager mySignals
Definition: DtPostProcessor.h:228
osg::ref_ptr< osg::Geode > myQuad
Definition: DtPostProcessor.h:206
bool myHandles2DFlag
Definition: DtPostProcessor.h:211
The abstract Channel Class.
Definition: DtChannel.h:35
bool myEnabledFlag
Definition: DtPostProcessor.h:212
EffectMap myEffects
Definition: DtPostProcessor.h:218
std::map< const DtChannel *, CallbackRefPtr > CallbackMap
Definition: DtPostProcessor.h:223
This class provides the OSG-specific management of post-processing effects.
Definition: DtPostProcessManager.h:27
Class to manage disconnection of boost connections on deletion.
Definition: DtSignalConnectionManager.h:20
std::string myType
Definition: DtPostProcessor.h:215
#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:204
Base class to provide boost signal/slot management.
osg::ref_ptr< DtPostProcessorCullVistorCallback > CallbackRefPtr
Definition: DtPostProcessor.h:222
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:76
virtual void operator()(osg::Node *node, osg::NodeVisitor *nv)
DtDe & myDe
Definition: DtPostProcessor.h:227
boost::unordered_map< std::string, bool > EffectMap
Definition: DtPostProcessor.h:186
CallbackMap myCullCallbackMap
Definition: DtPostProcessor.h:225
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 Oct 15 21:27:02 EDT 2026 from SVN revision 296421
Copyright © 2005-2026 MAK Technologies. All Rights Reserved (www.mak.com)