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.
  2. Dismiss Notice

Question 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:
    49
    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:
    193
    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.
     
  3. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @francescoc_unity I'm having this issue as well on 2019.3.13f1.
    Just updated from 2019.3.6 and yeap this issue is happening. My project is too big to send. So can't really help much on this front.

    Not sure if mine is any different than his/hers but here's my error output.
    Code (CSharp):
    1. IndexOutOfRangeException: Index was outside the bounds of the array.
    2. (wrapper stelemref) System.Object.virt_stelemref_class_small_idepth(intptr,object)
    3. UnityEngine.Rendering.HighDefinition.HDShadowAtlas.RegisterCachedLight (UnityEngine.Rendering.HighDefinition.HDShadowResolutionRequest request) (at Library/PackageCache/com.unity.render-pipelines.high-definition@7.3.1/Runtime/Lighting/Shadow/HDShadowAtlas.cs:264)
    4. 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.3.1/Runtime/Lighting/Shadow/HDShadowManager.cs:363)
    5. UnityEngine.Rendering.HighDefinition.HDAdditionalLightData.ReserveShadowMap (UnityEngine.Camera camera, UnityEngine.Rendering.HighDefinition.HDShadowManager shadowManager, UnityEngine.Rendering.HighDefinition.HDShadowSettings shadowSettings, UnityEngine.Rendering.HighDefinition.HDShadowInitParameters initParameters, UnityEngine.Rect screenRect) (at Library/PackageCache/com.unity.render-pipelines.high-definition@7.3.1/Runtime/Lighting/Light/HDAdditionalLightData.cs:1727)
    6. UnityEngine.Rendering.HighDefinition.HDRenderPipeline.PreprocessVisibleLights (UnityEngine.Rendering.HighDefinition.HDCamera hdCamera, UnityEngine.Rendering.CullingResults cullResults, UnityEngine.Rendering.HighDefinition.DebugDisplaySettings debugDisplaySettings, UnityEngine.Rendering.HighDefinition.AOVRequestData& aovRequest) (at Library/PackageCache/com.unity.render-pipelines.high-definition@7.3.1/Runtime/Lighting/LightLoop/LightLoop.cs:2141)
    7. 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.3.1/Runtime/Lighting/LightLoop/LightLoop.cs:2520)
    8. 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.3.1/Runtime/RenderPipeline/HDRenderPipeline.cs:1909)
    9. UnityEngine.Rendering.HighDefinition.HDRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext renderContext, UnityEngine.Camera[] cameras) (at Library/PackageCache/com.unity.render-pipelines.high-definition@7.3.1/Runtime/RenderPipeline/HDRenderPipeline.cs:1742)
    10. UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera[] cameras) (at <480508088aee40cab70818ff164a29d5>:0)
    11. UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset pipe, System.IntPtr loopPtr, Unity.Collections.LowLevel.Unsafe.AtomicSafetyHandle safety) (at <480508088aee40cab70818ff164a29d5>:0)
    12. UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)
     
  4. ayellowpaper

    ayellowpaper

    Joined:
    Dec 8, 2013
    Posts:
    49
    @N1warhead francescoc was nice enough to help me in direct messages.

    What worked for us was to change lights from Update Mode "OnEnable" or "OnDemand" to "Every Frame".
     
  5. N1warhead

    N1warhead

    Joined:
    Mar 12, 2014
    Posts:
    3,884
    @ayellowpaper Thank you, but unfortunately it boggs my PC down with 25 point lights even with a resolution of 64.. I really wished there was a GI solution for HDRP, I'm having to use point lights to give some slight environment lighting for glowing mushrooms.
     
  6. francescoc_unity

    francescoc_unity

    Unity Technologies

    Joined:
    Sep 19, 2018
    Posts:
    193
    Hey, what HDRP version are you on?
     
  7. cloverme

    cloverme

    Joined:
    Apr 6, 2018
    Posts:
    177
    I've got the issue too, HDRP 8.2.0