- Home /
Unity 5 Deferred Stencil Buffer Usage
I'm aware that unity 5 apparently has some problems with letting us use parts of the stencil buffer for deferred objects. (They use at least 4 bit's for excluding layers for lights, then possibly at least one more bit for stencil test light culling optimization). But if I could know/set what bits were used for what layer of those 4 (or possibly more if I choose!?) it would allow me to let other effects also depend on those exact same layers! Is this possible? If not, what are the chances it might be doable withing the forseeable future of unity?
Answer by msklywenn · Oct 24, 2016 at 04:52 PM
Indeed, it would be nice to have the stencil bits used by the deferred renderer document. A DeferredStencilReadMask value for shaders would be nice too, so that we could mask by default the bits of the stencil buffer if we don't use them.
Well, actually, it is... my bad.
https://docs.unity3d.com/$$anonymous$$anual/SL-Stencil.html
"The deferred rendering path uses the three highest bits of the stencil buffer, plus up to four more highest bits - depending on how many light mask layers are used in the scene. It is possible to operate within the range of the “clean” bits using the stencil read and write masks, or you can force the camera to clean the stencil buffer after the lighting pass using Camera.clearStencilAfterLightingPass."
Your answer
Follow this Question
Related Questions
Use the stencil buffer in multiple passes in a single shader 0 Answers
Can I read/write to the Stencil buffer in a pixel shader? 0 Answers
(Shader Graph) Output resolution/ setting resolution of the main preview window 0 Answers
Camera layering : UI shader is cleared by second camera with Depth Only flag 1 Answer
How can I disable masked object shadow with DepthMask shader 1 Answer