[osg-users] How to avoid stencil interference between seperate parts of a scenegraph

Robert Osfield robert.osfield at gmail.com
Wed Feb 15 07:04:37 PST 2017


Hi Malcom,

With stencilling you normally will need to tightly control the
rendering order of the various subgraphs as you clear, write to, then
read from the stencil buffer in sequence.  To do this you can easier
use a series of slave Camera's in the viewer or the scene graph, each
decorating the appropriate subgraph.  You can set what you want to
clear via the osg::Camera::setClearMask();   You can also control
rendering order with osg::StateSet::setRenderBinDetails(...) but this
can't add the control of the clear.

Robert.

On 15 February 2017 at 10:58, Malcolm Pigott
<osg.malcolm at hydrogenrocks.me.uk> wrote:
> Hi,
>
> I have a scene which utilises multiple stencils within the same camera, albeit under two different groups.
>
> So I have:
>
>
> Code:
> ViewerCamera
> |
> +-GroupA (uses StencilA)
> |
> +-GroupB (has multiple stencils applied to different pieces of non-overlapping geometry)
> | |
> | +-GroupBA (has its own stencil)
> | |
> | +-GroupBB (has its own stencil)
> | |
> | +-GroupBC (has its own stencil)
>
>
>
> ViewerCamera has GL_STENCIL_BUFFER_BIT set.
>
> If I don't add geometry under the GroupB masks, all is well. As soon as geometry is added into the GroupB stencils, the stencils in GroupA go wrong. It may also be interfering with the other stencils in GroupB.
>
> I realise that I probably have to introduce something above GroupB or maybe each group with a separate stencil (such as another camera) to seperately clear GL_STENCIL_BUFFER_BIT but I don't understand cameras enough to work out how to do this. I may be completely wrong in this approach though!
>
> I have tried introducing a slave camera to ViewerCamera and putting GroupB under that but GroupB disappears so I'm probably setting up the slave camera wrong.
>
> How would you advise a modify the above hierarchy to keep GroupA and GroupB controlled by the same projection/ viewport/ etc. as ViewerCamera, but with GroupB's stencils not affecting GroupA's and vice-versa?
>
> Thank you for any guidance you can offer.
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=70199#70199
>
>
>
>
>
> _______________________________________________
> osg-users mailing list
> osg-users at lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org



More information about the osg-users mailing list