Hello Carsten, thank you for your detailed answer. It definitely made things clearer to me. I have wrapped the setup for the scene render and post process with push/popPartition() commands and things look better.
However, it seems that the contents of the FBO is not cleared between consecutive frames. How can i schedule a glClearColor(...); glClear(...); after the FBO is bound and before a call to recurseFromThis()? I looked at the code of the RenderPartition class and the OSG::RenderPartition::setupExecution() function calls _pBackground->clear(&_oDrawEnv); if the RenderPartition::BackgroundSetup flag is set. Therefore i tried: DepthPeelingStage::renderEnter() { //init setup similar to HDRStage implementation pPart->setRenderTarget(<myFBO>); pPart->setBackground(pBack); pPart->addSetupModeBit(RenderPartition::BackgroundSetup); //if not first pass pushState() and add stage overrides here recurseFromThis(renderAction); //popState(), popPartition(), schedule postProcess, etc. } But this shows no effect i.e. the contents is still not cleared. Any idea? Regarding the EXT_shader_image_load_store extension it requires OpenGL 3.0 and GLSL 1.30 unfortunately, see http://developer.download.nvidia.com/opengl/specs/GL_EXT_shader_image_load_store.txt Can i still use the mechanism you described for getting the function pointer? Thanks. Kind regards, Alexander Lang > Hello Andreas, > > On 09/11/2012 07:35 AM, Alexander Lang wrote: >> DepthPeelingStage::renderEnter(Action* action) >> { >> beginPartitionGroup >> pushPartition >> >> //init similar to HDR implementation >> >> setRenderTarget(myFBO) >> renderPartition->setBackground(background); >> background->clear() >> //initialize depth buffer: draw Scene >> this->recurseFromThis() >> >> for (number of passes) >> { >> setRenderTarget(myOtherFBO) >> setBackground(...) >> background->setAlpha(...) >> background->clear() >> >> renderPartition->pushState() >> //set new state for pass i: add blend, texture and depth chunks >> renderPartition->addOverride(...) >> this->recurseFromThis() >> renderPartition->popState() >> >> //Post process: draw quad textured with contents of this pass >> //similar to HDR stage implementation >> pushPartition() >> //setup projection >> RenderPartition::SimpleDrawCallback f; >> >> f = boost::bind(&DepthPeelingStage::postProcess, >> this, _1); > > possibly a typo, but pPart->dropFunctor(f); is missing here, otherwise > the post processing is not being run. > >> popPartition() >> >> } >> >> popPartition >> endPartitionGroup >> } >> >> DepthPeelingStage::postProcess(DrawEnv*) >> { >> //get data >> //activate FBO if not final >> //activate material state >> //draw quad with glBegin()/glEnd() >> //deactivate material state >> //deactivate FBO >> } >> >> With this setup the scene gets rendered to a texture which is displayed >> by >> the quad but i do not see effects of other passes. >> Therefore, i have several questions, hopefully you could help me >> understand the internals of OpenSG better: >> >> - Does this sound like a valid setup with the main work done in >> renderEnter()? > > yes, keep in mind though that during scene traversal (i.e. when > renderEnter() is called) nothing is actually drawn, only the partitions > are set up and the work they are to do at draw time is specified. > >> - Why is the SimpleCallback required? > > see above, the actual work is done after scene traversal, so you need to > delay work until then. > >> Could postProcess not be called >> directly within renderEnter()? When is the callback executed in regards >> to >> the for-loop? > > every iteration of the loop must create a new partition, using > pushPartition() and then getActivePartition() to get a pointer to it and > set things like the FBO etc. > >> - What does a RenderPartition do? > > a render partition is a pass or a chunk of work to be done when objects > are drawn. > >> When do you have to call >> beginPartitionGroup() and pushPartition()? > > pushPartition() creates a new partition, so you need to call it when you > start a new pass. Partitions are normally processed in reverse order > from when they are created, if you begin a group the partitions in the > group are processed in the order they are created in. > >> Does each render pass have to >> be wrapped in such a pair or does it suffice to call these at the begin >> and end of renderEnter() > > each pass needs to be a partition, otherwise state sorting will draw > objects in whatever order it deems most efficient without respecting > pass boundaries. > >> - How could i have a texture that is set up within this stage available >> in >> the shader code of the user? I tried: >> >> pRenderPartition->addOverride(pTextureObjChunk->getClassId(), >> pTextureObjChunk); > > IIRC that should make the texture available in texture unit 0. > >> followed by the call to recurseFromThis() but this showed no effect. I >> replaced pTextureObjChunk->getClassId() with 0 or 1 since i assumed this >> would set the texture unit but that did not work either. > > the class id is not the texture unit; class id + 0 is texture unit 0, > class id + 1 is texture unit 1, etc. (at least that's what it used to be). > >> - The HDR stage and others use direct OpenGL calls. Can any FC >> implementation call arbitrary OpenGL functions that work in a >> distributed >> environment? > > OpenSG does not contain crystal ball technology ;) You have to know what > you are doing and in particular be careful to reset any state you > change, otherwise OpenSG's state tracking is going to be confused and > you get "interesting" result. > >> I look forward to any answer. My concern is to have a way to correctly >> display transparent geometry within OpenSG. >> As a last note, what is required to integrate new OpenGL functions into >> OpenSG? More specifically if the functionality of glBindImageTexture() >> was >> available in OpenSG, the A-Buffer algorithm (see Cyril Crassin's >> approach: >> http://blog.icare3d.org/2010/06/fast-and-accurate-single-pass-buffer.html) >> could be used and multiple render passes would not be required any >> longer >> for correct transparency. > > Is there an OpenGL extension that makes glBindImageTexture() available > in OpenGL 2 contexts? > If so, you can add prototypes for the extension to > Source/Base/Base/OSGGLFuncProtos.h > Add a static UInt32 _extSomeExtension extension id to your stage. > Add for each function added by the extension static UInt32 > FuncIdBindImageTexture extension function ids to your stage. > You register the extension and extension functions in > DepthPeelingStage::initMethod() - see > Source/System/State/Shader/Base/OSGShaderProgram.cpp for an example. > To call such an extension function you place a line like: > > OSGGETGLFUNCBYID_GL3_ES(glCreateShader, > osgGlCreateShader, > FuncIdCreateShader, > pWin); > > before you call it, to get a function pointer that is valid for the > current context and then use osgGlCreateShader() as if it was > glCreateShader() - again OSGShaderProgram.cpp has example usage. > > Cheers, > Carsten > > ------------------------------------------------------------------------------ > Live Security Virtual Conference > Exclusive live event will cover all the ways today's security and > threat landscape has changed and how IT managers can respond. Discussions > will include endpoint security, mobile security and the latest in malware > threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ > _______________________________________________ > Opensg-users mailing list > Opensg-users@lists.sourceforge.net > https://lists.sourceforge.net/lists/listinfo/opensg-users > ------------------------------------------------------------------------------ Live Security Virtual Conference Exclusive live event will cover all the ways today's security and threat landscape has changed and how IT managers can respond. Discussions will include endpoint security, mobile security and the latest in malware threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/ _______________________________________________ Opensg-users mailing list Opensg-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/opensg-users