Feedback Wanted: Lightweight Render Pipeline

Lightweight Pipeline
The Lightweight Pipeline is a Scriptable Render Pipeline available with Unity 2018.1. The LT pipe performs a single-pass forward rendering with light culling per-object with the advantage that all lights are shaded in a single pass. Compared to the vanilla unity forward rendering, which performs and additional pass per pixel light, using the LT pipeline will result in less draw calls at the expense of slightly extra shader complexity.

The pipeline supports at most 8 lights per-object and only supports a subset of vanilla Unity rendering features. A feature comparison table of Lightweight Pipeline vs stock Unity pipeline can be found here.

Lightweight Sample Project
We are providing a Lightweight Pipeline Template via Unity Hub. The project is already setup to render properly Lightweight Pipeline so you can easily experiment developing with the Lightweight Pipeline workflow.

Nightmares modified scene rendering with Lightweight Pipeline

How to use Lightweight Pipeline
The Lightweight Pipeline does not work with the Unity stock lit shaders. We have developed a new set of Standard shaders that are located under Lightweight Pipeline group in the material’s shader selection dropdown.

Lightweight Pipeline shaders

Standard (Physically Based): Single shader with both Metallic and Specular workflows. Light model similar and upgradable from stock Unity standard shaders. BRDF: Lambertian Diffuse + Simplified Cook Torrance (GGX, Simplified KSK and Schlick) Specular

Standard (Simple Lighting): Replaces the legacy mobile/lit shaders. It performs a non-energy conserving Blinn-Phong shading. Should be used for games that target devices with very limited bandwidth and that therefore cannot use Physically Based Shading.

Standard Terrain: Same as Unity’s stock terrain shader. (WIP)

Standard Unlit: Unlit shader with the option to sample GI. This replaces Unity’s stock unlit shaders.

Particles: Standard and Standard Unlit particles for lightweight pipeline. Same as Unity’s stock standard particles shaders with the exception of Distortion effect. (WIP)

Additionally, all Unity’s unlit stock shaders work with Lightweight Pipeline. That means you can use legacy particles, UI, skybox, and sprite shaders with the pipeline with no additional setup.

When the Lightweight Pipeline is set as the active rendering pipeline all game objects will be created with the correct shaders. This is achieved because the pipeline overrides the default materials in the engine.

The Lightweight Pipeline also provide material upgraders to upgrade Unity’s stock lit shaders to Lightweight ones. In order to upgrade materials go to Edit → Render Pipeline → Upgrade → Lightweight. Check Upgradable Shaders section below to see what unity stock shaders can be upgraded to Lightweight.

  • Upgrade Project Materials: upgrades all materials in the Asset folder to Lightweight materials.

  • Upgrade Selected Materials upgrade all currently selected materials to Lightweight materials.


Material Upgraders

Lightweight Pipeline Asset
The pipeline asset controls the global rendering quality settings and is responsible for creating the pipeline instance. The pipeline instance contains intermediate resources and the render loop implementation.

Lightweight Pipeline Asset

Rendering

Render Scale
Scales the camera render target allowing the game to render at a resolution different than native resolution. UI is always rendered at native resolution. When in VR mode, VR scaling configuration is used instead.

Pixel Lights
Controls the amount of pixel lights that run in fragment light loop. Lights are sorted and culled per-object.

Enable Vertex Lighting
If enabled shades additional lights exceeding the maximum number of pixel lights per-vertex up to the maximum of 8 lights.

Camera Depth Texture
If enabled the pipeline will generate camera’s depth that can be bound in shaders as _CameraDepthTexture. This is necessary for some effect like Soft Particles.

Anti Aliasing (MSAA)
Controls the global anti aliasing settings.

Shadows

Shadow Type
Global shadow settings. Options are NO_SHADOW, HARD_SHADOWS and SOFT_SHADOWS.

Shadowmap Resolution
Resolution of shadow map texture. If cascades are enabled, cascades will be packed into an atlas and this setting controls the max shadows atlas resolution.

Shadow Near Plane Offset
Offset shadow near plane to account for large triangles being distorted by pancaking.

Shadow Distance
Max shadow rendering distance.

Shadow Cascades
Number of cascades in directional light shadows.

In order to create a pipeline asset click on Asset → Create → Render Pipeline → Lightweight → Pipeline Asset

You can create multiple pipeline assets containing different quality levels. Assets can be set by either manually selecting a pipeline asset in Graphics Settings or by setting the GraphicsSettings.renderPipelineAsset property.

Q&A

What is scriptable render pipeline (SRP)?
SRP allow developers to write how Unity renders a frame in C#. We will release two builtin render pipelines with Unity: Lightweight Pipeline and HD Pipeline. This allows us to develop each pipeline focused on a set of target platforms, speeding up the development type. By exposing the rendering pipelines to C# we also make Unity less of a black box as one can see what is explicitly happening in the rendering. Developers can use the builtin pipelines we are providing, develop their own pipeline from scratch or even modify the ones we provide to adapt to their game specific requirements.

How does Lightweight Pipeline compare to Unity builtin pipelines?

Here’s a feature comparison table

Who should use Lightweight Pipeline?

Developers targeting a broad range of mobile platforms, VR and that develop games with limited realtime light capabilities.

What’s the development status of Lightweight Pipeline?

We are undergoing QA and optimization.

Where’s the Lightweight Pipeline source? How can I modify it or create my own pipeline?

Lightweight Pipeline resources are embedded in a package that gets downloaded by the Unity Package Manager. The package contents lie inside an internal Unity cache and they are not visible in the project folder. If you want to have access to Lightweight Pipeline source take a look at the Scriptable Rende Pipeline github page. We are working on the API and shader documentation at the moment.

I found an issue. How should I report it?

You can report any issues found in our github page.

3 Likes

Been looking into the LWRP now, and if I’m not mistaken, the thing that strikes me as problematic is that if I want to make a smaller change/addition I more or less need to copy the whole thing in order to retain the featureset. This is fine once, but it will in the end mean quite a lot of work trying to maintain it and keep it up to date with the official changes.

I would prefer the LWRP to be a bit less object oriented, and more library-like. So that methods like for instance SetupShadowReceiverConstants are not private methods of the pipeline class, but rather public utility functions of a support class. That way one can keep a pretty small custom core pipeline class, and reuse most of the LWRP functionallity except for the things you want to specifically change.

At least the methods and fields should be protected rather than private so that I can inherit the LWRP and call the functions from a subclass. Allthough in my view this is not as good as a utility library part of the same package.

4 Likes

The thing that concerns me the most with the ScriptableRenderPipelines is that to change and modify them, that still seems to require a pretty indepth amount of graphical programming knowledge.

There doesn’t seem to be a suitable mid-range between the HDRP and the LWRP, meaning a very black and white choice for people unable to modify them.

But that’s just the nature of things. Some things will always require a little more specialisation. You can’t expect every racing driver to also be a top quality mechanic, at least not until AI is good enough to fill in the blanks.

Seems to me that I could achieve most of builtin Unity with LW give or take a few quality tweaks. I would like to for instance add tessellation so I’ll be looking into that.

5 Likes

The problem is the current renderer is just way more dynamic. Thus moving to the scriptable render pipelines is a loss of function and ability for the engine.

Yes, we get some performance and graphic improvements (in theory), but for a lot of indie developers, these pipelines are just going to block them in more than the original rendering engine does.

3 Likes

I have no problem with it requiring deep graphics programming skills. But the current architecture seems too rigid in my opinion, making it time-consuming to maintain smaller customizations over time, while still staying up to date with Unity’s improvements.

2 Likes

[quote=“Huknar, post:5, topic: 692265, username:Huknar”]
Yes, we get some performance and graphic improvements (in theory), but for a lot of indie developers, these pipelines are just going to block them in more than the original rendering engine does.
[/quote]But making SRP exactly like the existing builtin engine will cause the same problems. What SRP asks you to do is make a decision, and then use shader graph to continue.

That you’re posting on lightweight means you want performance. But at the same time you want all the old features. That does not make sense. The reason LW is faster is because it does not do what the existing engine does. It does a lot less, and what it does do, it does differently. It is not necessarily faster either.

That’s my findings so far though, I’m sure you might find things different from your game’s perspective. Tried the shader graph?

1 Like

but won’t the old basic setup be available as a choice as well? (i thought i read that somewhere). And I’m sure the asset store will be brimming with other “User created Pipelines” … in the near future.

4 Likes

This sounds much like Valve’s implementation for Single Pass with shadows? Very excited for the render pipeline and what magicians are going to do with Unity.

1 Like

I just tried to get my Editor Extension running with SRP and apparently the camera events OnPreCull, OnPreRender and OnPostRender are not triggered. The manual seems to provide no information if these events have been deprecated.

@Tim-C : Shall I report this as a bug or is there a new way to subscribe to these events?

Edit: Reported as Case 1004625.

So basically artists of a 2d game can author content in 1x and scale down, as expected, on each screen, at runtime(because the renderer is accessible at runtime), while having a guarantee that the UI will stay crisp?

[Potential bug]: Seems as if the Environment Lighting settings in the Lithting Window does nothing. And whenever I hit play they are reset to the default settings of skybox + intensity 1.

I have seen a mention that this is fixed in 2018.1b9. :slight_smile:

Is there some info on how to setup the lightweight render pipeline in a new project? In a new project I have tried to right click to create the lightweightrender asset, but there is no option there. I have also tried dragging and dropping the asset from the lightweightandshadergraph project into a new project and it does not seam to recognize it. What am I missing?

Thanks

Open up the package manager (Window menu) and make sure the LWRP package is added to your project. Or you can clone the repo from github into your project. If you want to edit the code that is.

1 Like

These steps are based off of 2018.1b8 and are really easy to follow:

  1. Open the Package Manager (Window → Package Manager)
  2. Select ‘All’ and then select ‘Render-pipelines.lightweight’ and then ‘Install’.
  3. Once the installation as (successfully) finished, go to the Project Window and ‘Create → Rendering → Lightweight Pipeline Asset’.
  4. Open the Graphics Settings Window and set the newly-made Lightweight asset as the Scriptable Render Pipeline Asset.
  5. Done! :slight_smile: However, some of your materials might render in error-magenta and you might want to update these to use shaders that are compatible with the Lightweight Render Pipeline. You can do this manually (By selecting the desired Lightweight Shader in a Material’s Inspector’s Shader Menu; a set are included in the LW package when it is installed) or by using the Upgrade Material Tool (Edit → Render Pipeline → Upgrade Materials to Lightweight Materials).
4 Likes

@Andy-Touch : Do you have any information regarding the problem mentioned in my previous post?

Nope; probably better for someone more knowledgable (like @Tim-C ) to respond. :smile:

I’m writing a response to this today. It’s a long one so taking time.

2 Likes

Hi,

I just installed Unity 2018.1.0b9 and made a new project with LightWeight Pipeline (Both VR n normal ) … but the moment the unity opens it gives an error

Shader error in ‘LightweightPipeline/Standard (Physically Based)’: failed to open source file: ‘LWRP/ShaderLibrary/LightweightPassLit.hlsl’ (on metal)

Compiling Vertex program
Platform defines: UNITY_NO_DXT5nm UNITY_ENABLE_REFLECTION_BUFFERS UNITY_NO_CUBEMAP_ARRAY UNITY_USE_DITHER_MASK_FOR_ALPHABLENDED_SHADOWS UNITY_PBS_USE_BRDF1 UNITY_SPECCUBE_BOX_PROJECTION UNITY_SPECCUBE_BLENDING UNITY_ENABLE_DETAIL_NORMALMAP SHADER_API_DESKTOP UNITY_LIGHT_PROBE_PROXY_VOLUME UNITY_LIGHTMAP_DLDR_ENCODING

I cant see any object in the scene and the Lightweight shaders are in the section of FAILED TO COMPILE … Please tell me how to solve this problem.

I tried switching the platform to Android and Standalone but all the same