Hi, I'm pretty new to osgPPU and I'm working on a port of Jimenez's MLAA full scene antialiasing algorithm.
It's a 3-pass post processing effect and I got it working on osgPPU. - The first step detects the edges of the RTT'd scene and makes an 'edge texture'. - The second step uses the previous texture and a precomputed one to calculate the area which pixels belonging to an edge would cover from an ideal trapeze. - The final step blends each pixel in its 4-neighborhood according to the weights calculated in the previous step. I got it fully working in osgPPU, however, an important optimization can be done by using the stencil buffer. The idea behind this is: - Initially the stencil is cleared out to 0 - The first step of the post effect (edges detection) creates a stencil mask writing 1's to the stencil wherever there's an edge pixel. The pixels not belonging to an edge are discarded in the shader, so no writting to the stencil will occur in that case. - In the subsequent steps the stencil test discards every pixel not covered by the mask, hence only the edge pixels are processed (weights calculation and final blend). And this is how I tried to achieve it: - I created two osg::Stencils, one for creating the mask and other for using the mask and discarding everything else. - I attached the stencils to their corresponding osgPPU::Unit's. (now, I need to clear the stencil at the beginning of the postFX chain, but not between each pass) - I'm not sure about where glClear (with the clear mask of the camera the osgPPU::Processor is using) is called, but my guess is when rendering the scene to texture, not between units so I think that setting the clearMask in the camera is pointless. - I tried to call glClear(GL_STENCIL_BUFFER_BIT) in a notify callback set in the first unit of my chain. This has been driving me nuts for a couple of days now. It seems that the stencil buffer is not being written, or cleared prematurely between passes. And the stencil test only seems to be done if I enable it in the last unit's stateset. What am I missing? I can post the code if you want! ... Thank a lot in advance! Cheers, Miguel ------------------ Read this topic online here: http://forum.openscenegraph.org/viewtopic.php?p=39894#39894 _______________________________________________ osg-users mailing list [email protected] http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

