Give us as much detail as possible regarding the issue you're experiencing.
Unity Editor version: 2022.3.3f1
ML2 OS version: 1.2.0
MLSDK version: 1.8.0
Host OS: (Windows/MacOS) Windows 11 home
Error messages from logs (syntax-highlighting is supported via Markdown): Opaque Layer Mask does not work
I wanted to create a plane where the user can see through it like a window. It would be amazing if they could see Skybox through it. I wanted to create this functionality using forward renderer with layer mask. Skybox would be a massive sphere with cubemap material.
Expected behavior:
A sphere to be only visible through a quad.
Observed behavior:
A sphere is always visible.
How to recreate this behavior:
Follow this tutorial.
For my case, the object is sphere is in 7:Stencil Layer I created. The quad is using material with following shader.
Shader "Hatlab/StencilSkybox"
{
Properties
{
[IntRange] _StencilID ("Stencil ID", Range(0, 255)) = 0
}
SubShader
{
Tags
{
"RenderType" = "Opqaue"
"RenderPipeline" = "UniversalPipeline"
"Queue" = "Geometry"
}
Pass
{
Blend Zero One
ZWrite Off
Stencil
{
Ref [_StencilID]
Comp Always
Pass Replace
Fail Keep
}
}
}
}
I've set the Stencil ID to be 1 in material.
In the URP-HighFidelity Renderer, find the Filtering.
Disable Stencil Layer for Opaque Layer Mask and Transparent Layer Mask.
I've enabled Stencil with Value to be 1, compare function to be "Equal".
Don't forget to change the render to be URP renderer at Assets/Settings for Camera. You can change it at Camera component at Camera.
Interestingly, it works correctly on Game window and App Sim Target.
However, when I build it and play it, it does not behave as it should be.
I don't know what is causing this issue. Is this even right way to approach this? I want to recreate identical behavior by making custom shader but I lack knowledge in Shader yet.