- Home /
How to clear the stencil buffer?
Is there a way to manually clear the stencil buffer?
I am trying to create 2d stencil shadows, and I need to make sure the stencil buffer is clean at the start of every frame.
I have noticed the "clearStencilBufferAfterLightPass" flag, but this is no working for me for some reason. At the moment I am drawing a full screen quad at the start of every frame and setting every pixels stencil value back to 0.
I know this stuff is still new, but I am hoping someone knows more than I do.
Thanks in advance.
$$anonymous$$aybe this is not relevant, but as a personal point of view, I have not used OpenGL in Unity but it seems from the API the amount of available methods is limited (or are they just showing the main ones as there are thousands of them).
$$anonymous$$aybe if you want to develop more with OpenGL, you should go for TaoClassic or OpenTk which are OpenGl with C#. TaoClassic is even just a C# version of the C++ version. I do not know OpenTk but I read it takes a personal path and do not really looks like C++ version.
Answer by Bork Awesome · Aug 14, 2013 at 03:12 PM
I have not tried this myself, but would GL.Clear do what you need if you pass true as the first param to clear the depth buffer?
Only been messing around with the Stencil stuff myself recently but I believe the stencil data is an extra per-pixel byte in the depth buffer, so clearing the depth buffer manually might just do what you are asking..
Sorry for the late reply.
GL.Clear(true, false, Color.black);
Did the trick. $$anonymous$$any thanks