Quest 3 Lighting Bug

I have been playing around with the foundations of an augmented reality RPG targeting smartphones and things were going great. But, I just got a Quest 3 and decided to load it up to see how things looked. Sadly, it is not great. I have two strange issues regarding scene lighting and I was wondering if someone may know what is going on here.

  1. Any time I move the quest joysticks left or right, the scene’s sunlight / shadow changes as if the directional light that serves as the sun is being rotated around the map. But, I did not code any such functionality and this does not happen on the smartphone based versions.


  1. On the Quest 3, shadow angles change drastically as you move your head around, which once again is not expected, wanted, or programmed behavior.

Note, scene lighting is lit by an HDR skybox and a directional light. Nothing more. There is nothing in my code changing the direction of the directional light.

This shows both the issues:

Same test terrain but captured on my tablet which does not have the lighting issues:

Any ideas?

 // lighting for the active map
    private loadLighting(name: string, scene: Scene){
        ar.c("Creating Scene Lighting");
        let hdrTexture = CubeTexture.CreateFromPrefilteredData("./assets/environments/studio.env", ar.scene);
        ar.scene.environmentTexture = hdrTexture;
        // Sun
            ambienceManager.sunlight = new DirectionalLight("Sun", new Vector3(-0.5, -2, 4), ar.scene);
            ambienceManager.sunlight.diffuse = new Color3(1, 0.85, 0.40);
            ambienceManager.sunlight.intensity = 10;
            ambienceManager.sunlight.shadowEnabled = true;

            ambienceManager.sunShadow = new CascadedShadowGenerator(1024, ambienceManager.sunlight);
            ambienceManager.sunShadow.numCascades = 4;
            ambienceManager.sunShadow.stabilizeCascades = true;
            ambienceManager.sunShadow.lambda = 0.13;
            ambienceManager.sunShadow.cascadeBlendPercentage = 0.36;
            ambienceManager.sunShadow.depthClamp = false;
            ambienceManager.sunShadow.autoCalcDepthBounds = true;
            ambienceManager.sunShadow.shadowMaxZ = 16811191;
            ambienceManager.sunShadow.bias = 0.01;
            ambienceManager.sunShadow.normalBias = 0.004;
            ambienceManager.sunShadow.darkness = 0.1;
            ambienceManager.sunShadow.usePercentageCloserFiltering = true;
            ambienceManager.sunShadow.filteringQuality = CascadedShadowGenerator.QUALITY_HIGH;
1 Like

This looks really weird, do you have a repro @RaananW could play with ?

Would you be able to share the implementation with me? I want to use it on my headset to debug the behavior

Of course,

I won’t be back from a work trip until tomorrow evening at the earliest, but will simplify and sync things to a git repo as soon as I do. I will send you a PM with the details as soon as I am done.

Thanks for the assist.

1 Like

Sorry about the delay. I was in and out of the hospital. I have added you the git repo and PMed you the details.

You should be able to compile with an npm run-script build and drop on a server. If you need FTP access to a temporary test location, let me know.

Note, though hidden in AR until I get around to building an in AR menu system, I did incorporate debug options into the 2D interface. To access, back out of AR mode once launched on the quest and you will see the menu icon. Punch it to activate toggleable debug options including an in website console ( ar.c(“message”) to use, the console overlays the 2D Canvas) and Babylon inspector. Its not hard to jump back and forth by reentering and backing out of AR. Its on my list to render inspector and console to textures, but has not been a high priority yet.

Note 2, I don’t think its the lighting itself rotating, I think the world is. For some reason it looks like the world itself is not properly anchoring while the AR pinned asset do somehow stay anchored at the AR marker’s location. You can sort of see this now with the XR plane map planes (w grid texture) when setting the environment, they don’t stay fixed. Once you drop the game map by clicking anywhere in the physical world that has been plane mapped, you can see it in how the surface occlusion material (hides things behind plane detected geometry to properly occlude the world behind physical world objects) will cut into the map itself once you start wiggling the joysticks around on the quest controllers. Its pretty clear the global world is for some reason rotating. But why, well that makes not sense.

1 Like

Got the invite, I’ll look into that later this week. Thanks!