Casting Shadows for Virtual Objects using Occlusion Material


I have a virtual character in my space for which I want to cast a shadow. I can see the shadow when I use the default green material for the mesh. Is it possible to cast shadow when i make the mesh invisible/transparent?

Are you using URP or the standard render pipeline? The only difference between Magic Leap 2 and other platforms is that it currently uses the Alpha channel for the Segmented Dimmer. So if your application uses the dimmer, you will need to make sure that the shader clears the alpha as well as occludes the object.

I am using URP and I am not utilizing the dimmer feature, however I still can't see any shadows for the virtual objects in the scene. Even in the recording, there were no shadows displayed.

Can you provide some more information on the shader(s) you tried using?

I am using the Occlusion material provided in the magic leap examples which uses the following shader :


Also, the occlusion material appears black in video recordings. I came across a similar post that suggested to enable segmented dimming as a solution: Occlusion shader video recording issues - #10 by petrebasura

I did not face this issue when I used the Magic Leap Example project - I didn't have the dimmer enabled and the recording seemed to render the occlusion fine.

However, for my own project which is configured with MagicLeap-MRTK, I find issues regarding the black rendering in the recordings. I tried enabling basic segmented dimming and still faced this issue. Can you please advise on how can this be fixed as I need occlusion in my project. Thanks.

Are you using OpenXR ?


The project has the OpenXR package installed, but it is not configured for the Android platform. I am utilizing the MLSDK provider instead. These are the project settings :

Have you tried using the changes mentioned in this guide? Passthrough for Capture and Dimming | MagicLeap Developer Documentation

Hi, I will check out this guide, although I wanted to clarify segmented dimmer is not set for my application.

Also, I came across a similar post where you mentioned you have a URP shader that could possibly resolve the issue (for occlusion and shadows I believe) :

Could you please provide me the mentioned shader?

Unfortunately, the shader that was mentioned in that post was provided by the developer so you would need to ask him if he can share it with you.


I included the code snippet provided in the Passthrough for Capture guide and it resolved the issue. Now the mesh does not appear black in the video recording. Thanks.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.