Occlusion shaders rendering black in video recordings

Hi Magic Leap

I have this occlusion shader that also can receive shadows from objects, it works alright in all platforms FIgmin XR supports but in Magic Leap 2 when I actually record footage it just shows everything black:

What you see in the video is a black plane, that is the floor, it should just occlude but it renders black. The same issue occurs in our other occlusion shader that doesn't use shadows at all.

Just to be extra clear: the issue is only visible in video recordings, it's alright through the device though it gets messed up if i enable the segmented dimmer


Can you try making the following change to your shader?

Excluding objects

To exclude a GameObject from having the Segmented Dimmer applied to it using this method, you can disable ZWrite in the shader used by the object’s material. This will prevent the renderer from writing to the depth buffer, effectively opting out of the Segmented Dimmer. This would be useful if you want to exclude your visualization prefabs for MLMeshing or MLPlanes from Segmented Dimmer.

In the following example shader code, the ZWrite value is exposed as a property which can be set on the Material inspector and also via C# code at runtime:

Shader "Custom/SegmentedDimmerExclude"
        [Enum(Off, 0, On, 1)] _ZWrite("ZWrite", Int) = 1 // Default to "On"
        _Color ("Color", Color) = (1,1,1,1)
        _MainTex ("Albedo (RGB)", 2D) = "white" {}
        ZWrite [_ZWrite]
material.SetInt("_ZWrite", 0);

I sent you the shader we use on a private message, if i turn off z-write they don't occlude anymore.


Hey @ababilinski looks like your reply went to a different post but I'll reply to you here.

In that post you mention to set:
ZWrite Off
ZTest LEqual

For both the shadow pass, and the occlusion pass. But the problem is that if I turn off ZWrite for the second, occlusion doesn't work anymore.

This is a shader that we use for the spatial map, so I want digital content to become invisible if it's behind a wall for example.

Thanks for your help.

Aha, thank you for that clarification. From my testing, It looks like drawing to the depth and color buffer causes the object to render as opaque. I'll talk to the multi media team and see if they can give some insight on how the 3rd eye capture works.

Sorry for the mix-up earlier,

Thanks! @ababilinski, this and the other thread are probably related since the dark halo around semi transparent objects also is where the depth buffer did it's work.

Hey @ababilinski @kbabilinski I've noticed a few magic leap 2 videos on social media where the real world is very dark, I'm pretty sure it's the same problem. They have spatial mapping on but are recording without alpha override so the black just tints everything instead.

Take a look:

I had a strange behaviour - so all polygons produced a flipped y-axis mirrored clone of itself in 100% black :slight_smile:
Finally I found out, magic leap renderer couldn't handle the depth texture...
Would be nice to have working depth textures to occlude objects - so is there a way?