How to use stencil buffer in an HDRP project?
Hello, I started learning unity 2-3 months ago. Right now I am trying to learn how to make a sniper scope. The one that I came up with works fine, but the problem is that I can see the inside of the scope body.
I did some searching online and found that Stencil Buffer is exactly what I need. I can use a Stencil Mask behind my Lens object which is using a zoom shader graph (Thanks to Code Monkey). So I learned some basic shader code and managed to do something like this:
The quad writes to the stencil buffer in front of the cube, which is reading from the stencil buffer and only rendering the pixels when the reference value is not the same. Now, my question is, How do I add this to the Default HDRP lit shader? I tried modifying the default HDRP lit shader. But from what I saw, HDRP lit shader is already using Stencil buffer in some of the passes. I tried my best by editing some of the default passes but nothing worked. What can I do the get the same effect as the 2nd image in the Default HDRP lit shader?
sorry for my bad writing (English is my 4th language).