Update: LWRP is now out of preview and production-ready. Get more info in our 2019.1 release post.
In a recent blog post we introduced the concept of Scriptable Render Pipelines. In short, SRP allow developers to control how Unity renders a frame in C#. We will release two built-in render pipelines with Unity 2018.1: the Lightweight Pipeline and HD Pipeline. In this article we’re going to focus on the Lightweight Pipeline or LWRP.
By exposing the rendering pipelines to C# our goal is to make Unity less of a black box and enable developers to explicitly control what is happening during rendering. Developers can use the built-in pipelines we’re providing, develop their own pipeline from scratch or start by modifying one of the provided pipelines to meet their specific requirements.
We’ve released a video which provides a short overview of the Scriptable Render Pipeline concept including some footage of projects using the various pipelines:
The goal of the LWRP is to provide optimized real time performance on performance constrained platforms by making some tradeoffs with regard to lighting and shading.
The target audience for LWRP is developers targeting a broad range of mobile platforms, VR and those that develop games with limited realtime lighting needs. The LWRP performs single-pass forward rendering with one real time shadow light and light culling per-object with the advantage that all lights are shaded in a single pass. Compared to the legacy pipeline forward rendering, which performs an additional pass per pixel light within range, using the LW pipeline will result in less draw calls. This is at the expense of some additional shader complexity due to more lights per pass. The LWRP is also supported by our Shader Graph tool, which will provide some additional benefits with regard to shader authoring workflow.
The LWRP has its own process for rendering and therefore requires shaders which are written with it in mind. We have developed a new set of Standard Shaders that are located under the Lightweight Pipeline group in the material’s shader selection dropdown. These include a Standard PBR shader, a Non PBR Standard shader with a simplified lighting model, a Standard Terrain shader and a Standard Unlit shader. It’s worth noting that all Unity’s unlit stock shaders work already with LWRP. This includes legacy particles, UI, skybox, and sprite shader.
The Lightweight Pipeline also provides material upgraders to upgrade Unity’s stock lit shaders to shaders compatible with the pipeline. In order to upgrade materials go to Edit -> Render Pipeline -> Upgrade -> Lightweight. You can choose to either upgrade all material in a project, or selected materials.
The currently selected render pipeline is selected by assigning a pipeline asset in the Scriptable Render Pipeline Settings of the Graphics Settings window. It can also be assigned from script via the GraphicsSettings.renderPipelineAsset property.
In addition to selecting a pipeline to define the overall rendering approach of your project at the outset, it’s possible to store multiple quality settings within different instances of the same type of render pipeline. 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.
The rendering features of LWRP are mainly a subset of the built-in renderer. In order to improve performance on performance limited platforms, certain functionality has been deliberately excluded. Unity provides developers with a wide array of tools and techniques to apply to their games. The risk in this is that sometimes the wrong technique is applied to a game which doesn’t have the performance resources to support it. The goal of providing specialized rendering pipelines as templates is to mitigate the possibility for users to make certain potentially costly mistakes in terms of performance. Deploying inappropriate post processing effects for a target platform for example may make the game slow on a device, even though those effects are supported in Unity and might perform appropriately on the appropriate target platform.
Realtime global illumination is another example of a feature which is rarely used on the LW RP target platforms and has therefore been removed. The single supported rendering path is single-pass forward, which is another decision which privileges performance over rendering complexity. The table below provides further detail about which techniques are supported in the Built-In Pipeline, and which are supported in Lightweight.
Unity Built-In Pipeline | Lightweight Pipeline | |
Platform Coverage | All | All |
Rendering Paths | Multi-pass Forward
Multi-pass Deferred | Single-pass Forward |
Lighting Attenuation | Separate precomputed attenuation textures for Point and Spot
Vertex light attenuation does not reach 0 intensity at range boundary. | Attenuation computed in the shader smoothly fading to light range. Inner and outer angle for spot lights. |
Color Space | Linear with sRGB light intensity
sRGB | Linear preferred, Gamma supported
Linear light intensities |
Realtime Lights | Directional, Spot and Point
Amount of pixel lights controlled by Quality Settings Forward path limited to 8 pixel lights. Supports up to 4 vertex point lights. | Directional, Spot and Point
Amount of pixel lights controlled by Pipeline Asset Limited to 8 pixel lights. Supports up to 4 vertex point lights. |
Light Modes | Baked
Mixed Baked Indirect Shadow Mask Distance Shadowmask Subtractive Realtime | Baked
Mixed Baked Indirect Realtime |
Global Illumination | Directional, Spot, Point and Rectangular Area Lights
Baked Lightmap (Non-Directional and Directional) Light Probes Realtime Dynamic Lightmap Realtime Lightprobes | Directional, Spot, Point and Rectangular Area Lights
Baked Lightmap (Non-Directional and Directional) Light Probes Realtime GI Not Supported. |
Light Culling | Per-Object. No Compute. | Per-Object. No Compute. |
Shader Library | Dozens of non physically based shaders specializations
Unified Standard PBS Shaders: Metallic workflow Specular workflow Roughness workflow | Unified Standard non physically based Shader (covers most legacy and mobile lit shaders)
Unified Standard Shader (Metallic or Specular workflow) |
Physically Based Shading | Disney Diffuse + Cook Torrance (GGX, Smith, Schlick) Specular
Lambertian Diffuse + Simplified Cook Torrance (GGX, Simplified KSK and Schlick) Specular Lambertian Diffuse + Non-Microfaceted LUT Specular | Lambertian Diffuse + Simplified Cook Torrance (GGX, Simplified KSK and Schlick) Specular |
Light Cookies | Monochrome | Not supported in V1 |
Light Probes Modes | One interpolated probe
LPPV | One interpolated probe |
Reflection Probes | Sorted per-object, blend between at most 2 probes | Sorted per-object, no blending |
Shadows Features | PSSM Stable and Close Fit
Filtering: PCF No depth clip. Pancaking done in vertex. | PSSM Stable Fit
Filtering: PCF No depth clip. Pancaking done in vertex. |
Shadow Modes | Light Space
Screen Space | Screen Space |
Shadow Casting Lights | Directional, Spot, Point
Multiple shadow light casters, one per-pass. | Directional and Spot
Single shadow light caster supported as main light. |
General | ||
Camera | Sorts camera by depth value
Stack Management Groups by common camera state Handles depth state between cameras | Sorts camera by depth value
No stack management RenderTarget scale supported Game renders at scaled resolution UI renders at native resolution |
Anti-Aliasing | MSAA, TAA | MSAA |
Pipeline Additional Data | Motion Vectors | None |
Post-Processing | Legacy Post-Processing stack
new Post-Processing Stack | Subset of the new Post-Processing Stack FX
No support for: TAA, Motion Blur, SSR |
Debug option | Display GBuffer
Display various bake lighting view mode | |
Sky lighting | Procedural Sky
Cubemap/LatLong Sky Ambient Lighting | Procedural Sky
Cubemap Ambient Lighting |
The incredible potential of the Scriptable Render Pipeline architecture is that it’s more open and customizable than rendering in Unity ever has been. If you want to have access to Lightweight Pipeline source, take a look at the Scriptable Render Pipeline github page. There you can grab the C# source for the LW RP and begin making modifications to create a pipeline which is uniquely suited to your project. If you run into any issues, we’d love to hear about them via our github page. We’re also looking forward to hearing from you on the beta forum.