This example shows how to create a custom post processor for VR Vantage.
The example creates two derived classes. ExamplePostProcessor derives from DtPostProcessor and implements the constructor and update function for the new custom post processor. The class ExamplePostProcessorCreator is derived from DtPostProcessorCreator and is utilized in the DtPostProcessorFactory.
The plugin's init function sets the order of the post processor (placed before "camera_fx" runs) and registers the post processor effect with a user defined ObserverSetting enumeration value.
The update function demonstrates how to retrieve the depth buffer from the render to texture camera and link it to the shader state for the post processor. It also shows how to send variables such as time to the shader.
The shader for the post procesor is in examples\examplePostProcessor\example_ps.glsl. It draws the depth buffer in the lower left corner of the screen and applies a since wave distortion on the render to texture camera color buffer.
Please see the comments in the code as well since it describes the post processing system.
This example is a plug-in. You can run it by running ./bin64/examplePostProcessor_stealth.bat(on Windows) or ./bin64/examplePostProcessor_stealth.sh (on Linux). Load Ground_DB II terrain. For more information about running examples, please see Running Applications and Examples.
This example currently disables the reverse Z buffer (–disableReverseZBuffer) in order to allow the rendered depth buffer to work correctly.
#include <boost/bind/bind.hpp>
static vrvSignalsLib::connection postInitializeConnection;
{
public:
ExamplePostProcessor(
DtDe& de)
{
setFragmentShaderFile("../examples/examplePostProcessor/example_ps.glsl");
addEffect("example_effect");
}
{
osg::Camera* cam = cameraForChannel(channel);
if (cam)
{
osg::StateSet* ss = cam->getOrCreateStateSet();
osg::Uniform* timeUfrm = ss->getOrCreateUniform("vrv_time", osg::Uniform::FLOAT);
timeUfrm->set((float)myDe.simulationTime());
osg::Texture* depthTexture = 0L;
if(osgChannel != NULL)
{
}
if(depthTexture != 0L)
{
cam->getOrCreateStateSet()->
getOrCreateUniform("vrv_depthTex", osg::Uniform::INT)->set(1);
cam->getOrCreateStateSet()->
setTextureAttributeAndModes(1, depthTexture);
return true;
}
}
return false;
}
};
{
public:
DtPostProcessor* create(DtDe& de, const std::string&)
{
return new ExamplePostProcessor(de);
}
};
void slot_postInit(
DtDe& de)
{
postInitializeConnection.disconnect();
groundDbPath += "/TerrainData/TerrainConfiguration/Ground_DB II.mtf";
{
}
}
void initializeToolbar(
DtDe& de)
{
QString qTemp = QObject::tr("Custom Effect");
qTemp = QObject::tr("Show/Hide Custom Effect");
}
{
{
}
de, "CustomEffectItem", observerSettingId));
if ( igApp )
{
}
}
{
return true;
}
Contains makVrv::DtDe class.
#define DT_DE_INIT_ONCE(de)
This macro is called by modules in their init() function. This macro ensures that the module is only ...
Definition DtDe.h:30
Contains vrvCore::DtObserverMode class.
Contains the DtObserverModeManager class declaration.
Contains makVrv::DtObserverSettingsDisplayNameProvider class.
Contains classes used as menu items on the observer menu.
Contains makVrv::DtObserverSettingsManager class.
Contains makVrv::DtOsgChannel class.
Contains makVrv::DtPostProcessManagerInterface class.
Contains makVrv::DtScene class.
Contains makVrv::DtVrvApplication implementation.
The abstract Channel Class.
Definition DtChannel.h:36
The DtDe is the core component of any VR-Vantage application. It owns a DtRenderer,...
Definition DtDe.h:77
boost::signalslib::signal< void()> signal_initializeDefaultState
Definition DtDe.h:529
virtual const DtDePathConfiguration & dePathConfiguration() const
Return the DtDePathConfiguration.
virtual DtScene & scene()
The DtScene accessor.
boost::signalslib::signal< void()> signal_postInitialize
Definition DtDe.h:535
virtual std::string iconsPath() const
Accessors to resolved paths.
virtual std::string sharedDataPath() const
virtual void setToolTip(int intKey, const DtUnicode &displayName)
Change the tool tip associated with a key (if it exists) or add a new tool tip to key mapping.
virtual void setDisplayName(int intKey, const DtUnicode &displayName)
Change the dislay name associated with a key (if it exists) or add a new display name to key mapping.
static DtObserverModeManager & instance(DtDe &de)
Get an instance used to emit, or to connect.
Definition DtObserverSettingsItems.h:300
DtObserverSettingsDisplayNameProvider is an interface for a class to provide display names for observ...
Definition DtObserverSettingsDisplayNameProvider.h:24
ObserverSetting
Definition DtObserverSettingsManager.h:42
@ USER_START
Definition DtObserverSettingsManager.h:86
static DtObserverSettingsManager & instance(DtDe &de)
Get an instance used to emit, or to connect.
This class provides the OSG-specific implementation of a DtChannel.
Definition DtOsgChannel.h:59
virtual osg::ref_ptr< osg::Texture > getDepthTexture() const
Returns the depth texture for this channel.
Definition DtPostProcessor.h:235
static DtPostProcessorFactory & instance(DtDe &de)
Get an instance to the DtPostProcessorFactory.
This class provides the OSG-specific implementation of a post processor. A post processor has a type ...
Definition DtPostProcessor.h:67
An object that represents everything that is visible in the scene.
Definition DtScene.h:45
const std::string & terrainFileName() const
Get the loaded terrain filename.
bool loadTerrain(const DtUnicode &filePath)
Load the terrain from a file.
static DtUnicode fromQString(QStringType qstr)
Template function for setting from Qt 4 style string.
Definition DtUnicode.h:107
@ ModelSetAll
Definition DtVisualTypeManager.h:48
static DtVisualTypeManager & instance(DtDe &de)
Static accessor. Get the instance of the manager rooted in the DtDe.
The Root IG Application object. To run the IG simply create one, initialize it and call run.
Definition DtVrvApplication.h:58
DtMenuConfiguration & masterModeMenuConfiguration()
Get the menu configuration which may be altered by plugins.
static DtVrvApplication * findFromDe(DtDe &)
DtToolbarConfiguration & masterModeToolbarConfiguration()
Get the toolbar configuration which may be altered by plugins.
DT_DLL_EXAMPLEACCESSORY void init(makVrv::DtDe &de)
DT_DE_PLUGIN_EXPORT_MACRO bool initDeModule(makVrv::DtDe *de)
DT_DLL_VRVCOREQT void init(DtDe &de)
DT_DLL_VRVPOSTPROCESSOR void init(DtDe &anIG)
Initialize the VRV Post Processor library.
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16
Information about a visual type.
Definition DtVisualTypeManager.h:53