Breakfast With Unity: Stencil Shaders
Why Stack Overflow recommends it
Stack Overflow users link it when answering Unity shader questions about masking, hiding overlapped regions or partial rendering, as a practical demonstration of how stencil buffers work.
Recommended by 2 people across 2 different months, 2017 to 2019.
What it is
A 26-minute Unity tutorial from PushyPixels' 'Breakfast With Unity' series that experiments with stencil shaders and shows how they can produce many different visual effects. The presenter works through examples live, and project files are available on GitHub.
What people said
Recommends Harry · 2017-01 · Stack Overflow · on “Unity shader that make overlapped regions transparent?”
Stencil shader does exactly what you want in opposite way. Perhaps you could adapt it to your problem. Here it is: [LINK] And documentation: [LINK] This one is exciting as well: [this video]
Recommends Mons · 2018-10 · Stack Overflow · on “how to progressive rendering a mesh?”
The most obvious is indeed dynamically mesh vertices IMO but if you really want to do it shader side, you could try using 2 meshes and stencil shader. Documentation: [LINK] Interesting video: [this video]
Cites Anton Kasabutski · 2019-12 · Stack Overflow · on “Unity: UI Image alpha overlap”
Resolution: a new shader and its material, plus one additional material. Shader creation can be avoided in some situations! Shaders in Unity has a tool called Stencil. This tool maintains pixel buffer that can be used to discard pixels. CanvasImageMask shader: it is a clone of default UI image shader, except Stencil adjustments and tiny addition for comfort work. When mask rendering is happening, Stencil will set the pixel buffer's value to 1 in the place where it actually drew something. The second shader reacts to this change and discards new pixels in that location. Keep in mind that objects with such material (that hold CanvasImageMask shader) should come first in Canvas because during r