27 #include "../../common/WItemSelection.h"
28 #include "../../common/WPropertyHelper.h"
29 #include "../WGEUtils.h"
30 #include "../callbacks/WGENodeMaskCallback.h"
31 #include "../shaders/WGEShaderPropertyDefineOptions.h"
32 #include "WGEPostprocessingNode.h"
33 #include "WGEPostprocessor.h"
38 m_properties( std::shared_ptr<
WProperties >( new
WProperties(
"Post-processing",
"Post-processing properties" ) ) )
44 std::shared_ptr< WItemSelection > m_possibleSelections(
new WItemSelection() );
45 m_possibleSelections->addItem(
"None",
"No postprocessing." );
47 m_showHud =
m_properties->addProperty(
"Texture debug",
"If set, all intermediate texture are shown on screen for debugging.",
false );
53 "All depths behind this are assumed to be background.", 0.75 );
61 "How much to shade the foreground. Use values higher than one to brighten the foreground.", 1.0 );
67 m_active =
m_properties->addProperty(
"Enable",
"If set, post-processing is enabled.",
false,
true );
69 m_possibleSelections->getSelectorFirst(),
79 for( WGEPostprocessor::ProcessorList::const_iterator iter = processors.begin(); iter != processors.end(); ++iter )
82 osg::ref_ptr< WGEOffscreenRenderNode > offscreen(
new WGEOffscreenRenderNode( reference, width, height, noHud ) );
83 offscreen->getTextureHUD()->addUpdateCallback( textureHudCallback );
86 offscreen->setLinkViewportToTextureSize( ( *iter )->getFixedViewportSize() );
89 osg::ref_ptr< WGEOffscreenRenderPass > render = offscreen->addGeometryRenderPass(
102 m_properties->addProperty( processor->getProperties() );
103 processor->getProperties()->setHidden(
true );
106 m_possibleSelections->addItem( processor->getName(), processor->getDescription() );
109 osg::ref_ptr< WGEShader > combinerShader(
new WGEShader(
"WGEPostprocessorCombiner" ) );
110 osg::ref_ptr< WGEOffscreenFinalPass > output = offscreen->addFinalOnScreenPass( combinerShader,
"Output" );
122 osg::ref_ptr< osg::Texture2D > colorTex = processor->getOutput();
123 colorTex->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
124 colorTex->setFilter( osg::Texture::MIN_FILTER, osg::Texture::LINEAR_MIPMAP_LINEAR );
125 output->bind( colorTex, 0 );
128 osg::ref_ptr< osg::Texture2D > depthTex = processor->getDepth();
133 output->bind( depthTex, 1 );
136 addChild( offscreen );
159 m_active,
"WGE_POSTPROCESSING_DISABLED",
"WGE_POSTPROCESSING_ENABLED" )
163 shader->addPreprocessor( preproc );
168 w->get()[ node ] = std::make_pair( shader, preproc );
182 if( item != w->get().end() )
185 ( *item ).second.first->removePreprocessor( ( *item ).second.second );
186 w->get().erase( item );
201 ( *iter ).second.first->removePreprocessor( ( *iter ).second.second );
230 m_postprocs[ i ]->getProperties()->setHidden( i != ( active - 1 ) );
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
This callback is useful to en-/disable nodes using the node mask based on properties.
This type of node basically is a convenience class for managing and creating offscreen renderings.
WGEPostprocessor::SPtr getCurrentPostprocessor() const
The post processor currently in use.
WPropDouble m_depthShadeU
Upper depth threshold -> how bright to get.
WPropGroup m_depthGroup
Group these depth-shading props.
virtual ~WGEPostprocessingNode()
Destructor.
WPropBool m_shadeByDepth
Activate depth based darkening.
WPropBool m_showHud
Activate to show the texture HUDs.
WPropDouble m_depthShadeL
Lower depth shade threshold -> how dark to get.
WPropSelection m_activePostprocessor
The property containing the currently active method or a combination.
WPropDouble m_depthThresholdU
Upper depth threshold -> higher depth is foreground.
void postprocessorSelected()
Callback for changes in m_activePostprocessor.
WGEPostprocessingNode(osg::ref_ptr< WGECamera > reference, size_t width=2048, size_t height=2048, bool noHud=false)
Create a new post-processing node.
osg::ref_ptr< WGEGroupNode > m_childs
The group of child nodes to post-process.
WPropDouble m_depthThresholdL
Lower depth threshold -> lower depth is background.
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.
NodeShaderAssociation m_nodeShaderAssociation
List of nodes and their corresponding shader and preprocessor.
WPropGroup m_properties
All the properties of the post-processor.
void clear()
Removes all associated nodes.
WGEPostprocessor::ProcessorList m_postprocs
The postprocessors.
void remove(osg::ref_ptr< osg::Node > node)
Removes the node from the post-processing.
WPropGroup getProperties() const
Returns the set of properties controlling the post-processing node.
WPropBool m_active
If true, post-processing is enabled.
This class encapsulates a G-Buffer.
static PostprocessorInput attach(osg::ref_ptr< WGEOffscreenRenderPass > from)
Attaches the needed textures to the specified render pass and returns the G-Buffer.
osg::ref_ptr< osg::Texture2D > m_depthTexture
Depth.
static ProcessorList getPostprocessors()
Returns a list of all known postprocessor prototypes.
std::shared_ptr< WGEPostprocessor > SPtr
Convenience typedef for an osg::ref_ptr< WGEPostprocessor >.
std::vector< WGEPostprocessor::SPtr > ProcessorList
Type used for returning lists of postprocessor prototypes.
std::shared_ptr< WGEShaderPreprocessor > SPtr
Shared pointer for this class.
This is a WGEShaderDefineOptions class which additionally uses a property to automatically control th...
Class encapsulating the OSG Program class for a more convenient way of adding and modifying shader.
osg::ref_ptr< WGEShader > RefPtr
Convenience typedef for an osg::ref_ptr.
This callback is able to switch a osg::Switch node using a property.
A class containing a list of named items.
Class to manage properties of an object and to provide convenience methods for easy access and manipu...
T::iterator Iterator
A typedef for the correct iterator to traverse this sequence container.
std::shared_ptr< WSharedObjectTicketWrite< T > > WriteTicket
Type for write tickets.
WriteTicket getWriteTicket(bool suppressNotify=false) const
Returns a ticket to get write access to the contained data.
void addTo(WPropSelection prop)
Add the PC_NOTEMPTY constraint to the property.
void addTo(WPropSelection prop)
Add the PC_SELECTONLYONE constraint to the property.