25 #include "../../common/WPropertyHelper.h"
26 #include "../../common/WItemSelection.h"
28 #include "../shaders/WGEShaderPropertyDefineOptions.h"
29 #include "../callbacks/WGENodeMaskCallback.h"
30 #include "../WGEUtils.h"
32 #include "WGEPostprocessor.h"
34 #include "WGEPostprocessingNode.h"
39 m_properties( boost::shared_ptr<
WProperties >( new
WProperties(
"Post-processing",
"Post-processing properties" ) ) )
45 boost::shared_ptr< WItemSelection > m_possibleSelections(
new WItemSelection() );
46 m_possibleSelections->addItem(
"None",
"No postprocessing." );
48 m_showHud =
m_properties->addProperty(
"Texture Debug",
"If set, all intermediate texture are shown on screen for debugging.",
false );
49 m_active =
m_properties->addProperty(
"Enable",
"If set, post-processing is enabled.",
false,
true );
51 m_possibleSelections->getSelectorFirst(),
61 for( WGEPostprocessor::ProcessorList::const_iterator iter = processors.begin(); iter != processors.end(); ++iter )
64 osg::ref_ptr< WGEOffscreenRenderNode > offscreen(
new WGEOffscreenRenderNode( reference, width, height, noHud ) );
65 offscreen->getTextureHUD()->addUpdateCallback( textureHudCallback );
68 offscreen->setLinkViewportToTextureSize( ( *iter )->getFixedViewportSize() );
71 osg::ref_ptr< WGEOffscreenRenderPass > render = offscreen->addGeometryRenderPass(
85 processor->getProperties()->setHidden(
true );
88 m_possibleSelections->addItem( processor->getName(), processor->getDescription() );
91 osg::ref_ptr< WGEOffscreenFinalPass > output = offscreen->addFinalOnScreenPass(
new WGEShader(
"WGEPostprocessorCombiner" ),
93 output->bind( processor->getOutput(), 0 );
96 osg::ref_ptr< osg::Texture2D > depthTex = processor->getDepth();
101 output->bind( depthTex, 1 );
104 addChild( offscreen );
125 m_active,
"WGE_POSTPROCESSING_DISABLED",
"WGE_POSTPROCESSING_ENABLED" )
129 shader->addPreprocessor( preproc );
134 w->get()[ node ] = std::make_pair( shader, preproc );
148 if( item != w->get().end() )
151 ( *item ).second.first->removePreprocessor( ( *item ).second.second );
152 w->get().erase( item );
167 ( *iter ).second.first->removePreprocessor( ( *iter ).second.second );
196 m_postprocs[ i ]->getProperties()->setHidden( i != ( active - 1 ) );
osg::ref_ptr< osg::Texture2D > m_depthTexture
Depth.
boost::shared_ptr< WSharedObjectTicketWrite< std::map< osg::ref_ptr< osg::Node >, std::pair< WGEShader::RefPtr, WGEShaderPreprocessor::SPtr > > > > WriteTicket
Type for write tickets.
WPropGroup m_properties
All the properties of the post-processor.
WPropBool m_active
If true, post-processing is enabled.
This class encapsulates a G-Buffer.
WGEPostprocessor::ProcessorList m_postprocs
The postprocessors.
std::vector< WGEPostprocessor::SPtr > ProcessorList
Type used for returning lists of postprocessor prototypes.
boost::shared_ptr< WGEPostprocessor > SPtr
Convenience typedef for an osg::ref_ptr< WGEPostprocessor >.
WPropBool m_showHud
Activate to show the texture HUDs.
This callback is able to switch a osg::Switch node using a property.
This is a WGEShaderDefineOptions class which additionally uses a property to automatically control th...
void clear()
Removes all associated nodes.
virtual ~WGEPostprocessingNode()
Destructor.
WGEPostprocessingNode(osg::ref_ptr< WGECamera > reference, size_t width=2048, size_t height=2048, bool noHud=false)
Create a new post-processing node.
std::map< osg::ref_ptr< osg::Node >, std::pair< WGEShader::RefPtr, WGEShaderPreprocessor::SPtr > >::iterator Iterator
A typedef for the correct iterator to traverse this sequence container.
osg::ref_ptr< WGEShader > RefPtr
Convenience typedef for an osg::ref_ptr.
WriteTicket getWriteTicket(bool suppressNotify=false) const
Returns a ticket to get write access to the contained data.
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader...
Class to manage properties of an object and to provide convenience methods for easy access and manipu...
A class containing a list of named items.
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
This type of node basically is a convenience class for managing and creating offscreen renderings...
osg::ref_ptr< WGEGroupNode > m_childs
The group of child nodes to post-process.
NodeShaderAssociation m_nodeShaderAssociation
List of nodes and their corresponding shader and preprocessor.
void insert(osg::ref_ptr< osg::Node > node, WGEShader::RefPtr shader=NULL)
Inserts a node to the post-processor and injects the needed code to the specified shader...
boost::shared_ptr< WGEShaderPreprocessor > SPtr
Shared pointer for this class.
WPropSelection m_activePostprocessor
The property containing the currently active method or a combination.
static PostprocessorInput attach(osg::ref_ptr< WGEOffscreenRenderPass > from)
Attaches the needed textures to the specified render pass and returns the G-Buffer.
void postprocessorSelected()
Callback for changes in m_activePostprocessor.
This callback is useful to en-/disable nodes using the node mask based on properties.
WPropGroup getProperties() const
Returns the set of properties controlling the post-processing node.
static ProcessorList getPostprocessors()
Returns a list of all known postprocessor prototypes.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.
void remove(osg::ref_ptr< osg::Node > node)
Removes the node from the post-processing.
WGEPostprocessor::SPtr getCurrentPostprocessor() const
The post processor currently in use.