[osg-users] Executing subtree multiple times / repeater node?

Julien Valentin julienvalentin51 at gmail.com
Thu Sep 14 04:27:58 PDT 2017


I don't think there's a builtin/elegant solution for this in osg
What I did for the purpose of iterative algorithms with pingpong FBO I did smething like this

Code:
class FBOWritter public Geometry{
    void setFBO(FrameBufferObject);
    void setPingPongTexture(Texture*,texture*);
    void setHalfPassCount()
    draimplementation(){
        state.bind(fbo)
        for(i in 0..halpasscount){
            fbo.framebuffertexture(pingpong[1])
            Geometry::drawimplementation()
            fbo.framebuffertexture(pingpong[0])
            Geometry::drawimplementation()
        }
    }
};



And I put this FBOwritter as Child as a camera2FBO.
It avoid the requirement of multiple camera setup and so work pretty great but don't know if there's a better alternative..
Cheers


antiro42 wrote:
> Hi,
> 
> I am implementing a Gaussian blur effect by alternating between a horizontal and a vertical blur shader (in the implementation they are the same shader, switching based on a uniform).
> 
> In OSG I managed to implement this by adding the two shaders to geometry nodes containing a screen sized quad and having the camera configured for rendering to a texture. To get the best looking effect I want to execute this pair of shaders several times in a single frame. I can of course add the pair of nodes to the scene graph multiple times, but there must be a more elegant solution:
> 
> Is there some kind of "repeater" node which simple executes its subtree multiple times?
> 
> If not, how would I implement such a node? Should I write a new traverse method? How to handle the different kinds of visitors?
> 
> Thank you!
> 
> Cheers,
> antiro


------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71721#71721







More information about the osg-users mailing list