This GitHub project provides C# scripts and shaders that make Projector component work with Lightweight Render Pipeline (LWRP).

Verified LWRP version

5.7.2

Install

If you use git, clone (or submodule add) the repository into the Assets folder in your Unity Project. If you don’t use git, you can download zip file and extract it into the Assets folder.
URL: https://github.com/nyahoon-games/ProjectorForLWRP.git

Setup

First of all, you need to add ProjectorRendererFeature into your Lightweight Render Pipeline. If you created your project from LWRP template (or already configured LWRP properly), a LightweightRenderPipelineAsset had been assigned to Scriptable Render Pipeline Settings in Graphics Settings.

Double click the asset to select it in Inspector View.

If you are using the default forward renderer, change Renderer Type to Custom, then click the small button of Data field, and select ForwardRendererWithProjectorPass.

If you are already using your custom forward renderer, please add ProjectorRendererFeature into your forward renderer data.

How to use

Add a Projector For LWRP component to your Projector object, if you already have one. If you want to create a new Projector object, just add a Projector For LWRP component to an empty GameObject, then Projector component will also be added.

Projector component will automatically disabled by Projector For LWRP component though, you still need to setup the properties of Projector component as usual. One thing that is different from usual settings is that you cannot use the projector shaders in Standard Assets. Please use one of the shaders in this project, or create a custom shader if needed (see below for more details). The shaders in Fast Shadow Receiver and Dynamic Shadow Projector will be available after update.

In addition to setting up Projector properties, you might need to setup the properties of Projector For LWRP component.

Properties of Projector For LWRP component

Cameras An array of cameras in which the projector is rendered. If it is empty, Camera.main will be used. To add a camera to the array, increase Size first, then put the camera to the last element of the array.
Shader Tag List An array of LightMode tag values. Only the renderers whose material has a shader that contains a pass whose LightMode tag value is identical to one of the values in the array can receive projection. If a shader pass doesn’t have LightMode tag, its LightMode tag value is considered as SRPDefaultUnlit. To add a value, please increase Size first.
Render Queue Lower/Upper Bound Only the renderers of which the render queue values of their materials are within this range can receive projection.
Render Pass Event An event in which projector render pass is inserted. Please be aware that the render queue value of the projector’s material is ignored.
Per Object Data Kinds of per object data (other than transform matrix) that are required by the projector’s material.
Use Stencil Test There is a chance to improve the rendering performance if stencil test is enabled. Just try and see if it is effective or not. Don’t need to use stencil test, if the projector is used with Fast Shadow Receiver.

Create a custom projector shader

If you need a custom projector shader, please include “Assets/ProjectorForLWRP/Shaders/P4LWRP.cginc” and use fsrTransformVertex function to transform vertex and projection uv. The shader must be compiled with FSR_PROJECTOR_FOR_LWRP keyword.

Sample Code:

Links

6 thoughts on “Projector For LWRP

  • 2019/06/06 at 3:34 PM
    Permalink

    You guys are lifesavers! This helped so much! Just a side note for anyone else who may come across the problem we did, leaving “Draw Instanced” on a Terrain will prevent a projector from showing up on that Terrain. At least for 2019.1f.

    Reply
    • 2019/06/12 at 10:56 AM
      Permalink

      Thank you for sharing your experience! If you want to keep “Draw Instanced” on, try our another asset Fast Shadow Receiver which can receive a projector shadow on behalf of the terrain.

      Reply
  • 2019/07/25 at 12:47 PM
    Permalink

    Where is the option to add ProjectorRendererFeature in Unity 2018?

    Reply
    • 2019/07/26 at 9:55 AM
      Permalink

      It seems like Projector For LWRP is not available in Unity 2018. The latest version of LWRP available in Unity 2018 is 4.10 preview which doesn’t have ScriptableRendererFeature class.

      Reply
  • 2019/07/29 at 12:12 AM
    Permalink

    Hi,

    Anyone that can confirm that it works LWRP 5.16.1 as well? It seems that I can not make it work properly with 5.16.1.

    Reply
    • 2019/07/29 at 2:59 PM
      Permalink

      I tried LWRP 5.16.1 and I didn’t see problems. What kind of issues did you find?

      Reply

Leave a Reply to WILEz Cancel reply

Your email address will not be published. Required fields are marked *

Anti Spam Code *