Access Stencil Buffer on non-translucent materials
I'm working on a stencil effect where a portion of an object can be "cut out" using another object as reference.
To do this I have the floor set up as a translucent material which tests the stencil value in the CustomStencil scene texture to determine it's opacity.
The stencil buffer looks like this:
My current goal is to get this to work with a non-translucent material. I can't do this right now because non-translucent materials don't have access to the custom depth buffer / stencil values.
Basically what I'd like to do is render all of the "Portals" (in this case a cube) to the stencil buffer (value = 1). Then in the next pass render all of the "Blockers" (in this case the floor) the the stencil buffer (value = 2). Then render the "Blockers" in the main pass while obeying the rule value == 2. Then render the rest of the main pass.
I'm not sure where to start with this approach, any ideas?
asked Dec 24 '15 at 01:10 AM in Rendering
answered Dec 05 '17 at 09:20 PM
It's recommended you render another copy of the mesh. The other copy should have a fully opaque material, under render settings deselect render in main path and turn on render is custom render buffer. Then you can use that data for your needs either in the shader or as a postprocess.
answered Dec 05 '17 at 09:23 PM
Follow this question
Once you sign in you will be able to subscribe for any updates here