Re: [osg-users] Create a custom RenderStage
Hi Paul, Thanks a lot, these are very intersting informations ! Actually, I need to use custom RenderStages and not only RenderBins because I want to render to different FBO's (for pre and post process purposes) - Editing manually the RenderGraph sounds a little bit complicated to me - Creating a "CustomNode" class as you suggest is very close to using multiple cameras : it leads to scene graph manipulations as the nodes rendered into this RenderStage need to be child of the "CustomNode" and I would like to avoid this I'm still looking for a way to create a RenderBin prototype which is actually a RenderStage instance and re-implement its "reset" (and probably others) method to make it works. The final goal is to easily move individual nodes from a RenderStage to another without editing the scene graph, just edit the StateSet's RenderBin -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51753#51753 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Create a custom RenderStage
The CullVisitor traverses the scene graph and assembles a render graph. The structure of the render graph is composed of RenderBins, some of which might actually be RenderStages. The current RenderBin changes under two circumstances: - The CullVisitor encounters a Node with a StateSet whose RenderBin details require a different RenderBin. - The CullVisitor encounters a Camera, or some custom Node that calls into the CullVisitor to change the RenderBin. The CullVisitor contains built-in support for Camera. The CullVisitor changes the RenderBin to the Camera's RenderStage during CullVisitor::apply(Camera&). If you want to derive a class from RenderStage and insert it into the render graph, you can do that with a custom Node class. But because CullVisitor doesn't know about your custom Node, you must overrides Node::traverse(). In that method, call into the CullVisitor to set your custom RenderStage. I have done this before, and it does work. Most recently, I used a custom RenderStage to implement depth peeling in which occlusion query was used to determine the number of passes. You might also be able to insert a custom RenderStage by editing the render graph directly, perhaps with an osgViewer Operation. I have never tried this approach. There is no way to "register" a RenderStage for Cameras to use, as far as I know. But as you already know, you can do this with RenderBin. So if you don't require any of the functionality of RenderStage, then perhaps a custom RenderBin would suffice. Hope this helps, -Paul On 1/2/2013 1:01 AM, Aurelien Albert wrote: Hi, I use differents custom RenderStages : as pre-renderstage for pre-processing and as post-renderstage for post processing. These processing are executed using FBO render targets. Currently I'm doing that with slaves cameras, but : - the "RenderStage" class is derived from the "RenderBin" class - it is possible to register new RenderBins using the "addRenderBinPrototype" method So I wonder if it is possible to create a new RenderStage prototype to replace my slave cameras ? How to configure the rendertarget of these renderstages ? My goal here is to learn how to create / customize RenderStages and RenderBins. Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51746#51746 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Create a custom RenderStage
Thanks for these informations, I'll try to do something with that. I was thinking about a more simple approach : - register a RenderBin prototype which is a class deriver from RenderStage - use this renderbin for some nodes I've already created custom RenderBin prototypes (it's pretty easy, just override the needed method) but the RenderStage class seems to need more parameters (renderTarget, writeBuffer...). My first idea was to hardcode (for testing) these parameters in "MyRenderStageBin" constructor, but I don't know which values to use. -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51750#51750 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Create a custom RenderStage
Hi Aurelien, Oh, that's an interesting idea that not intrude the scene graph but with a special renderbin mode. I have never tried but know there is a Camera::setRenderingCache() method that would provide RenderStage instance corresponding with each camera node. It is used in osgUtil/CullVisitor, which has an internal RenderingCache class. Maybe you could do something here to replace the RenderingCache to your own one. W.r.t the creation of RenderBin instances, it is done in CullVisitor::pushStateSet() and can hardly be re-implemented unless you rewrite some source code of OSG itself, I think. Hope it helps, Wang Rui 2013/1/2 Aurelien Albert > Hi Wang, > > Thanks for your quick answer ! > > I'm already doing pre and post-processing of various king : tone-mapping, > DOF, motion blur... using multiple cameras, slave or childs. > > Now I'm trying to create custom renderstages, without multiple cameras, > but using a RenderBin prototype. This could be very usefull in some > situations, for example : > > - having a graph with a parent group and 3 childs : "A", "B" and "C" > - render node "A" and node "C" using a custom pre-renderstage > - render node "B" as usual > > To do so with multiple cameras, the graph need to be manipulated to create > a new camera and move "A" and "C" under this camera. > > Using a custom RenderStage registered as a RenderBin prototype, there is > no need to edit the scene graph, but just edit the "RenderBin" of A and C > statesets. > > In this situation, culling and events traversal are also done as described > in the "main graph" : > > - parent > ---> A > ---> B > ---> C > > But whith multiple cameras it leads to something like : > > - parent > ---> child camera > --> A > --> C > ---> B > > > > Cheers, > Aurelien > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=51748#51748 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Create a custom RenderStage
Hi Wang, Thanks for your quick answer ! I'm already doing pre and post-processing of various king : tone-mapping, DOF, motion blur... using multiple cameras, slave or childs. Now I'm trying to create custom renderstages, without multiple cameras, but using a RenderBin prototype. This could be very usefull in some situations, for example : - having a graph with a parent group and 3 childs : "A", "B" and "C" - render node "A" and node "C" using a custom pre-renderstage - render node "B" as usual To do so with multiple cameras, the graph need to be manipulated to create a new camera and move "A" and "C" under this camera. Using a custom RenderStage registered as a RenderBin prototype, there is no need to edit the scene graph, but just edit the "RenderBin" of A and C statesets. In this situation, culling and events traversal are also done as described in the "main graph" : - parent ---> A ---> B ---> C But whith multiple cameras it leads to something like : - parent ---> child camera --> A --> C ---> B Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51748#51748 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Re: [osg-users] Create a custom RenderStage
Hi Aurelien, The OpenSceneGraph Cookbook provides a simple Depth-of-Field example that implements post-processing work with multiple camera ndoes (not slaves). You may have a look at it at https://github.com/xarray/osgRecipes . FYI, It also includes an osgeffectcompositor example that provides an initial deferred shading solution for OSG developers. Wang Rui 2013/1/2 Aurelien Albert > Hi, > > I use differents custom RenderStages : as pre-renderstage for > pre-processing and as post-renderstage for post processing. > > These processing are executed using FBO render targets. > > Currently I'm doing that with slaves cameras, but : > - the "RenderStage" class is derived from the "RenderBin" class > - it is possible to register new RenderBins using the > "addRenderBinPrototype" method > > So I wonder if it is possible to create a new RenderStage prototype to > replace my slave cameras ? > > How to configure the rendertarget of these renderstages ? > > My goal here is to learn how to create / customize RenderStages and > RenderBins. > > Thank you! > > Cheers, > Aurelien > > -- > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=51746#51746 > > > > > > ___ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org > ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
[osg-users] Create a custom RenderStage
Hi, I use differents custom RenderStages : as pre-renderstage for pre-processing and as post-renderstage for post processing. These processing are executed using FBO render targets. Currently I'm doing that with slaves cameras, but : - the "RenderStage" class is derived from the "RenderBin" class - it is possible to register new RenderBins using the "addRenderBinPrototype" method So I wonder if it is possible to create a new RenderStage prototype to replace my slave cameras ? How to configure the rendertarget of these renderstages ? My goal here is to learn how to create / customize RenderStages and RenderBins. Thank you! Cheers, Aurelien -- Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=51746#51746 ___ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org