Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
Dismiss Notice
Join us now in the Performance Profiling Dev Blitz Day 2023 - Q&A forum where you can connect with our teams behind the Memory and CPU Profilers and the Frame Debugger.

Bug [URP][Quest 2] Camera snaps and stops rendering subtractive shadows.

Discussion in 'VR' started by chichichap, Dec 30, 2022.

  1. chichichap

    chichichap

    Joined:
    May 28, 2017
    Posts:
    15



    Unity Version: 2020.3.18f / 2020.3.43f
    URP Version: 10.10.1
    Platform: Quest 2
    Lighting: Mixed (Subtractive)

    When the game starts, shadows appear fine, but they seem to disappear (and never come back) when the player looks away from the shadow-casting mesh. Once the bug is triggered, the camera will not see shadows from any mesh.

    More info:
    - The bug seems preventable if I keep a shadow-casting mesh in the camera's view.
    - The bug also happens if the mesh gameObject is disabled for one frame. The shadows never come back even if the gameObject is enabled.
    - If I start the scene with Soft shadows and trigger the bug, the bugged camera can actually render shadows again if I changed the shadow type to Hard (the shadows will disappear if I change it back to Soft). If I start the scene with Hard shadows, the bug can happen vice versa.

    - I breakpoint-debugged the light, the camera, the material, the shadow color, the quality settings, and couldn't find anything unusual--all the settings and properties are still fine.
    - I used RenderDoc, and the captured frame still has shadows, even though there is no shadow in the headset / screenshot / video capture.

    - The bug is not reproducible whatsoever on the editor (Rift S).
    - The bug is only reproducible 70% of the time on Quest 2 (not sure why).
    - Real-time shadows on dynamic meshes still appear fine even after the bug happens to subtractive shadows on baked meshes.

    Any help will be appreciated.
     
    Last edited: Dec 31, 2022
  2. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    2,987
    Whaaat, this seems like the start of a horror game with the shadow suddenly away.

    Anyhow, few questions:

    - are you using vulkan or opengl?
    - if vulkan, do you use graphics jobs?
    - did you try disabling the optimizations in the Oculus XR plugin for android?
    - did you try switching multiview/multipass?
    - does this happen in the latest 2020 lts?


    Edit:
    Is it possible shadows are disabled in the URP asset used for android?
    If so, maybe it is switching from baked to realtime lighting because something changed and realtime lights aren't possible because theyre disabled?
     
  3. chichichap

    chichichap

    Joined:
    May 28, 2017
    Posts:
    15
    - I'm using OpenGL.
    - I've tried Multiview/Multipass, disabling Low Overhead Mode (GLES), Phase Sync, Subsampled Layout, etc. The bug is still reproducible.
    - I've tried upgrading to the latest 2020.3.43, and the bug is still reproducible.
     
    Last edited: Dec 31, 2022
  4. chichichap

    chichichap

    Joined:
    May 28, 2017
    Posts:
    15
    I added another video with a new rotating camera using RenderTexture.
    I used to be able to trigger the bug on one camera while the other camera still sees shadows, but now the bug seems to happen to both cameras simultaneously.
     
  5. chichichap

    chichichap

    Joined:
    May 28, 2017
    Posts:
    15
    I've attached & debugged the running process. The properties/settings about the light, the material, the camera, and the URP pipeline asset didn't change after the bug happens. Besides, if I change the shadow type (from Soft to Hard or vice versa), the shadows appear again (but disappear if I change the shadow type back).

    It feels like when the bug happens, the renderer stops rendering the type (Soft/Hard) of subtractive shadows I started with.

    Code (CSharp):
    1. UnityEngine.Rendering.GraphicsSettings.currentRenderPipeline
    2. "UniversalRP-HighQuality (UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset)"
    3.     base: "UniversalRP-HighQuality (UnityEngine.Rendering.Universal.UniversalRenderPipelineAsset)"
    4.     additionalLightsRenderingMode: Disabled
    5.     additionalLightsShadowmapResolution: 2048
    6.     cascade2Split: 0.25
    7.     cascade3Split: "(0.1, 0.3)"
    8.     cascade4Split: "(0.1, 0.1, 0.3)"
    9.     colorGradingLutSize: 32
    10.     colorGradingMode: LowDynamicRange
    11.     default2DMaterial: null
    12.     defaultLineMaterial: null
    13.     defaultMaterial: null
    14.     defaultParticleMaterial: null
    15.     defaultShader: "Universal Render Pipeline/Lit (UnityEngine.Shader)"
    16.     defaultTerrainMaterial: null
    17.     defaultUIETC1SupportedMaterial: null
    18.     defaultUIMaterial: null
    19.     defaultUIOverdrawMaterial: null
    20.     k_AssetPreviousVersion: 5
    21.     k_AssetVersion: 6
    22.     m_AdditionalLightShadowsSupported: true
    23.     m_AdditionalLightsPerObjectLimit: 4
    24.     m_AdditionalLightsRenderingMode: Disabled
    25.     m_AdditionalLightsShadowmapResolution: _2048
    26.     m_Cascade2Split: 0.25
    27.     m_Cascade3Split: "(0.1, 0.3)"
    28.     m_Cascade4Split: "(0.1, 0.1, 0.3)"
    29.     m_ColorGradingLutSize: 32
    30.     m_ColorGradingMode: LowDynamicRange
    31.     m_DefaultRendererIndex: 0
    32.     m_DefaultShader: "Universal Render Pipeline/Lit (UnityEngine.Shader)"
    33.     m_LocalShadowsAtlasResolution: _256
    34.     m_LocalShadowsSupported: false
    35.     m_MSAA: Disabled
    36.     m_MainLightRenderingMode: PerPixel
    37.     m_MainLightShadowmapResolution: _2048
    38.     m_MainLightShadowsSupported: true
    39.     m_MaxPixelLights: 0
    40.     m_MixedLightingSupported: true
    41.     m_OpaqueDownsampling: None
    42.     m_RenderScale: 1
    43.     m_RendererData: null
    44.     m_RendererDataList: UnityEngine.Rendering.Universal.ScriptableRendererData[1]
    45.     m_RendererType: ForwardRenderer
    46.     m_Renderers: UnityEngine.Rendering.Universal.ScriptableRenderer[1]
    47.     m_RequireDepthTexture: false
    48.     m_RequireOpaqueTexture: false
    49.     m_ShaderVariantLogLevel: Disabled
    50.     m_ShadowAtlasResolution: _256
    51.     m_ShadowCascadeCount: 1
    52.     m_ShadowDepthBias: 1
    53.     m_ShadowDistance: 20
    54.     m_ShadowNormalBias: 0
    55.     m_ShadowType: HardShadows
    56.     m_SoftShadowsSupported: true
    57.     m_StoreActionsOptimization: Auto
    58.     m_SupportsDynamicBatching: true
    59.     m_SupportsHDR: false
    60.     m_SupportsTerrainHoles: false
    61.     m_UseAdaptivePerformance: true
    62.     m_UseSRPBatcher: true
    63.     m_VolumeFrameworkUpdateMode: ViaScripting
    64.     mainLightRenderingMode: PerPixel
    65.     mainLightShadowmapResolution: 2048
    66.     maxAdditionalLightsCount: 4
    67.     msaaSampleCount: 1
    68.     opaqueDownsampling: None
    69.     renderScale: 1
    70.     rendererIndexList: int[2]
    71.     scriptableRenderer: {UnityEngine.Rendering.Universal.ForwardRenderer}
    72.     scriptableRendererData: "ForwardRenderer (UnityEngine.Rendering.Universal.ForwardRendererData)"
    73.     shaderVariantLogLevel: Disabled
    74.     shadowCascadeCount: 1
    75.     shadowDepthBias: 1
    76.     shadowDistance: 20
    77.     shadowNormalBias: 0
    78.     storeActionsOptimization: Auto
    79.     supportsAdditionalLightShadows: true
    80.     supportsCameraDepthTexture: false
    81.     supportsCameraOpaqueTexture: false
    82.     supportsDynamicBatching: true
    83.     supportsHDR: false
    84.     supportsMainLightShadows: true
    85.     supportsMixedLighting: true
    86.     supportsSoftShadows: true
    87.     supportsTerrainHoles: false
    88.     useAdaptivePerformance: true
    89.     useSRPBatcher: true
    90.     volumeFrameworkUpdateMode: ViaScripting
     
    Last edited: Dec 31, 2022
  6. DevDunk

    DevDunk

    Joined:
    Feb 13, 2020
    Posts:
    2,987
    Try the latest lts version and of that doesn't fix it make a bug report
     
  7. chichichap

    chichichap

    Joined:
    May 28, 2017
    Posts:
    15