Search Unity

LWRP + ARFoundation workaround for 2019.1

Discussion in 'AR' started by todds_unity, Apr 19, 2019.

  1. todds_unity

    todds_unity

    Joined:
    Aug 1, 2018
    Posts:
    324
    We have a workaround for LWRP+ARFoundation on 2019.1. Version 5.6.1 of both LWRP and ShaderGraph will work with ARFoundation on 2019.1.

    Switching LWRP and Shader both to 5.6.1 versions will enable LWRP and ARFoundation to work together.


    In the arfoundation-samples repository, I have created a new branch lwrp-2019.1 that has this implemented.
    https://github.com/Unity-Technologies/arfoundation-samples/tree/lwrp-2019.1


    For your own projects, reference these versions of the following packages:

    Code (JavaScript):
    1. {
    2.   "dependencies": {
    3.     "com.unity.render-pipelines.lightweight": "5.6.1",
    4.     "com.unity.shadergraph": "5.6.1",
    5.     "com.unity.xr.arfoundation": "1.1.0-preview.6"
    6.   }
    7. }
    We are working to resolve some issues with the verified 5.7.2 version of LWRP and ARFoundation. We will update as soon as we have a working solution.

    Todd


    Edit (2019-08-29):

    AR Foundation 3.0.0-preview now supports LWRP and URP.

    https://forum.unity.com/threads/con...-0-0-preview-to-work-with-lwrp-or-urp.736583/
     
    Last edited: Aug 29, 2019
  2. Blarp

    Blarp

    Joined:
    May 13, 2014
    Posts:
    270
    OMG THX
     
  3. michaelybecker

    michaelybecker

    Joined:
    Jun 18, 2014
    Posts:
    19
    Thanks, that's fantastically helpful.
    1. Would you happen to know if the VFX Graph is also compatible, and if so, which version?
    2. So in terms of the path of least resistance, the template to start a new project with would be 3D, right? LWRP introduces 5.7.2 and I heard mixed things about downgrading packages... The initial LWRP scene seems not to work out of the box.
     
  4. Christopher-Anderson-GISP

    Christopher-Anderson-GISP

    Joined:
    Mar 5, 2015
    Posts:
    19
    Finally got it working using the Lightweight RP (Preview) template in 2019.1.0f2. In order to get it to work using the LWRP and Shader Graph 5.6.1 I had to turn on Face Tracking even though I'm not using it. Apparently when it was unchecked it wasn't being properly stripped out when building the xCode project.

    Another issue was the frame rate. I used the LWRP sample scene and just removed the camera and replaced it with the AR Foundation camera (AR Session, AR Session Origin, and adding in the LWRP camera data, etc). The frame rate I was getting was only 17; far below the 30fps that I was targeting, and the CPU usage stayed at ~122%. The iPad model I'm testing on is MP2F2LL/A which only has an A9 chip so I'm not sure if that's the issue or if the Lightweight RP (Preview) template's sample scene is just too much for an AR experience.

    Anyone else seeing this? Are there other project settings that need to be adjusted to improve frame rate and CPU usage?
     
  5. edee1337

    edee1337

    Joined:
    Apr 10, 2013
    Posts:
    34
    I'm seeing much higher CPU usage in 2019.1 + LWRP compared to 2018.3 without LWRP on an iPhone X
     
  6. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    Which version of LWRP is compatible with the VFXGraph?
     
  7. Blarp

    Blarp

    Joined:
    May 13, 2014
    Posts:
    270
    If you are using ARFoundation, none, because we are stuck at 5.6.1.

    VFX graph is going to be a game changer just as shadergraph is. Looking forward to it
     
    aalmada likes this.
  8. eco_bach

    eco_bach

    Joined:
    Jul 8, 2013
    Posts:
    1,601
    That's what I thought:( So no fancy particle effects in AR.....
     
  9. Amin-

    Amin-

    Joined:
    Sep 27, 2017
    Posts:
    26
    Hi @todds_unity ...
    How can I download LWRP Version 5.6.1 in 2019.1.1 ?!
    Snap35.jpg
    there's nothing about that version!
     
  10. oleyb

    oleyb

    Joined:
    Nov 8, 2012
    Posts:
    15
    Edit your manifest.json directly.
     
    Blarp and Amin- like this.
  11. Amin-

    Amin-

    Joined:
    Sep 27, 2017
    Posts:
    26
    wow... I really appreciate your reply @oleyb.
    clean and simple :)
     
    Blarp likes this.
  12. oleyb

    oleyb

    Joined:
    Nov 8, 2012
    Posts:
    15
    Awesome, I'm glad it worked out for you. :)
     
    Amin- likes this.
  13. Bystander333

    Bystander333

    Joined:
    Jan 11, 2018
    Posts:
    6
  14. danlee_lils

    danlee_lils

    Joined:
    Mar 28, 2018
    Posts:
    4
    Any update on this?? It clearly is broken and we can't use the latest...
     
  15. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    I have a project here https://github.com/StigOlavsen/LightweightARFoundation that has a workaround for using AR Foundation with LWRP 5.13. I've been told it doesn't work on Android (haven't had the chance to test/fix), only on iOS, but it is probably an easy fix if you are adventurous.
     
    BobbyVR and Blarp like this.
  16. agpatel0007

    agpatel0007

    Joined:
    Aug 21, 2014
    Posts:
    14
    AR camera goes blank after upgrading project to LWRP 5.7.2 and using ar foundation 2.2.0
    any solution ?
     
  17. danlee_lils

    danlee_lils

    Joined:
    Mar 28, 2018
    Posts:
    4
    This is what I experienced as well. Apparently, the way to fix it is to assign Custom Render Asset in ARCamera. The render asset is provided in LWRPSupport branch in the ARFoundationSample but the codebase is not compatible with the latest LWRP. ARFoundation team needs to fix it so it is compatible with the latest LWRP. I don't plan to use workaround with older version. Not a suitable solution.
     
    createtheimaginable likes this.
  18. agpatel0007

    agpatel0007

    Joined:
    Aug 21, 2014
    Posts:
    14
    I didnt find custom render asset anywhere
    do you have in your project ?
     
  19. rirfan

    rirfan

    Joined:
    Mar 16, 2018
    Posts:
    1

    Thanks @steego for the project. I am new to unity and shaders (still learning). I tried your project on Android, tracking and planes are working but camera background is pink. I tried to replace the shader with the one that provided in LWRP Support folder, and changing some properties, but not worked. If you give some pointers for fixing the ARCoreBackgroundLWRP.shader, It will be helpful for me a lot.
     
    Last edited: Aug 8, 2019
  20. steego

    steego

    Joined:
    Jul 15, 2010
    Posts:
    969
    Sorry I don't have much time to look into it right now. The shader requires GLES 3, and the GL_OES_EGL_image_external_essl3 extension, but this should be the same as Unitys project for the old LWRP.

    I suspect it might be due to not getting camera permissions, or that the camera isn't started somehow, but I can't say for sure without debugging it myself.
     
  21. unnanego

    unnanego

    Joined:
    May 8, 2018
    Posts:
    199
    How about 2019.2?
     
  22. SilverSc0ut

    SilverSc0ut

    Joined:
    Apr 12, 2018
    Posts:
    2
    I started to look into it, i haven't found the solution yet since it seems all the links to the git repositories for LWRP and ARFoundation are broken now
     
  23. Yashwanth_Personal

    Yashwanth_Personal

    Joined:
    Jul 23, 2019
    Posts:
    6
  24. todds_unity

    todds_unity

    Joined:
    Aug 1, 2018
    Posts:
    324
    Blarp likes this.
  25. synok

    synok

    Joined:
    Jun 7, 2011
    Posts:
    126
    Recently switched to the 2019.3.0b1 beta. I wanted to do this early to upgrade to URP so I am ready to go with it. Previously I had an issue where it did not render the background camera. Right now it is the same, but the background is completely black. I can still place my model in AR though. Waiting for updates on this and the AR plugins to fully work with URP. I don't really bother with workarounds at the moment because I will probably be back on square one when 19.3 comes out of beta. Then we need new versions and workarounds anyway. Not really expecting it to work out of the box.
     
  26. todds_unity

    todds_unity

    Joined:
    Aug 1, 2018
    Posts:
    324
    Did you follow the project configuration instructions on https://forum.unity.com/threads/con...-0-0-preview-to-work-with-lwrp-or-urp.736583/ ? And are you using the AR Foundation 3.0.0-preview.1 that was published yesterday?

    Todd
     
  27. synok

    synok

    Joined:
    Jun 7, 2011
    Posts:
    126
    Trying it out now as we speak, but cannot find ARBackground in the list of Rendering Features.

    EDIT: Nevermind, plugins not updated. Fixed now. Getting back here soon.
     
    Last edited: Aug 29, 2019
    Blarp likes this.
  28. synok

    synok

    Joined:
    Jun 7, 2011
    Posts:
    126
    @todds_unity No, sorry. I did not get it to work. But this time it falls back on the skybox texture rather than complete darkness. I tried to adjust different settings. No camera background.
     
  29. todds_unity

    todds_unity

    Joined:
    Aug 1, 2018
    Posts:
    324
    If you switch back to the Legacy RP by selecting "None" for ProjectSettings -> Graphics -> ScriptableRenderPipelineSettings, then build&deploy&run, what does the background display?

    Note that switching back to Legacy RP may cause other shaders to render incorrectly. However, for this test, I am only interested in what happens to the background.

    Additionally, if you could provide this information:
    - What version of the AR Foundation package?
    - What version of the ARCore XR Plugin package?
    - What version of the ARKit XR Plugin package?
    - What version of the Universal RP package?
    - Does this issue occur on Android, iOS, or both Android&iOS devices?

    Todd
     
  30. synok

    synok

    Joined:
    Jun 7, 2011
    Posts:
    126
    This dark pattern. Nothing else.
    https://imgur.com/a/zLPhJxB

    AR Foundation: 3.0.0 preview 1 (To test AR support with URP)
    ARCore XR Plugin: 3.0.0 preview 1
    Universal RP 7.0.1
    Android
     
  31. todds_unity

    todds_unity

    Joined:
    Aug 1, 2018
    Posts:
    324
    If you are seeing a black background with the Legacy RP, the problem is not with the LWRP/URP implementation. More than likely, the problem is with the scene or project.

    - On your game camera, do you have the AR Camera Manager script component?
    - On your game camera, do you have the AR Camera Background script component?
    - Do you have a game object with the AR Session Origin script component?
    - Does the Camera property on the AR Session Origin component point to the game camera that has your AR Camera Manager on it?
    - Do you have a game object with the AR Session script component?

    Todd
     
  32. synok

    synok

    Joined:
    Jun 7, 2011
    Posts:
    126
    - Yes
    - Yes
    - Yes
    - Yes
    - Yes
     
  33. todds_unity

    todds_unity

    Joined:
    Aug 1, 2018
    Posts:
    324
    @synok Would you be able to DM me a copy of your project? I just need one sample scene that is displaying the behavior.

    Todd
     
  34. synok

    synok

    Joined:
    Jun 7, 2011
    Posts:
    126
    Solution if someone has the same or similar issue as I had, thanks to @todds_unity :

    Make sure you have latest version of your packages (URP should be updated and set up properly (version 7.0.1 tested), AR Foundation, AR Subsystems and ARCore XR Plugin should use the 3.0.0 preview update (Select "See all versions in the Package Manager to access those). Of course, shaders should be set up for the Universal Rendering Pipeline too. And what fixed it for me was this

    When the ARCameraBackground component is enabled, the ARCameraBackground code should be caching the state of the Unity camera's clearFlags property and then setting the Unity camera property to Don'tClear. When the ARCameraBackground is disabled, it should restore the Unity camera property to the original value that it had cached.

    "Should", so at the moment it is a bug that makes the ARCameraBackground not rendering properly.

    So please set your Background Type of the AR Camera to something else than "Skybox". My AR app is working as it used to now and I am grateful for the help of the community here.
     
    Last edited: Aug 31, 2019
    unnanego likes this.
  35. MaryamKamel

    MaryamKamel

    Joined:
    Feb 5, 2016
    Posts:
    22
    i have an AR project built in Unity 2019.1 with ARfoundation 2 and i would like to create some effects using LWRP and shaderGraph , also the link above does not work , what would be best for me to do?