UI Mask in Scroll View not working with 16-bit depth format
Describe the bug
After following the recommended settings for Unity, and changing the Depth format to 16-bit shows irregularities while using the scroll view. Items seem to overflow beyond the viewport. But after changing to 24-bit, it works fine. Reproducible only on HL2 device (not on the editor)
To reproduce
Steps to reproduce the behavior:
- Open the HandInteractionUnityUIExample scene
- Open XR settings in Player settings, set Depth format to 16-bit depth
- Have Enable Depth Buffer Sharing. Stereo Rendering mode can be Single-pass instancing or multi-pass. Shouldn't matter (I think)
- Build for HL2 and see the scroll view overflow.
Expected behavior
With the recommended settings, scroll view shouldn't overflow (UI Mask working fine)
Your Setup (please complete the following information)
- Unity Version [e.g. 2018.4.5f1]
- MRTK Version [e.g. v2.1]
Target Platform (please complete the following information)
- HoloLens 2
Occurs on Hololens 1 aswell
@pampas93 use Rect 2D Mask component instead of Mask
AFAICT this has been an issue in UnityUI since 2016:
https://forum.unity.com/threads/ui-mask-failing-on-hololens-works-on-preview-fine.424998/ https://forums.hololens.com/discussion/1167/ui-mask-not-working-on-hololens
Though also AFAICT it seems like general stencil buffer support doesn't seem to be working as expected, which is what the Mask component uses to accomplish the culling effect:
https://forum.unity.com/threads/stencil-buffer-not-working.439158/
At this point it might just be worth Rect 2D Mask given the amount of time the underlying thing has been broken.
Alrighty, thanks to the sluething that @Troy-Ferrell did, it looks like the fact that stencil buffers don't work on 16 bit is by design:
https://docs.unity3d.com/ScriptReference/RenderTexture-depth.html
Maybe we should downgrade/caveat our recommendations here to warn against these sorts of things... I think there are other things in the MRTK that also depend on stencil buffers being usable.
Closing as dupe of 5970