29 #include "../../common/WAssert.h"
30 #include "../WGEUtils.h"
32 #include "WGEOffscreenRenderNode.h"
34 bool isPowerOfTwo(
size_t x )
36 return ( ( x != 0 ) && ( ( x & ( ~x + 1 ) ) == x ) );
39 bool checkTextureSize(
size_t size )
41 return !( ( size > 8192 ) || ( size < 8 ) );
46 m_referenceCamera( reference ),
48 m_textureWidth( width ),
49 m_textureHeight( height ),
51 m_forceViewportTextureSize( false )
53 WAssert( checkTextureSize( width ) && checkTextureSize( height ),
"Invalid offscreen texture size. Must be power of two and in [8,4096]." );
60 m_hud->coupleViewportWithTextureViewport();
73 osg::ref_ptr< WGEOffscreenRenderPass > pass = addRenderPass< WGEOffscreenRenderPass >( name );
74 pass->addChild( node );
88 osg::ref_ptr< WGEShader > shader,
92 osg::ref_ptr< WGEOffscreenRenderPass > pass = addRenderPass< WGEOffscreenRenderPass >( name );
93 pass->addChild( node );
94 shader->apply( pass );
108 osg::ref_ptr< WGEOffscreenTexturePass > pass = addRenderPass< WGEOffscreenTexturePass >( name );
114 osg::ref_ptr< WGEOffscreenTexturePass > pass = addRenderPass< WGEOffscreenTexturePass >( name );
115 shader->apply( pass );
121 osg::ref_ptr< WGEOffscreenFinalPass > pass = addRenderPass< WGEOffscreenFinalPass >( name );
127 osg::ref_ptr< WGEOffscreenFinalPass > pass = addRenderPass< WGEOffscreenFinalPass >( name );
128 shader->apply( pass );
Class to wrap around the osg Group node and providing a thread safe add/removal mechanism.
void insert(osg::ref_ptr< osg::Node > node)
Adds the specified node to the child list of this node in a safe manner.
osg::ref_ptr< WGETextureHud > getTextureHUD() const
Returns the instance of the texture HUD.
size_t getTextureWidth() const
Get FBO texture width.
virtual ~WGEOffscreenRenderNode()
Destructor.
size_t m_textureHeight
The height of each texture in this offscreen rendering.
void setLinkViewportToTextureSize(bool vp=true)
If true, the viewport has the size of the resulting texture.
virtual osg::ref_ptr< WGEOffscreenFinalPass > addFinalOnScreenPass(std::string name="Unnamed")
Creates a new render pass which can be seen as put-textures-back-on-screen-pass.
WGEOffscreenRenderNode(osg::ref_ptr< WGECamera > reference, size_t width=2048, size_t height=2048, bool noHud=false)
Create a new managing instance.
osg::ref_ptr< WGECamera > m_referenceCamera
The camera to which is used for setting this camera up.
size_t m_textureWidth
The width of each texture in this offscreen rendering.
osg::ref_ptr< WGETextureHud > m_hud
The pointer to the hud used to render all used texture buffers.
bool m_forceViewportTextureSize
Flag denotes whether the viewport is coupled to the reference camera or the texture size.
virtual osg::ref_ptr< WGEOffscreenRenderPass > addGeometryRenderPass(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 g...
bool getLinkViewportToTextureSize() const
The flag denotes whether the viewport is linked to the texture size or the reference camera.
virtual osg::ref_ptr< WGEOffscreenTexturePass > addTextureProcessingPass(std::string name="Unnamed")
Creates a new offscreen-render-pass coupled with the reference camera which simply processes textures...
size_t getTextureHeight() const
Get FBO texture height.
This class implements a HUD showing several textures on screen.
This callback is useful to update viewport information on several nodes supporting it.
osg::ref_ptr< osg::Node > generateDynamicCullProxy(osg::ref_ptr< osg::Node > node)
Generate a proxy cube, which ensures OSG does proper near-far plane calculation and culling.