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:
You must change your whole project to use LWRP. See Unity Blog (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.
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.
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.
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.
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!
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?
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!
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 :))
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.
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!
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.
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!
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?
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
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.
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?