One-way Stencil Shader Window

Hi, I was wondering if anyone could help me with stencil shaders.

I noticed that when you use a stencil window, it changes the values of pixels both infront and behind the window - is there a way to do this so that it only happens to objects you see beyond the window plane and not in front of it?

No, it shouldn’t do that. Are you sure that:

  • the masking geometry that you’re rendering into the stencil buffer is one sided. For example Unitys default Quad and Plane meshes only have one side.
  • your shader that is rendering the masking geometry uses Cull back so it only renders the front side of your geometry?

If that all applies to in your case you should add more details on your setup and maybe post the shader code that you’re using and some kind of screenshot or drawing of your issue would help.