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

Malcolm Pigott osg.malcolm at hydrogenrocks.me.uk
Wed Feb 15 02:58:29 PST 2017


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








More information about the osg-users mailing list