Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

ARFoundation now supports Lightweight Renderpipeline

Discussion in 'AR' started by jimmya, Oct 4, 2018.

Thread Status:
Not open for further replies.
  1. jimmya

    jimmya

    Joined:
    Nov 15, 2016
    Posts:
    793
    We have recently added support for using LWRP with ARFoundation Preview 18. This means that you can now create shaders in the new shader graph and render them in your AR apps. To achieve this we have introduced the notion of a ARFoundationRendererAsset that controls a custom ARFoundationRenderer--allowing you more control over the rendering.

    ARFoundation has not changed its support for the legacy render pipeline and the assets and shaders built for it, but has introduced a way for your projects to support LWRP with ARFoundation.

    To demonstrate how to use the new ARFoundationRendererAsset, we have created a branch of the arfoundation-samples project that has the components needed for LWRP support. This requires Unity 2018.3 as there is a dependency on LWRP 3.3.0

    If you want to see a starter project that works with LWRP, open SampleLWRPSCene and build it to your device - it should just work! :)


    To make it work with an existing project, follow these steps:

    1. You must change your whole project to use LWRP. See https://blogs.unity3d.com/2018/02/2...er-pipeline-optimizing-real-time-performance/ (or for TLDR: create a LightweightRenderpipelineAsset and set it to the Renderpipeline parameter in Graphics settings).This might cause some of your existing materials to not work (even if you attempted to upgrade them). Fix these materials by replacing them with new materials that support LWRP. There is a folder called LWRPSupport in the root. This contains all the components needed to support LWRP for ARFoundation background rendering.




    2. Next, locate your ARCamera game object which lives under the ARSessionOrigin game object, and examine it in the Inspector. Note the ARCameraBackground component. ARFoundation v1.0.0.0-preview.18 introduces the concept of a CustomRenderAsset which you can enable on your ARCameraBackground component. Check the “Use Custom Renderer Asset” on the component, which should reveal the “Custom Renderer Asset” parameter. Into this parameter, drag the LWRPBackgroundRendererAsset asset from the LWRPSupport folder.





    3. Finally, the CustomRendererAsset allows you to do more than just change the material that is used to render the background. In this case, it does change the material that is used (to one of the ones in the LWRPSupport folder), but it also adds some helper components on the camera game object that will allow it to hook into the part of the LWRP that does the camera rendering and setup the render to happen at the right time in the render pipeline.





    For more information on how this works, you can look at the source files in the LWRPSupport folder. There is some functionality in ARFoundation that was added to change the background renderer from the default behavior to use the CustomRendererAsset specified one.


    4. LWRPSupport folder contains shaders, materials and scripts that support the renderer above. It also contains a LWRPBackgroundRendererAsset that is used to provide the renderer and its settings to ARFoundation. To create one of these assets, select Assets>Create>XR>LWRPBackgroundRendererAsset which should create the asset in your project folder. In order for the background rendering shaders to be included when building your project, it needs to be referenced from somewhere, and this asset also allows you to reference the materials that use those shaders so that they are included.



    5. If you want to take advantage of the shader graph you will need to make sure to import the 3.3.0 - preview version. To do this open the package manager and click Advanced -> Show preview packages, next locate Shader Graph and select the version number in the upper corner. Under All versions locate 3.3.0 - preview and click Install.



    Please watch the arfoundation-samples project for future examples that include shader graphs. And enjoy making cool new content with ARFoundation and LWRP!
     

    Attached Files:

  2. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    Right on time, thank you
     
  3. Fl0oW

    Fl0oW

    Joined:
    Apr 24, 2017
    Posts:
    21
    Great news, we have been waiting for this! :) As you will integrate ARKit into ARFoundation I guess there is no plan to make LWRP usable for ARKit only, right?
     
  4. jg3d

    jg3d

    Joined:
    Jan 13, 2014
    Posts:
    17
    Amazing! Is it possible to use this solution with the ARKit 2 beta plugin? Sorry- I'm a little unclear about the relationship between the arfoundation and the bitbucket repo. Thanks!
     
  5. jimmya

    jimmya

    Joined:
    Nov 15, 2016
    Posts:
    793
    They are not related at all. It should be pretty straightforward to do something similar for ARKit plugin (when I get some spare cycles, or if someone wants to take a stab at it and send me a PR :))
     
    dannyp159, Fl0oW and rob_ice like this.
  6. jg3d

    jg3d

    Joined:
    Jan 13, 2014
    Posts:
    17
    Cool- have you (or anyone here) had a chance to take a look at it? I haven't started digging into it yet, but I'm happy to give it a shot if someone can give me a little more guidance about the relevant differences between the arfounation and the plugin.
     
  7. michacardenas

    michacardenas

    Joined:
    Sep 20, 2018
    Posts:
    1
    Hi all, I'm also trying to use LWRP with the ARkit plugin, and I tried to follow these instructions but they don't work with the ARkit plugin, so just another plea for some help here... Thanks!
     
  8. rob_ice

    rob_ice

    Joined:
    Nov 11, 2016
    Posts:
    112
    This hasn't been set up yet -as JImmya said, somebody should have a go at making it work and submitting a pull request
     
  9. bondd_dev

    bondd_dev

    Joined:
    Feb 13, 2014
    Posts:
    2
    Hi, I tried cloning the LWRP branch and ran it with 2018.3.0b6.

    I verified in the package manager that the same package versions are being used as they are in Packages/manifest.json

    I am getting this single error -

    arfoundation-samples-lwrp_support/Library/PackageCache/com.unity.xr.arextensions@1.0.0-preview.4/Runtime/XRCameraExtensions.cs(19,88):

    error CS1070: The type `UnityEngine.Experimental.XR.XRCameraSubsystem' has been forwarded to an assembly that is not referenced.

    Enable the built in package 'JSONSerialize' in the Package Manager window to fix this error.

    Any thoughts?

    Thanks
     
  10. real2u

    real2u

    Joined:
    Jun 20, 2018
    Posts:
    13
    Amazing work @jimmya, thanks for sharing it with us. I've managed to get the project up and running, and LWRP really improves my app performance, thanks once again.

    I was wondering if it's possible to include the PostProcessing (that exists within LWRP) into my project. I've noticed that you created an 8th layer called PostProcessing, so I decided to give it a shot.

    I added a Post Process Layer to the Camera, changed the camera layer to PostProcessing, and created an empty gameobject with my Post Process Volume. In the end, it all failed and that blurry effect (when LWRP is not properly set), started happening once again.

    Any idea on how to get it working ?
     
  11. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    584
    Cromfeli, Blarp and rob_ice like this.
  12. rob_ice

    rob_ice

    Joined:
    Nov 11, 2016
    Posts:
    112
    Thanks for the heads up, feels like every time I want to use the new SRP in projects, there is always a gotcha or a bug to be fixed :( keep the fixes coming!
     
    Blarp and newguy123 like this.
  13. Blarp

    Blarp

    Joined:
    May 13, 2014
    Posts:
    269
    It's weird, I get the problem in ARFoundation & solo unityarkit plugin, but not Vuforia.

    Hoping this is fixed soon!
     
  14. newguy123

    newguy123

    Joined:
    Aug 22, 2018
    Posts:
    1,248
    Is LWRP 3.3.0 still the only version supported by AR Foundation?
     
  15. jimmya

    jimmya

    Joined:
    Nov 15, 2016
    Posts:
    793
    We're working on later versions - please hang tight!
     
  16. Cromfeli

    Cromfeli

    Joined:
    Oct 30, 2014
    Posts:
    202
    There have been questions about AR Foundation status. In the documentation it is said the support was introduced for 2018.1 but there is no information how long it will be "Experimental". This is a real issue now when trying to target LTS or not for 2018.4 if it will not actually have AR Foundation or not. Can you clarify the status? When it will be stable for production use?
     
  17. real2u

    real2u

    Joined:
    Jun 20, 2018
    Posts:
    13
    It was pretty stable using 2018.3.11b, really can't complain
     
  18. Bitfabrikken

    Bitfabrikken

    Joined:
    Mar 24, 2013
    Posts:
    34
    What's the ETA on this? I have a project I want to update before Apple closes down the App Store for submissions on december 23rd. Having to still use 3.3.0 of LWRP instead of 4.6.0 is a bit frustrating :)
     
  19. Cromfeli

    Cromfeli

    Joined:
    Oct 30, 2014
    Posts:
    202
    Sorry if I was coming off as complaining. Not the intention. What I was more wondering is that will 2019.1 have AR Foundation as a new feature and it will not be as full fledged feature in 2018.4 LTS. Just to be able to target 2018.4 LTS for production use or keep upgrading the project to 2019.1 and finally move to LTS with AR Foundation year later when 2019.4 LTS is out. Just a timing question in terms of project what wants to use AR Foundation.
     
  20. mebalzer

    mebalzer

    Joined:
    Mar 19, 2015
    Posts:
    16
    I second Bitfabrikken's request. Even though I was able to manually move many shader selections back to the 3.3.0 LWRP/Lit, I would rather be using Autodesk Interactive shaders.

    Also will there be Post Processing package integration in LWRP/AR Foundation?
     
    Blarp likes this.
  21. asa989

    asa989

    Joined:
    Dec 18, 2015
    Posts:
    52
    are there any way to control some camera features? like camera exposure.
     
  22. jimmya

    jimmya

    Joined:
    Nov 15, 2016
    Posts:
    793
    Only if the underlying SDK will allow it - currently neither ARKit nor ARCore has this control. You could simulate camera exposure using a post process of some sort.
     
    asa989 likes this.
  23. ShubhamSaxena

    ShubhamSaxena

    Joined:
    Aug 31, 2017
    Posts:
    3
    Will ARFoundation not support LWRP's latest version?
     
    Lucas-Hehir likes this.
  24. Futurristic

    Futurristic

    Joined:
    Jun 21, 2016
    Posts:
    42
    hello All,

    I'm getting the following error when I'm trying to compile it in Xcode. can someone help.

    Undefined symbols for architecture arm64:

    "_OBJC_CLASS_$_ARWorldMap", referenced from:

    objc-class-ref in UnityARKit.a(WorldMapManager.o)

    ld: symbol(s) not found for architecture arm64

    thanks
     
  25. asa989

    asa989

    Joined:
    Dec 18, 2015
    Posts:
    52
    Thanks for answer. That's unfortunate. post processing wouldnt help me for what I want to do. I also need other camera features too. but anyway, its good to know that its not possible.
     
  26. real2u

    real2u

    Joined:
    Jun 20, 2018
    Posts:
    13
  27. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    Hi @jimmya getting a bunch of errors putting this branch in to an empty 2018.3.1f1 project:

    Library/PackageCache/com.unity.postprocessing@2.0.11-preview/PostProcessing/Runtime/PostProcessLayer.cs(9,39): error CS1070: The type `UnityEngine.XR.XRSettings' has been forwarded to an assembly that is not referenced. Enable the built in package 'JSONSerialize', which is required by package 'VR', in the Package Manager window to fix this error.
     
    Last edited: Jan 18, 2019
    tinatotty91 likes this.
  28. enhawk

    enhawk

    Joined:
    Aug 22, 2013
    Posts:
    833
    I'm having two issues here with the latest version of 2018.3 & ARFoundation + LWRP:

    1. Screen Space Camera Canvas doesn't seem to appear in scenes that use AR.

    2. When loading an AR scene from a 2d scene (like a main menu), the screen is filled with glitch garbage graphics for a few seconds then the camera feed is shown (iPhoneX). I have tried both async and normal loading.
     
    Last edited: Jan 18, 2019
  29. jimmya

    jimmya

    Joined:
    Nov 15, 2016
    Posts:
    793
    Last edited: Jan 18, 2019
    aaaavvvv, Blarp and newguy123 like this.
Thread Status:
Not open for further replies.