Search Unity

(LWRP) How to use a custom post process

Discussion in 'Universal Render Pipeline' started by Vitalis08, Feb 6, 2020.

  1. Vitalis08

    Vitalis08

    Joined:
    Mar 4, 2014
    Posts:
    2
    Hi, I've just upgrade my project to Unity 2019.3 tu use 2D lights and LWRP.
    Unfortunately I've lost all my post process doing it since we can't use function like OnRenderImage in LWRP
    I've tryed to write my own custom effet to replace like said here : https://github.com/Unity-Technologies/PostProcessing/wiki/Writing-Custom-Effects
    And done that :
    Code (CSharp):
    1. [PostProcess(typeof(GrayscaleRenderer), PostProcessEvent.AfterStack, "Custom/Grayscale")]
    2. public sealed class Grayscale : PostProcessEffectSettings
    3. {
    4.     [Range(0f, 1f), Tooltip("Grayscale effect intensity.")]
    5.     public FloatParameter blend = new FloatParameter { value = 0.5f };
    6. }
    7.  
    8. public sealed class GrayscaleRenderer : PostProcessEffectRenderer<Grayscale>
    9. {
    10.     public override void Render(PostProcessRenderContext context)
    11.     {
    12.         var sheet = context.propertySheets.Get(Shader.Find("Hidden/Custom/Grayscale"));
    13.         sheet.properties.SetFloat("_Blend", settings.blend);
    14.         context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
    15.     }
    16. }
    But now I can't find a way to use that post process with the new Volume : https://docs.unity3d.com/Packages/c...-definition@4.8/manual/Volume-Components.html

    I've try to create my own VolumeComponent doing something like this :
    Code (CSharp):
    1. namespace UnityEngine.Rendering.Universal
    2. {
    3.     [Serializable, VolumeComponentMenu("Custom/Grayscale")]
    4.     public sealed class Grayscale : VolumeComponent, IPostProcessComponent
    5.     {
    6.         [Range(0f, 1f), Tooltip("Grayscale effect intensity.")]
    7.         public FloatParameter blend;
    8.  
    9.         public bool IsActive() => blend.value > 0f;
    10.  
    11.         public bool IsTileCompatible() => true;
    12.     }
    13. }
    But that does not seems to work, and now I'm out of ideas of how to use a custom post process in Unity 2019.3.0f6 with LWRP
    Thx, for your answers.
     
  2. Wuceng

    Wuceng

    Joined:
    Dec 18, 2018
    Posts:
    9
    I just looked into this today.
    https://github.com/Unity-Technologies/UniversalRenderingExamples
    On this repository you can find an example on how to create custom postprocessing for URP.
    The toon outline sample should have you covered.

    The main steps are:
    copy the cs files of the example repository into your project
    Add a custom blit renderpass to your renderer asset
    Write a postprocessing shader (I took the SobelFilter shader of the examples above as a reference to create my own post effect)
    Assign a material to the blit pass with the shader that does your post processing

    Important notes:
    I ran into issues with postprocessing on Oculus Quest. This could be a VR specific issue but could also affect other mobile devices. My post effect works fine in the editor though when using the approach described above/ in the examples.
    I have not yet figured out how you can hook your posteffects into Unitys Volume script so with the approach above your posteffect is kind of separated from the built in volume based effects.
     
  3. Vitalis08

    Vitalis08

    Joined:
    Mar 4, 2014
    Posts:
    2
    Hi Thx for your response.
    I've tried to follow the example but I find myself once again in a dead end...
    I'm using a 2D renderer Pipepline to use 2D lights and I don't have the option to add Renderer Features in it.
    There is a screenshot comparing Forward and 2D :

    2D data.jpg

    I'm really lost now, is it not possible to use any custom post process with LWRP and a 2D Pipeline?
     
  4. AlterHaudegen

    AlterHaudegen

    Joined:
    Jul 8, 2013
    Posts:
    28
    Not possible at the moment, somebody said in another thread that "work on this has begun" (tm).

    Edit: Oops, totally necroed the thread, thought the last post was from feb 2021 (aka... the future).