Hello everyone,
We are currently doing a VR project in Unity involving stencil buffer to manage transitions between overlapped rooms.
Like this example :
The main problem is that the window using the stencil buffer show also the room’s walls that are between the camera and the window. (example below)
The window should render walls only if the window is between camera and walls.
No problem from this point of view
Here, we see the wall (on the outside of the room) that is between the camera and the window.
Part of the Window shader : (Ref = 1, Comp = Always, Pass = Replace)
Tags{ "Queue" = "Geometry-1" }
ZWrite off
ColorMask 0
Stencil
{
Ref[_SRef]
Comp[_SComp]
Pass[_SOp]
}
Room shader : (Ref = 1, Comp = Equal, Pass = Keep)
An other problem is that the window can be seen through other objects that use an other stencil buffer reference
We tried to deal with render order (render queue, ZWrite, ZTest) without any good results.
Thanks for your help !




