Search Unity

Bug AR Foundation pre 5.0 and URP Background not rendering

Discussion in 'AR' started by Voronoi, Jun 29, 2022.

  1. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    590
    I am using AR Foundation 5.0.0-pre.12, Unity 2022.1.+ and URP 13.1.8 and I am again getting the 'black screen' issue on iOS. This has cropped up before in previous combinations of URP and AR Foundation, and in my case I also get a black screen with AR Foundation 4.2.3 release version.

    The camera is running and plane recognition is working, so I know the problem is related to the background rendererer. This thread has screenshots to check all the settings, and I have done that.

    Is this a known bug? Are there any ways to workaround this and get background rendering working again?
     
  2. davidmo_unity

    davidmo_unity

    Unity Technologies

    Joined:
    Jun 18, 2019
    Posts:
    99
    It may be a known issue with URP. Double check that the active render pipeline has the renderer feature and check the logs during runtime to make sure that there isn't an `IndexOutOfBoundsException` being thrown by the renderer. If there is you can resolve it by adding your renderer again in the URP asset then removing it (this is a workaround). The editor has been seeing some issues with the default option in serialized lists being at the incorrect index on startup.

    If you have run the URP Pipeline conversion utility that actually replaces your active render pipeline with default pipelines created by URP to emulate the built-in renderer. You would need to add the ARBackgroundRendererFeature to the pipelines that were generated.

    Otherwise, please file a bug here and post the tracking link:
    https://unity3d.com/unity/qa/bug-reporting
     
  3. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    590
    The active pipeline does have the renderer feature, but I do not see any console or log messages for index out of range errors. I selected the 'Balanced' renderer pipeline and removed the AR Background Renderer and then re-installed it a number of times and it makes no difference.

    I have noticed the Editor occassionally losing track of the selected pipeline and also occassionally the Editor randomly unchecks the ARKit system. But, even with all those selected/checked, still get a black screen.

    I've submitted a bug report – IN-9102
     
    Last edited: Jul 2, 2022
    fuzzy3d and davidmo_unity like this.
  4. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    Thanks for submitting a bug report!
     
  5. ambergarage

    ambergarage

    Joined:
    Sep 30, 2016
    Posts:
    1
    2022.2b4 have not fixed this bug yet. Any update on this?
     
  6. ankur-unity

    ankur-unity

    Unity Technologies

    Joined:
    Aug 12, 2021
    Posts:
    34
    It is caused by a bug in URP which is being fixed.

    As a workaround, AR Foundation 5.0.0-pre.12 added a new feature to set the camera background rendering order to "After Opaque". Try setting the Rendering Mode of ARCameraManager to "After Opqaue" in the inspector or use this API
    ARCameraManager.requestedBackgroundRenderingMode = CameraBackgroundRenderingMode.AfterOpaques
    .

    https://docs.unity3d.com/Packages/c...ameraManager_requestedBackgroundRenderingMode

    Last time I tested various combinations, the following set of editors and packages worked without issues:

    Editor Version:
    2020.3.37f1
    AR Foundation: 4.1.10
    URP: 10.9.0

    Editor Version: 2021.3.6f1
    AR Foundation: 4.2.3
    URP: 12.1.7

    Editor Version: 2022.1.10f1
    AR Foundation: 5.0.0-pre.12 (with After Opaque rendering mode)
    URP: 13.1.8

    Editor Version:
    2022.2.0b2.2700
    AR Foundation: 5.0.0-pre.12 (with After Opaque rendering mode)
    URP: 14.0.3
     
  7. pavel056

    pavel056

    Joined:
    May 24, 2021
    Posts:
    3
    But if use After Opaque rendering mode, the image from camera close the opaque geometry from scene
     
  8. shrey-malhotra

    shrey-malhotra

    Joined:
    Jan 27, 2013
    Posts:
    11
    I am having the same issue, selecting "After Opaque" occludes the geometry and only the camera view is rendered.

    Editor Version: 2022.1.20f1
    AR Foundation: 5.0.2 (with After Opaque rendering mode)
    URP: 13.1.8
     
    Last edited: Oct 29, 2022
  9. shrey-malhotra

    shrey-malhotra

    Joined:
    Jan 27, 2013
    Posts:
    11
    The way I solved it was by setting `Depth Texture Mode` to `Force Prepass` in the URP Asset Renderer.
    Not sure if this is an official fix.
     
    sharatachary and ROBYER1 like this.
  10. VitekCapS

    VitekCapS

    Joined:
    Jul 26, 2017
    Posts:
    4
    I solve this problem by switch "Render Mode" in ARCameraManager to `After Opaques`
    also i check my URP Asset and made sure for values in `Rendering Path` n `DepthTexture Mode` have been a
    `Forward` and `After Opaques` too.
    Its worked for me.

    As i know from this https://docs.unity3d.com/Packages/com.unity.xr.arfoundation@5.0/manual/migration-guide-5-x.html
    URP Version 14.0.2 Incompatibility
    When using URP version 14.0.2 there is a bug that causes URP to not respect RendererFeature input requests. This means that even though the ARCameraBackground might request for a Camera Depth Texture, URP will not respect this request and the camera background will overwrite geometry.

    To workaround this, make sure you are using URP version 14.0.3 or greater.


    Editor Version: 2022.2.0b14
    AR Foundation: 5.0.2
    URP: 14.0.3
     
  11. davidmo_unity

    davidmo_unity

    Unity Technologies

    Joined:
    Jun 18, 2019
    Posts:
    99
    This is true, however there is still an issue in URP 14 where you must use the `AfterOpaques` mode in 14. We are still working on the correct fix there.
     
  12. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Any update on a fix? This is a horrible user experience, I also found in 2022.2.1f1 using After Opaques on AR Camera Manager and in the URP asset, actual geometry in the scene would not render and only the background camera would show when in Editor using XR Simulation.
     

    Attached Files:

    Last edited: Jan 26, 2023
  13. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Edit: I can confirm this is fixed in 2022.2.3f1 using URP 14.0.4 and AR Foundation 5.0.3, I had to do this to roll back and get it working by reversing the fixes from above:

    1. AR Camera Manager - Render Mode set to 'Any'
    2. On the URP asset - Rendering > Render Path Forward, Depth priming Disabled (default I think) and Depth Texture Mode: After Opaques
    Screenshot 2023-01-26 at 12.44.49 pm.png
     
    andyb-unity and davidmo_unity like this.
  14. davidmo_unity

    davidmo_unity

    Unity Technologies

    Joined:
    Jun 18, 2019
    Posts:
    99
    Yes sorry, definitely got lost in the noise. The fix is available in later URP versions. A default URP ARFoundation project should not have anymore difficulties.
     
    ROBYER1 and newguy123 like this.
  15. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Would be neat if the AR Foundation Samples repo used URP or at least had a branch for that
     
  16. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    We aren't ready to pull in the work for "URP by default" at this time, but likely later this year!
     
  17. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Added a bug report for this one: IN-30833

    Here's a fun one - with URP in 2022.2.3f1, ARF 5.0.3, URP 14.0.5, if URP Asset > Opaque layer mask isn't set to 'everything' - in this example I was using Render Feature - Render Objects to make stencils and masks for AR portals, the XR Sim background doesn't render.

    I am confident that if there was a URP branch, some more of these issues would get caught, especially if we assume that Built-In Render pipeline is going to be deprecated for the upcoming URP/HDRP combo refactor. For now it is a real pain in the ass that we have so many render pipelines and bugs split across them. URP is a godsend for shader graph and renderer features! Screenshot 2023-01-31 at 9.06.57 am.png
    Screenshot 2023-01-31 at 9.07.06 am.png
     
    Last edited: Feb 2, 2023
  18. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    I have also found with Unity 2022.2.4f1, the XR Simulation Environments render on the M1 Mac Silicon Editor but on Windows Editor the environment renders black and I get this error:

    `d3d11: failed to create 2D texture shader resource view id=1928 [D3D error was 80070057]`

    I will post back the bug report ID for both these bugs.

    IN-30833
    and
    IN-30822


    Bug report id:

    In Mac Editor:


    In Windows Editor:
     
    Last edited: Feb 2, 2023
  19. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    Bug Report: IN-30822

    In Mac Editor:
    macerror.png

    In Windows Editor:
    windowserror.jpg
     
    Last edited: Feb 2, 2023
  20. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    XR Simulation environments are rendered on Layer 30 by default. If you name Layer 30 you can mask it correctly using Editor UI workflows like this, or change the layer that is used in your XR Simulation Project Settings: https://docs.unity3d.com/Packages/c...r-simulation/simulation-project-settings.html.

    There was some debate internally about automatically naming the layer as it could conflict with your existing settings, but I'll revive that conversation as our current solution is problematic for reasons you describe. (And indeed if there is a layer conflict, not naming the layer doesn't solve the issue but simply obscures it)

    Thanks for this report. To clarify, this is Windows 2022.2.4f1 with URP?
     
    Last edited: Feb 2, 2023
    ROBYER1 likes this.
  21. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    It would also help our investigation if you can confirm whether this reproduces in our Samples project? https://github.com/Unity-Technologies/arfoundation-samples This helps us rule out the possibility that there is something else in your project that is throwing the error
     
  22. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    I have identified the root cause of this issue by comparing the projects and copying the User Settings + Project settings asset files over one-by-one with source control. Having colour-space in Project Settings > Player > Other Settings set to Linear instead of Gamma when using Universal Render Pipeline on Windows Editor causes this issue. I will reply with this to the bug report to let QA know. This requires URP in the project.

    Most AR scenarios I test are for product visualisation so Linear is a must and obviously I found the layer issue as we work with AR portals and stencil effects from time to time in common AR situations.
     
    andyb-unity and newguy123 like this.
  23. StarFluke

    StarFluke

    Joined:
    Jan 19, 2013
    Posts:
    39
    Is there a release number or date when we should expect to see a fix?
    Thank you
     
  24. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    @ROBYER1 thanks for this additional context.

    @StarFluke when our QA team assigns this bug to us, they will create a public IssueTracker link that we will post here so you can follow the progress.
     
  25. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    What the bug report reference to track it? I got the same issue on Unity 2022.2.7f1 (Windows 11) with URP and Linear gamma space. All good on OSx. URP 14.0.6, AR foudnation 5.0.4
    Code (CSharp):
    1. Cannot create camera background material compatible with the render pipeline
    2. UnityEngine.XR.Management.XRGeneralSettings:AttemptInitializeXRSDKOnLoad () (at ./Library/PackageCache/com.unity.xr.management@4.2.0/Runtime/XRGeneralSettings.cs:148)
    3. d3d11: Creating a default shader resource view with dxgi-fmt=28 for a texture that uses dxgi-fmt=29
    4. d3d11: failed to create 2D texture shader resource view id=2578 [D3D error was 80070057]
    Couldn't understand what the reason when sample project worked fine and only my current project had it until found @ROBYER1 answer related to Linear/Gamma space
     
  26. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    The QA team couldn't understand my bug report and closed it. I have hundreds of accepted bug reports so I know how to write one up and explain it. I couldn't make the report any simpler than I could. At least your team are aware of this as that bug is now closed.
     
    WeiWuDe likes this.
  27. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    Unity team behaves as it always does, I am not surprized at all.
    I spent 2 days trying to migrate from 2021.3 to 2022.2 and just hit into couple of critical bugs related to AR Foundation 5.x and URP 14.x, and couldn't solve it. Just downgraded back.

    I always have a same feeling updating Unity products - it's the same if you come to car manufacturer official service after hearing about their incredible new model. You get behind the wheel, turn on the ignition, but.... the car is not driving. Checked everything to be sure you didn't miss anything but suddenly realize that there are no 3 wheels of 4!

    In other words - looks like Unity release new versions just to keep good reports and show roadmap goal achieved, but when you try these updates you find that COMMON things are not working anymore.

    I just can't imaging, how is it possible to release such crap without checking how AR Foundation works with all your URP versions, taking in account that URP is most commonly used pipeline, and AR is the product which still keep a lot of developers to use Unity and don't move to any other IDE.
     
    WeiWuDe likes this.
  28. zyndata

    zyndata

    Joined:
    Feb 15, 2015
    Posts:
    6
    In my case, the screen went black because Unity itself changes the culling mask during play mode. You can see it in the attached video. When the editor is turned off, the "everything" mask is selected. In play mode it turns off automatically.
     

    Attached Files:

  29. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    @ROBYER1 I see IN-30822 as still open and in review? Not sure what you mean about QA closing this issue?
     
  30. ROBYER1

    ROBYER1

    Joined:
    Oct 9, 2015
    Posts:
    1,454
    I was referencing IN-30833 bug which is: AR Foundation XR Simulated Environment doesn't show if URP Renerer Opaque Layer Mask isn't set to 'Everything'

    That bug report was resolved as: Not Qualified.
     
  31. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    ah I see. We do still need to name layer 30 so that layer masks will work as expected. I just pinged our team as a reminder to get that work queued up.
     
    ROBYER1 likes this.
  32. AeOngDev

    AeOngDev

    Joined:
    Sep 25, 2020
    Posts:
    8
    AR Foundation 4.2.3 version.. Please inform how to do that work in relation to the version. Anybody help me?
    I couldn't find the rendering mode "After Opqaue" OR "ARCameraManager.requestedBackgroundRenderingMode = CameraBackgroundRenderingMode.AfterOpaques"

    [My version]
    Editor version
    : 2021.3.8f1
    AR Foundation: 4.2.3
    URP: 12.1.7

    I'm sorry if my English was weird.
    upload_2023-5-15_16-58-56.png

    upload_2023-5-15_16-59-4.png

    upload_2023-5-15_16-59-13.png
     
  33. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    AfterOpaques was added in AR Foundation 5.0. The URP issue I'm referencing above has been long-fixed though, just update to the most recent patch of Unity 2021.
     
    AeOngDev likes this.
  34. Oktawian

    Oktawian

    Joined:
    Jan 24, 2015
    Posts:
    1
    Please provide a stable version as of today using
    Unity, URP and AR
    Has it ever worked? I need any working version.
    Thanks
     
  35. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    KyryloKuzyk likes this.
  36. flintml

    flintml

    Joined:
    Apr 13, 2021
    Posts:
    16
    My project is on Unity 2022.2 and can't go any earlier. I've tried seemingly every available combination of ARF + URP versions (the Package Manager seems to only ever make one version of each of these available at a time) and I have tried setting both my ARCameraManager and my renderer to "After Opaques", and I have the ARBackgroundRendererFeature feature added to my universal renderer.

    No matter what I do, I can't get the camera background to honor the alpha value and actually be transparent.

    Judging by this thread, it sounds like URP is just extremely buggy on AR and this simply doesn't work unless I have some magical combination of Editor + Packages?

    What are my options with ARF 5.0.x and URP 14.0.x?
     
  37. novaVision

    novaVision

    Joined:
    Nov 9, 2014
    Posts:
    518
    @flintml it finally works and I moved from 2021.3 to 2022.3 LTS just week ago.
    But to be sure everything will be fine with all the features you use in your project, just do the tests.
     
  38. flintml

    flintml

    Joined:
    Apr 13, 2021
    Posts:
    16
    It turns out I had to disable the HDR option on the pipeline asset. No idea why it was that specifically. What a mess. Anyway, seems to be working just fine now. :confused:
     
    Cuttlas-U likes this.
  39. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
    @flintml What platform(s) did you observe this? Unity does not support HDR rendering on Android or iOS (Apple themselves just introduced HDR support last year) but this is good to know
     
  40. mixedworldgmbh

    mixedworldgmbh

    Joined:
    Jan 28, 2023
    Posts:
    1
    This is still broken in my current project.
    Unity 2022.3.7f1 LTS.
    AR Foundation 5.0.7.
    URP 14.0.8
    Using the URP Empty Sample Template.
    I created a simple sample Scene.
    Added a AR Session.
    Converted the Camera to XRRig (which contains an AR Camera as a child.)
    Modified the High-Fidelity URP Renderer Asset to have AR Background Feature.

    It just won't show the camera background when running the app on the Phone. The SLAM works just fine and the content is also visible. But the background is just black.

    I also checked the permissions, Camera is set.
     
  41. unity_andrewc

    unity_andrewc

    Unity Technologies

    Joined:
    Dec 14, 2015
    Posts:
    223
  42. andyb-unity

    andyb-unity

    Unity Technologies

    Joined:
    Feb 10, 2022
    Posts:
    1,062
  43. SpiderJones

    SpiderJones

    Joined:
    Mar 29, 2014
    Posts:
    246
    The first time I updated my project from standard to URP, I had the same AR Foundation plane AR issue, there was no video feed. I fixed it by following these steps -> https://forum.unity.com/threads/arf...k-screen-and-no-tracking.915527/#post-6374280
    The Render Pipeline Asset under Quality was not referencing the same asset. That fixed my issue.

    Then for other reasons I had to revert my project via git. Then I updated the project again to URP, this time it worked and The Render Pipeline Asset was correctly set. I have no idea why, but seems like there might be an issue.

    I'm using Unity 2022.3.10 and ARFoundation 5.0.7 and URP 14.0.8
     
    Stijn_RMDY likes this.