OpenWalnut  1.5.0dev
Public Types | Public Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
WGEPostprocessingNode Class Reference

This class enables you to add arbitrary nodes that get post-processed in screen space. More...

#include <WGEPostprocessingNode.h>

+ Inheritance diagram for WGEPostprocessingNode:
+ Collaboration diagram for WGEPostprocessingNode:

Public Types

typedef osg::ref_ptr< WGEPostprocessingNodeRefPtr
 Convenience typedef for an osg::ref_ptr. More...
 
typedef osg::ref_ptr< const WGEPostprocessingNodeConstRefPtr
 Convenience typedef for an osg::ref_ptr; const. More...
 

Public Member Functions

 WGEPostprocessingNode (osg::ref_ptr< WGECamera > reference, size_t width=2048, size_t height=2048, bool noHud=false)
 Create a new post-processing node. More...
 
virtual ~WGEPostprocessingNode ()
 Destructor. More...
 
WPropGroup getProperties () const
 Returns the set of properties controlling the post-processing node. More...
 
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. More...
 
void remove (osg::ref_ptr< osg::Node > node)
 Removes the node from the post-processing. More...
 
void clear ()
 Removes all associated nodes. More...
 
WGEPostprocessor::SPtr getCurrentPostprocessor () const
 The post processor currently in use. More...
 

Private Types

typedef WSharedAssociativeContainer< std::map< osg::ref_ptr< osg::Node >, std::pair< WGEShader::RefPtr, WGEShaderPreprocessor::SPtr > > > NodeShaderAssociation
 This type is used to actually store the association between a node and its associated shader and custom preprocessor. More...
 

Private Member Functions

void postprocessorSelected ()
 Callback for changes in m_activePostprocessor. More...
 

Private Attributes

NodeShaderAssociation m_nodeShaderAssociation
 List of nodes and their corresponding shader and preprocessor. More...
 
osg::ref_ptr< WGEGroupNodem_childs
 The group of child nodes to post-process. More...
 
WPropGroup m_properties
 All the properties of the post-processor. More...
 
WPropBool m_active
 If true, post-processing is enabled. More...
 
WPropBool m_showHud
 Activate to show the texture HUDs. More...
 
WPropBool m_shadeByDepth
 Activate depth based darkening. More...
 
WPropDouble m_depthThresholdL
 Lower depth threshold -> lower depth is background. More...
 
WPropDouble m_depthThresholdU
 Upper depth threshold -> higher depth is foreground. More...
 
WPropDouble m_depthShadeL
 Lower depth shade threshold -> how dark to get. More...
 
WPropDouble m_depthShadeU
 Upper depth threshold -> how bright to get. More...
 
WPropGroup m_depthGroup
 Group these depth-shading props. More...
 
WPropSelection m_activePostprocessor
 The property containing the currently active method or a combination. More...
 
WGEPostprocessor::ProcessorList m_postprocs
 The postprocessors. More...
 

Detailed Description

This class enables you to add arbitrary nodes that get post-processed in screen space.

The only thing you need to take care of is your shader. You need some special parts in it. Please see the all-in-one super-shader-example module WMShaderExample in modules/template.

Note
Although this is an osg::Switch node, you should avoid using its inherited API unless you know what you do. Using the osg::Switch API might be useful for those who want to modify the post-processing pipeline.

Definition at line 54 of file WGEPostprocessingNode.h.

Member Typedef Documentation

◆ ConstRefPtr

Convenience typedef for an osg::ref_ptr; const.

Definition at line 65 of file WGEPostprocessingNode.h.

◆ NodeShaderAssociation

typedef WSharedAssociativeContainer< std::map< osg::ref_ptr< osg::Node >, std::pair< WGEShader::RefPtr, WGEShaderPreprocessor::SPtr > > > WGEPostprocessingNode::NodeShaderAssociation
private

This type is used to actually store the association between a node and its associated shader and custom preprocessor.

Definition at line 141 of file WGEPostprocessingNode.h.

◆ RefPtr

Convenience typedef for an osg::ref_ptr.

Definition at line 60 of file WGEPostprocessingNode.h.

Constructor & Destructor Documentation

◆ WGEPostprocessingNode()

WGEPostprocessingNode::WGEPostprocessingNode ( osg::ref_ptr< WGECamera reference,
size_t  width = 2048,
size_t  height = 2048,
bool  noHud = false 
)

Create a new post-processing node.

It uses the WGEOffscreenRenderNode to setup an offscreen, shader-based post-processing for rendered images. This is not limited to geometry but can also be used for ray-traced images.

Note
The width and hight define the offscreen texture size. The viewport if each rendering is automatically set to the one of the reference camera. This means, width and height only define the maximal supported resolution without upscaling of your postprocessor.
Parameters
referencecamera used as reference
widththe width of the textures used in this rendering. Must be in [8,4096] and a power of two.
heightthe height of the textures used in this rendering. Must be in [8,4096] and a power of two.
noHudIf true, no hud gets displayed showing the created and used textures.

Definition at line 35 of file WGEPostprocessingNode.cpp.

References WPropertyHelper::PC_SELECTONLYONE::addTo(), WPropertyHelper::PC_NOTEMPTY::addTo(), WGEPostprocessor::PostprocessorInput::attach(), WGEPostprocessor::getPostprocessors(), m_active, m_activePostprocessor, m_childs, m_depthGroup, m_depthShadeL, m_depthShadeU, WGEPostprocessor::PostprocessorInput::m_depthTexture, m_depthThresholdL, m_depthThresholdU, m_postprocs, m_properties, m_shadeByDepth, m_showHud, and postprocessorSelected().

+ Here is the call graph for this function:

◆ ~WGEPostprocessingNode()

WGEPostprocessingNode::~WGEPostprocessingNode ( )
virtual

Destructor.

Definition at line 145 of file WGEPostprocessingNode.cpp.

Member Function Documentation

◆ clear()

void WGEPostprocessingNode::clear ( )

Removes all associated nodes.

Note
this is thread-safe and can be done from every thread

Definition at line 193 of file WGEPostprocessingNode.cpp.

References WSharedObject< T >::getWriteTicket(), m_childs, and m_nodeShaderAssociation.

+ Here is the call graph for this function:

◆ getCurrentPostprocessor()

WGEPostprocessor::SPtr WGEPostprocessingNode::getCurrentPostprocessor ( ) const

The post processor currently in use.

Returns
the current post processor

Definition at line 209 of file WGEPostprocessingNode.cpp.

References m_activePostprocessor, and m_postprocs.

◆ getProperties()

WPropGroup WGEPostprocessingNode::getProperties ( ) const

Returns the set of properties controlling the post-processing node.

You can use them to provide them to the user for example.

Returns
the properties as a group.

Definition at line 150 of file WGEPostprocessingNode.cpp.

References m_properties.

◆ insert()

void WGEPostprocessingNode::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.

See class documentation for further details on how the shader gets modified. If you are using an group node, be yourself aware that all nodes in this group need to have the same shader! If not, post-processing will not work properly.

Note
this is thread-safe and can be done from every thread
it does NOT apply the shader.
Parameters
nodethe node to post-process
shaderthe shader used for the node

Definition at line 155 of file WGEPostprocessingNode.cpp.

References WSharedObject< T >::getWriteTicket(), m_active, m_childs, and m_nodeShaderAssociation.

+ Here is the call graph for this function:

◆ postprocessorSelected()

void WGEPostprocessingNode::postprocessorSelected ( )
private

Callback for changes in m_activePostprocessor.

Definition at line 214 of file WGEPostprocessingNode.cpp.

References m_active, m_activePostprocessor, m_depthGroup, and m_postprocs.

Referenced by WGEPostprocessingNode().

+ Here is the caller graph for this function:

◆ remove()

void WGEPostprocessingNode::remove ( osg::ref_ptr< osg::Node >  node)

Removes the node from the post-processing.

If it is not in the post-processing pipeline, nothing happens.

Note
this is thread-safe and can be done from every thread
Parameters
nodethe node to remove

Definition at line 174 of file WGEPostprocessingNode.cpp.

References WSharedObject< T >::getWriteTicket(), m_childs, and m_nodeShaderAssociation.

+ Here is the call graph for this function:

Member Data Documentation

◆ m_active

WPropBool WGEPostprocessingNode::m_active
private

If true, post-processing is enabled.

Definition at line 161 of file WGEPostprocessingNode.h.

Referenced by insert(), postprocessorSelected(), and WGEPostprocessingNode().

◆ m_activePostprocessor

WPropSelection WGEPostprocessingNode::m_activePostprocessor
private

The property containing the currently active method or a combination.

Definition at line 201 of file WGEPostprocessingNode.h.

Referenced by getCurrentPostprocessor(), postprocessorSelected(), and WGEPostprocessingNode().

◆ m_childs

osg::ref_ptr< WGEGroupNode > WGEPostprocessingNode::m_childs
private

The group of child nodes to post-process.

Definition at line 151 of file WGEPostprocessingNode.h.

Referenced by clear(), insert(), remove(), and WGEPostprocessingNode().

◆ m_depthGroup

WPropGroup WGEPostprocessingNode::m_depthGroup
private

Group these depth-shading props.

Definition at line 196 of file WGEPostprocessingNode.h.

Referenced by postprocessorSelected(), and WGEPostprocessingNode().

◆ m_depthShadeL

WPropDouble WGEPostprocessingNode::m_depthShadeL
private

Lower depth shade threshold -> how dark to get.

Definition at line 186 of file WGEPostprocessingNode.h.

Referenced by WGEPostprocessingNode().

◆ m_depthShadeU

WPropDouble WGEPostprocessingNode::m_depthShadeU
private

Upper depth threshold -> how bright to get.

Definition at line 191 of file WGEPostprocessingNode.h.

Referenced by WGEPostprocessingNode().

◆ m_depthThresholdL

WPropDouble WGEPostprocessingNode::m_depthThresholdL
private

Lower depth threshold -> lower depth is background.

Definition at line 176 of file WGEPostprocessingNode.h.

Referenced by WGEPostprocessingNode().

◆ m_depthThresholdU

WPropDouble WGEPostprocessingNode::m_depthThresholdU
private

Upper depth threshold -> higher depth is foreground.

Definition at line 181 of file WGEPostprocessingNode.h.

Referenced by WGEPostprocessingNode().

◆ m_nodeShaderAssociation

NodeShaderAssociation WGEPostprocessingNode::m_nodeShaderAssociation
private

List of nodes and their corresponding shader and preprocessor.

Definition at line 146 of file WGEPostprocessingNode.h.

Referenced by clear(), insert(), and remove().

◆ m_postprocs

WGEPostprocessor::ProcessorList WGEPostprocessingNode::m_postprocs
private

The postprocessors.

Definition at line 206 of file WGEPostprocessingNode.h.

Referenced by getCurrentPostprocessor(), postprocessorSelected(), and WGEPostprocessingNode().

◆ m_properties

WPropGroup WGEPostprocessingNode::m_properties
private

All the properties of the post-processor.

Definition at line 156 of file WGEPostprocessingNode.h.

Referenced by getProperties(), and WGEPostprocessingNode().

◆ m_shadeByDepth

WPropBool WGEPostprocessingNode::m_shadeByDepth
private

Activate depth based darkening.

Definition at line 171 of file WGEPostprocessingNode.h.

Referenced by WGEPostprocessingNode().

◆ m_showHud

WPropBool WGEPostprocessingNode::m_showHud
private

Activate to show the texture HUDs.

Definition at line 166 of file WGEPostprocessingNode.h.

Referenced by WGEPostprocessingNode().


The documentation for this class was generated from the following files: