Search Unity

Help Wanted IndexOutOfRangeException: Index was outside the bounds of the array.

Discussion in 'High Definition Render Pipeline' started by ayellowpaper, Feb 10, 2020.

  1. ayellowpaper

    ayellowpaper

    Joined:
    Dec 8, 2013
    Posts:
    30
    Hey,

    we are using HDRP and are getting this error for "bigger" scenes. Some side notes: we recently upgraded from standard pipeline to UDRP and then to HDRP. This error leads to a static image because it won't render anymore. The game still runs in the background though.
    We want to pitch our game in a few weeks and any help is appreciated. And I know this isn't a lot to go off.


    IndexOutOfRangeException: Index was outside the bounds of the array.
    (wrapper stelemref) System.Object.virt_stelemref_class_small_idepth(intptr,object)
    UnityEngine.Rendering.HighDefinition.HDShadowAtlas.RegisterCachedLight (UnityEngine.Rendering.HighDefinition.HDShadowResolutionRequest request) (at Library/PackageCache/com.unity.render-pipelines.high-definition@7.1.8/Runtime/Lighting/Shadow/HDShadowAtlas.cs:264)
    UnityEngine.Rendering.HighDefinition.HDShadowManager.ReserveShadowResolutions (UnityEngine.Vector2 resolution, UnityEngine.Rendering.HighDefinition.ShadowMapType shadowMapType, System.Int32 lightID, System.Int32 index, System.Boolean canBeCached, System.Int32& cachedRequestIdx) (at Library/PackageCache/com.unity.render-pipelines.high-definition@7.1.8/Runtime/Lighting/Shadow/HDShadowManager.cs:331)
    UnityEngine.Rendering.HighDefinition.HDAdditionalLightData.ReserveShadowMap (UnityEngine.Camera camera, UnityEngine.Rendering.HighDefinition.HDShadowManager shadowManager, UnityEngine.Rendering.HighDefinition.HDShadowInitParameters initParameters, UnityEngine.Rect screenRect) (at Library/PackageCache/com.unity.render-pipelines.high-definition@7.1.8/Runtime/Lighting/Light/HDAdditionalLightData.cs:1623)
    UnityEngine.Rendering.HighDefinition.HDRenderPipeline.PrepareLightsForGPU (UnityEngine.Rendering.CommandBuffer cmd, UnityEngine.Rendering.HighDefinition.HDCamera hdCamera, UnityEngine.Rendering.CullingResults cullResults, UnityEngine.Rendering.HighDefinition.HDProbeCullingResults hdProbeCullingResults, UnityEngine.Rendering.HighDefinition.DensityVolumeList densityVolumes, UnityEngine.Rendering.HighDefinition.DebugDisplaySettings debugDisplaySettings, UnityEngine.Rendering.HighDefinition.AOVRequestData aovRequest) (at Library/PackageCache/com.unity.render-pipelines.high-definition@7.1.8/Runtime/Lighting/LightLoop/LightLoop.cs:2117)
    UnityEngine.Rendering.HighDefinition.HDRenderPipeline.ExecuteRenderRequest (UnityEngine.Rendering.HighDefinition.HDRenderPipeline+RenderRequest renderRequest, UnityEngine.Rendering.ScriptableRenderContext renderContext, UnityEngine.Rendering.CommandBuffer cmd, UnityEngine.Rendering.HighDefinition.AOVRequestData aovRequest) (at Library/PackageCache/com.unity.render-pipelines.high-definition@7.1.8/Runtime/RenderPipeline/HDRenderPipeline.cs:1897)
    UnityEngine.Rendering.HighDefinition.HDRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext renderContext, UnityEngine.Camera[] cameras) (at Library/PackageCache/com.unity.render-pipelines.high-definition@7.1.8/Runtime/RenderPipeline/HDRenderPipeline.cs:1727)
    UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera[] cameras) (at <f38c71c86aa64e299d4cea9fb7c715e1>:0)
    UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset pipe, System.IntPtr loopPtr, Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle safety) (at <f38c71c86aa64e299d4cea9fb7c715e1>:0)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
  2. francescoc_unity

    francescoc_unity

    Unity Technologies

    Joined:
    Sep 19, 2018
    Posts:
    17
    Thank you for reporting the issue, this seems to be related to an issue on shadows map set to either on Demand or onEnable as update mode. Of course it is not expected, if you could file a bug with a repro project would be very helpful in tracking and solving the bug.

    It looks like the caching system of shadow map is failing in your case.

    In the meantime some things to consider:

    - Increase the maximum number of shadow requests that are allowed. You can find this setting in the HDRP asset you are using. Though I am not sure this would be a sure fix since I don't know what the core issue here is in this case.

    As a (sadly expensive) workaround you can reduce the number of shadow maps that are set to OnEnable or OnDemand as update mode and either set them to not cast shadows or if you can afford it set it as real time update.


    Unfortunately without a repro project is hard to understand more what is going on. If you could provide one as part of a bug report it would be much appreciated.
     
unityunity