Search Unity

Stencil buffer not working

Discussion in 'VR' started by Gentatsu, Nov 2, 2016.

  1. Gentatsu

    Gentatsu

    Joined:
    Oct 21, 2016
    Posts:
    6
    I'm trying to use the stencil buffer to mask an object, such that the object is only rendered within the bounds of the mask.

    On the editor, it works fine, but it's not masked at all with the hololens. The shaders seem to be loaded correctly. Honestly, I'd ideally like to do it without the shaders, since I have a biggish model, and when I use the shader with the stencil buffer, it breaks them a bit. Is there a way to do that, does anyone know? Main issue is the first one, though.

    Thanks!
     
  2. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
  3. Gentatsu

    Gentatsu

    Joined:
    Oct 21, 2016
    Posts:
    6
    Yes, I had a look at that, but it seems to be an inbuilt component.

    I'm using two shaders for my mask.

    One that writes to the stencil buffer, essentially, for the space it occupies, it writes "1" in the space. Then I attach shaders to my objects checking for that reference, and only render if it equals it. In essence, if they overlap, render; otherwise, don't. I mildly solved the issue by unchecking the 16 bit depth buffer. Though I now have the issue of them not being in the same place.

    Again, on the editor, it works fine. On the hololens, I tried scaling my object, and eventually it seems to intersect the mask, but in a completely random place. They're both children of another gameobject, so I can move them both around, but they're both at position (0, 0, 0). When I change the shader, it displays fine. When I changed the mask's shader to a normal one, it displays fine. The only difference is the stencil buffer writing.
     
  4. Unity_Wesley

    Unity_Wesley

    Unity Technologies

    Joined:
    Sep 17, 2015
    Posts:
    558
    That is interesting, can you please file a bug report with this information in it. Also, can you attach a simple project to the bug that reproduces this issue.

    This way we can investigate the issue quickly