Occlusion with Shadows in Magic Leap


There is a character in my space for which I want to cast shadows on the meshes generated using spatial mapping. I am able to visualize the shadows on the mesh when using the default green material for the meshes as shown below:

For the Occlusion, I am using the following Occlusion Shader :

Shader "Universal Render Pipeline/VR/SpatialMapping/Occlusion"
Tags { "RenderPipeline" = "UniversalPipeline" "Queue" = "Geometry-1" }
LOD 100

    ZWrite On
    ZTest LEqual
    Colormask 0
    Cull Off

        Name "Spatial Mapping Occlusion"

        #pragma vertex vert
        #pragma fragment frag

        // -------------------------------------
        // Unity defined keywords
        #pragma multi_compile_instancing

        #include "UnlitInput.hlsl"

        struct Attributes
            float4 positionOS       : POSITION;

        struct Varyings
            float4 vertex  : SV_POSITION;


        Varyings vert(Attributes input)
            Varyings output = (Varyings)0;

            UNITY_TRANSFER_INSTANCE_ID(input, output);

            VertexPositionInputs vertexInput = GetVertexPositionInputs(input.positionOS.xyz);
            output.vertex = vertexInput.positionCS;

            return output;

        half4 frag(Varyings input) : SV_Target

            return half4(0,0,0,0);

FallBack "Hidden/Universal Render Pipeline/FallbackError"


When I switch to the Occlusion shader, there is no shadow received as seen below:

The occlusion aspect works fine; however I also want to enable shadows for the character. Can you please provide some insights on this matter? Thanks.

Hi @Zul01
I think you are going to have some difficulty creating a convincing shadow. In your second picture there is nothing for the shadow to fall on, unity is not going to draw a shadow on a hidden mesh, which would be solvable, but I think your bigger problem is going to be that as an additive light display you cannot add darkness to an area, so even if the shadow were to show up in captures, it would not be visible in the display. The only way I could see it working at all would be to trick the segmented dimmer, but the segmented dimmer's resolution is much lower than the rgb resolution and would likely look quite bad. You might be able to get away with a simple blob shadow that way, but I am not sure that it will add meaningfully to your scene.