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

This type of node basically is a convenience class for managing and creating offscreen renderings. More...

#include <WGEOffscreenRenderNode.h>

+ Inheritance diagram for WGEOffscreenRenderNode:
+ Collaboration diagram for WGEOffscreenRenderNode:

Public Types

typedef osg::ref_ptr< WGEOffscreenRenderNodeRefPtr
 Convenience typedef for an osg::ref_ptr. More...
 
typedef osg::ref_ptr< const WGEOffscreenRenderNodeConstRefPtr
 Convenience typedef for an osg::ref_ptr; const. More...
 
- Public Types inherited from WGEGroupNode
typedef WPredicateHelper::ArbitraryPredicateBase< osg::ref_ptr< osg::Node > const > NodePredicate
 The base type of predicate. More...
 

Public Member Functions

 WGEOffscreenRenderNode (osg::ref_ptr< WGECamera > reference, size_t width=2048, size_t height=2048, bool noHud=false)
 Create a new managing instance. More...
 
virtual ~WGEOffscreenRenderNode ()
 Destructor. More...
 
osg::ref_ptr< WGETextureHudgetTextureHUD () const
 Returns the instance of the texture HUD. More...
 
virtual osg::ref_ptr< WGEOffscreenRenderPassaddGeometryRenderPass (osg::ref_ptr< osg::Node > node, std::string name="Unnamed")
 Creates a new offscreen-render-pass coupled with the reference camera which renders a specified OSG graph to a texture. More...
 
virtual osg::ref_ptr< WGEOffscreenRenderPassaddGeometryRenderPass (osg::ref_ptr< osg::Node > node, osg::ref_ptr< WGEShader > shader, std::string name="Unnamed")
 Creates a new offscreen-render-pass coupled with the reference camera which renders a specified OSG graph to a texture. More...
 
virtual osg::ref_ptr< WGEOffscreenTexturePassaddTextureProcessingPass (std::string name="Unnamed")
 Creates a new offscreen-render-pass coupled with the reference camera which simply processes textures. More...
 
virtual osg::ref_ptr< WGEOffscreenTexturePassaddTextureProcessingPass (osg::ref_ptr< WGEShader > shader, std::string name="Unnamed")
 Creates a new offscreen-render-pass coupled with the reference camera which simply processes textures. More...
 
virtual osg::ref_ptr< WGEOffscreenFinalPassaddFinalOnScreenPass (std::string name="Unnamed")
 Creates a new render pass which can be seen as put-textures-back-on-screen-pass. More...
 
virtual osg::ref_ptr< WGEOffscreenFinalPassaddFinalOnScreenPass (osg::ref_ptr< WGEShader > shader, std::string name="Unnamed")
 Creates a new render pass which can be seen as put-textures-back-on-screen-pass. More...
 
template<typename T >
osg::ref_ptr< T > addRenderPass (std::string name="Unnamed")
 Creates a new offscreen-render-pass coupled with the reference camera. More...
 
size_t getTextureWidth () const
 Get FBO texture width. More...
 
size_t getTextureHeight () const
 Get FBO texture height. More...
 
void setLinkViewportToTextureSize (bool vp=true)
 If true, the viewport has the size of the resulting texture. More...
 
bool getLinkViewportToTextureSize () const
 The flag denotes whether the viewport is linked to the texture size or the reference camera. More...
 
- Public Member Functions inherited from WGEGroupNode
 WGEGroupNode ()
 Default constructor. More...
 
void insert (osg::ref_ptr< osg::Node > node)
 Adds the specified node to the child list of this node in a safe manner. More...
 
void remove (osg::ref_ptr< osg::Node > node)
 Removes the specified node from this group in a thread safe manner. More...
 
void remove_if (std::shared_ptr< WGEGroupNode::NodePredicate > predicate)
 Removes a node if the specified predicate evaluates to true. More...
 
void clear ()
 Removes all children from this node. More...
 

Private Attributes

osg::ref_ptr< WGECameram_referenceCamera
 The camera to which is used for setting this camera up. More...
 
osg::ref_ptr< WGETextureHudm_hud
 The pointer to the hud used to render all used texture buffers. More...
 
size_t m_textureWidth
 The width of each texture in this offscreen rendering. More...
 
size_t m_textureHeight
 The height of each texture in this offscreen rendering. More...
 
size_t m_nextPassNum
 The number of the next pass getting added. More...
 
bool m_forceViewportTextureSize
 Flag denotes whether the viewport is coupled to the reference camera or the texture size. More...
 

Additional Inherited Members

- Protected Types inherited from WGEGroupNode
enum  ChildOperationType { INSERT = 0 , REMOVE , REMOVE_IF , CLEAR }
 The type of operation to perform. More...
 
- Protected Member Functions inherited from WGEGroupNode
virtual ~WGEGroupNode ()
 Destructor. More...
 
- Protected Attributes inherited from WGEGroupNode
osg::ref_ptr< SafeUpdaterCallbackm_nodeUpdater
 Node callback used to update this root node. More...
 
std::queue< std::shared_ptr< ChildOperation > > m_childOperationQueue
 Queue of childs that need to be added/removed during the next update cycle. More...
 
std::shared_mutex m_childOperationQueueLock
 Lock used for inserting and removing childs into the child insertion/removal queue. More...
 
bool m_childOperationQueueDirty
 Flag denoting whether the m_childOperationQueue should be considered during the next update of the node. More...
 
bool m_removeAll
 True whenever all child nodes should be removed. More...
 

Detailed Description

This type of node basically is a convenience class for managing and creating offscreen renderings.

The children of this node should be of type WGEOffscreenRenderPass. This class provides factories to create offscreen-render-pass instances with proper sizes with a coupling to a reference camera. This is useful to provide automatic viewport scaling etc. to each render-pass. You do not explicitly need this class to create offscreen-renderings at all. You can manually manage multiple WGEOffscreenRenderPass instances.

It is important to understand, that the graph (your scene) must not be a children of this node. This node can be placed somewhere in your scene. The OSG collects all the cameras (and offscreen-cameras) and render then independently from their position in the graph (except for transformations inherited from others).

Note
Please not that you should not modify the whole wiring and offscreen configuration if the this node has been added as it is not thread-safe.

Definition at line 55 of file WGEOffscreenRenderNode.h.

Member Typedef Documentation

◆ ConstRefPtr

Convenience typedef for an osg::ref_ptr; const.

Definition at line 66 of file WGEOffscreenRenderNode.h.

◆ RefPtr

Convenience typedef for an osg::ref_ptr.

Definition at line 61 of file WGEOffscreenRenderNode.h.

Constructor & Destructor Documentation

◆ WGEOffscreenRenderNode()

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

Create a new managing instance.

It uses the specified camera as reference to all created offscreen-render-pass instances. Especially viewport, clear-mask and clear-color get used. The default texture resolution is 2048x2048 which is more than full-HD resolution. So it should be enough.

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 offscreen renderer.
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 44 of file WGEOffscreenRenderNode.cpp.

References WGEGroupNode::insert(), m_hud, and m_referenceCamera.

+ Here is the call graph for this function:

◆ ~WGEOffscreenRenderNode()

WGEOffscreenRenderNode::~WGEOffscreenRenderNode ( )
virtual

Destructor.

Definition at line 65 of file WGEOffscreenRenderNode.cpp.

Member Function Documentation

◆ addFinalOnScreenPass() [1/2]

osg::ref_ptr< WGEOffscreenFinalPass > WGEOffscreenRenderNode::addFinalOnScreenPass ( osg::ref_ptr< WGEShader shader,
std::string  name = "Unnamed" 
)
virtual

Creates a new render pass which can be seen as put-textures-back-on-screen-pass.

It renders a full-screen quad to the on-screen frame-buffer. An optional shader can be used for final processing (most commonly clipping, blending, color-mapping and so on).

Parameters
shaderthe shader to add
namethe name of the render pass. You should specify it to enable the nice debugging feature of WGETextureHud.
Returns
the on-screen render pass which draws processed textures back on screen.

Definition at line 125 of file WGEOffscreenRenderNode.cpp.

◆ addFinalOnScreenPass() [2/2]

osg::ref_ptr< WGEOffscreenFinalPass > WGEOffscreenRenderNode::addFinalOnScreenPass ( std::string  name = "Unnamed")
virtual

Creates a new render pass which can be seen as put-textures-back-on-screen-pass.

It renders a full-screen quad to the on-screen frame-buffer. An optional shader can be used for final processing (most commonly clipping, blending, color-mapping and so on).

Parameters
namethe name of the render pass. You should specify it to enable the nice debugging feature of WGETextureHud.
Returns
the on-screen render pass which draws processed textures back on screen.

Definition at line 119 of file WGEOffscreenRenderNode.cpp.

◆ addGeometryRenderPass() [1/2]

osg::ref_ptr< WGEOffscreenRenderPass > WGEOffscreenRenderNode::addGeometryRenderPass ( osg::ref_ptr< osg::Node >  node,
osg::ref_ptr< WGEShader shader,
std::string  name = "Unnamed" 
)
virtual

Creates a new offscreen-render-pass coupled with the reference camera which renders a specified OSG graph to a texture.

Parameters
nodethe node which represents the subgraph.
namethe name of the render pass. You should specify it to enable the nice debugging feature of WGETextureHud.
shaderthe shader to add.
Note
never forget to remove the returned node if not used anymore or use WGEGroup::clean.
Returns
the geometry render pass.

Definition at line 87 of file WGEOffscreenRenderNode.cpp.

◆ addGeometryRenderPass() [2/2]

osg::ref_ptr< WGEOffscreenRenderPass > WGEOffscreenRenderNode::addGeometryRenderPass ( osg::ref_ptr< osg::Node >  node,
std::string  name = "Unnamed" 
)
virtual

Creates a new offscreen-render-pass coupled with the reference camera which renders a specified OSG graph to a texture.

Parameters
nodethe node which represents the subgraph.
namethe name of the render pass. You should specify it to enable the nice debugging feature of WGETextureHud.
Note
never forget to remove the returned node if not used anymore or use WGEGroup::clean.
Returns
the geometry render pass.

Definition at line 70 of file WGEOffscreenRenderNode.cpp.

References wge::generateDynamicCullProxy(), and WGEGroupNode::insert().

+ Here is the call graph for this function:

◆ addRenderPass()

template<typename T >
osg::ref_ptr< T > WGEOffscreenRenderNode::addRenderPass ( std::string  name = "Unnamed")

Creates a new offscreen-render-pass coupled with the reference camera.

This pass actually does nothing. The method is useful for custom variants of WGEOffscreenRenderPass.

Parameters
namethe name of the render pass. You should specify it to enable the nice debugging feature of WGETextureHud.
Returns
new instance of a plain render pass
Template Parameters
Tthe type of pass to create.

Definition at line 246 of file WGEOffscreenRenderNode.h.

References WGEGroupNode::insert(), m_forceViewportTextureSize, m_hud, m_nextPassNum, m_referenceCamera, m_textureHeight, and m_textureWidth.

+ Here is the call graph for this function:

◆ addTextureProcessingPass() [1/2]

osg::ref_ptr< WGEOffscreenTexturePass > WGEOffscreenRenderNode::addTextureProcessingPass ( osg::ref_ptr< WGEShader shader,
std::string  name = "Unnamed" 
)
virtual

Creates a new offscreen-render-pass coupled with the reference camera which simply processes textures.

All the in- and output textures have to be specified manually.

Note
never forget to remove the returned node if not used anymore or use WGEGroup::clean.
Parameters
namethe name of the render pass. You should specify it to enable the nice debugging feature of WGETextureHud.
shaderthe shader to add.
Returns
the texture processing pass created.

Definition at line 112 of file WGEOffscreenRenderNode.cpp.

◆ addTextureProcessingPass() [2/2]

osg::ref_ptr< WGEOffscreenTexturePass > WGEOffscreenRenderNode::addTextureProcessingPass ( std::string  name = "Unnamed")
virtual

Creates a new offscreen-render-pass coupled with the reference camera which simply processes textures.

All the in- and output textures have to be specified manually.

Note
never forget to remove the returned node if not used anymore or use WGEGroup::clean.
Parameters
namethe name of the render pass. You should specify it to enable the nice debugging feature of WGETextureHud.
Returns
the texture processing pass created.

Definition at line 106 of file WGEOffscreenRenderNode.cpp.

◆ getLinkViewportToTextureSize()

bool WGEOffscreenRenderNode::getLinkViewportToTextureSize ( ) const

The flag denotes whether the viewport is linked to the texture size or the reference camera.

See setLinkViewportToTextureSize for details.

Returns
the flag.

Definition at line 152 of file WGEOffscreenRenderNode.cpp.

References m_forceViewportTextureSize.

◆ getTextureHeight()

size_t WGEOffscreenRenderNode::getTextureHeight ( ) const

Get FBO texture height.

Returns
the height

Definition at line 142 of file WGEOffscreenRenderNode.cpp.

References m_textureHeight.

◆ getTextureHUD()

osg::ref_ptr< WGETextureHud > WGEOffscreenRenderNode::getTextureHUD ( ) const

Returns the instance of the texture HUD.

Returns
the HUD

Definition at line 132 of file WGEOffscreenRenderNode.cpp.

References m_hud.

◆ getTextureWidth()

size_t WGEOffscreenRenderNode::getTextureWidth ( ) const

Get FBO texture width.

Returns
the width

Definition at line 137 of file WGEOffscreenRenderNode.cpp.

References m_textureWidth.

◆ setLinkViewportToTextureSize()

void WGEOffscreenRenderNode::setLinkViewportToTextureSize ( bool  vp = true)

If true, the viewport has the size of the resulting texture.

This is very interesting if you want to force large scale renderings and want to decouple your offscreen pass from the reference camera viewport.

Parameters
vpif true, viewport is forced to be the whole texture size

Definition at line 147 of file WGEOffscreenRenderNode.cpp.

References m_forceViewportTextureSize.

Member Data Documentation

◆ m_forceViewportTextureSize

bool WGEOffscreenRenderNode::m_forceViewportTextureSize
private

Flag denotes whether the viewport is coupled to the reference camera or the texture size.

Definition at line 242 of file WGEOffscreenRenderNode.h.

Referenced by addRenderPass(), getLinkViewportToTextureSize(), and setLinkViewportToTextureSize().

◆ m_hud

osg::ref_ptr< WGETextureHud > WGEOffscreenRenderNode::m_hud
private

The pointer to the hud used to render all used texture buffers.

This can be NULL. It gets distributed to all created render-pass instances.

Definition at line 222 of file WGEOffscreenRenderNode.h.

Referenced by addRenderPass(), getTextureHUD(), and WGEOffscreenRenderNode().

◆ m_nextPassNum

size_t WGEOffscreenRenderNode::m_nextPassNum
private

The number of the next pass getting added.

Definition at line 237 of file WGEOffscreenRenderNode.h.

Referenced by addRenderPass().

◆ m_referenceCamera

osg::ref_ptr< WGECamera > WGEOffscreenRenderNode::m_referenceCamera
private

The camera to which is used for setting this camera up.

Definition at line 216 of file WGEOffscreenRenderNode.h.

Referenced by addRenderPass(), and WGEOffscreenRenderNode().

◆ m_textureHeight

size_t WGEOffscreenRenderNode::m_textureHeight
private

The height of each texture in this offscreen rendering.

Definition at line 232 of file WGEOffscreenRenderNode.h.

Referenced by addRenderPass(), and getTextureHeight().

◆ m_textureWidth

size_t WGEOffscreenRenderNode::m_textureWidth
private

The width of each texture in this offscreen rendering.

Definition at line 227 of file WGEOffscreenRenderNode.h.

Referenced by addRenderPass(), and getTextureWidth().


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