On Thu, May 14, 2009 at 1:32 PM, Chris 'Xenon' Hanson
<xe...@alphapixel.com> wrote:
> Robert Osfield wrote:
>> This type of task is exactly what the stencil buffer is good for.  The
>> OSG supports stencil buffer natively.  See the osgreflect example.
>
>  I thought of that too, but it seemed like overkill since all I needed was a 
> bulk Z clear
> at the right time. Plus, I couldn't immediately describe to myself how the 
> stencil buffer
> would accomplish this. Don't you still need to wipe the Z values in order for 
> the Object B
> fragments to overwrite the Object A fragments (both of which have to be 
> generated with Z
> write and Z test enabled to self-occlude properly)?

Well if just want to do a clear of the z buffer then the tool to use
an osg::Camera for the second pass, and have this camera use a
relative reference frame and identity view and projection matrices so
it doesn't change the view, but enable the clear of the depth buffer
but not the colour buffer.  This is very similar to how one can do
HUD's using Camera's, the only different being the how one sets the
ReferenceFrame.

FYI, ClearNode controls the clear of the RenderStage that it's nested
within.  A pre/post draw Camera is implemented in the rendering
back-end as a RenderStage (a nested Camera just ruses it RenderStage
it's within).  But... you don't really need the ClearNode has the
Camera has it's own settings you can use.

Robert.
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to