Search Unity

Custom Post Effects not working on Mobile in LWRP

Discussion in 'Graphics Experimental Previews' started by battou, Sep 30, 2018.

  1. battou

    battou

    Joined:
    Jan 25, 2011
    Posts:
    142
    So I followed tutorial on github about creating custom post effects for stack. made simple test effect wich multiplies screen texture by 2. In editor it works fine, but on android it messes up everything, UI gets duplicated multiple times covering whole screen.

    What is wrong? LWRP do not support custom effects?

    Code:
    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using UnityEngine.Rendering.PostProcessing;
    4. using UnityEngine.Rendering;
    5.  
    6.  
    7. [Serializable]
    8. [PostProcess(typeof(MyGlowEffectRenderer), PostProcessEvent.AfterStack, "Custom/MyGlowEffect")]
    9. public sealed class MyGlowEffect : PostProcessEffectSettings
    10. {
    11.     [Range(0f, 5f), Tooltip("Glow effect intensity.")]
    12.     public FloatParameter gloawStrength = new FloatParameter { value = 1.0f };
    13. }
    14.  
    15. public sealed class MyGlowEffectRenderer : PostProcessEffectRenderer<MyGlowEffect>
    16. {
    17.     public override void Render(PostProcessRenderContext context)
    18.     {
    19.         var sheet = context.propertySheets.Get(Shader.Find("Hidden/Custom/MyGlowEffect"));
    20.        
    21.         context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
    22.     }
    23. }
    shader pass just samples maintex and outputs it multiplyed by 2.

    Here is what I get on my phone


    And here is what I see in editor:
     
  2. phil_lira

    phil_lira

    Unity Technologies

    Joined:
    Dec 17, 2014
    Posts:
    402
    Can you open a bug report and attach your scene? We will take a look at it.
     
  3. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,527
    Did thing get resolved, I'm getting a similar issue in 2019.2.9
     
  4. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    2,218
    I thought custom post processing effects do not work in URP anymore?
     
  5. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,527
    I managed to get it working in the end, it was all to do with the format for how the Image effect shader is written.

    Needs to follow this layout

    Code (CSharp):
    1. Shader "Unlit/SobelFilterBasic"
    2. {
    3.   Properties
    4.       {
    5.           .
    6.           .
    7.     }
    8.   HLSLINCLUDE
    9.  
    10.         #include "Packages/com.unity.postprocessing/PostProcessing/Shaders/StdLib.hlsl"
    11.      
    12.         .
    13.         .
    14.         .
    15.  
    16.     half4 Frag (VaryingsDefault i) : SV_Target
    17.     {
    18.         .
    19.         .
    20.  
    21.     }
    22.  
    23.     ENDHLSL
    24.  
    25.     SubShader
    26.     {
    27.         Cull Off ZWrite Off ZTest Always
    28.  
    29.         Pass
    30.         {
    31.             HLSLPROGRAM
    32.                 #pragma vertex VertDefault
    33.                 #pragma fragment Frag
    34.              
    35.             ENDHLSL
    36.         }
    37.     }
    38. }
    Without the HLSLINCLUDE it was failing
     
  6. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    2,218
    And then that is usable via the PostProcessEffectSettings & PostProcessEffectRenderer as shown above?

    And that works with the built in Post processing stack in URP? Or some other way?

    Is this for LWRP or URP that you did it on ? Very excited if this is for URP as I have been fighting to find a way to do custom post FX for a while now
     
  7. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,527
  8. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    2,218
  9. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,527
    Of course naturally they've completely changed it for the Universal Render Pipeline in 2019.3 so now trying to track down how that is meant to work...
     
    GameDevCouple_I likes this.
  10. GameDevCouple_I

    GameDevCouple_I

    Joined:
    Oct 5, 2013
    Posts:
    2,218
    Please let me know if you do work it out, been scratching my head on this one for about 2 weeks now :(
     
  11. Grimreaper358

    Grimreaper358

    Joined:
    Apr 8, 2013
    Posts:
    580
    URP doesn't support custom post-processing yet but it's being worked on. I saw a branch for it on GitHub a while back.
     
    GameDevCouple_I likes this.
  12. monark

    monark

    Joined:
    May 2, 2008
    Posts:
    1,527
    Yup I downloaded the Github files and tried out the samples, I'm going to stick with 2019.2 for now