Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

LWRP Custom Effect - black screen when built

Discussion in 'Universal Render Pipeline' started by cipheredxyz, Jul 3, 2019.

  1. cipheredxyz

    cipheredxyz

    Joined:
    Jun 16, 2019
    Posts:
    8
    Hello,

    I am kinda new within the Unity community and with Unity in general.

    I am currently trying to implement a custom post processing effect, and I've been following this guide step by step to do so :
    https://github.com/Unity-Technologies/PostProcessing/wiki/Writing-Custom-Effects

    This grayscale custom effect is working great in editor mode. I can add it to my post processing volume and everything works fine. However, whenever I try to build my scene, I get a full grey screen, as if nothing was happening. When I remove the effect from the pile of my post processing volume, everything works as intended, even when building. However adding the effect to the volume causses the built game to not render.

    I've been trying stuff for hours now, but I come to an end.
    Am I doing something wrong ?
    What are the steps required for an effect to work also on the built game ?

    Is the guide I have been following outdated ? If so, where can I find a more recent one ?


    Thank you for your time, have a great day;
    Ciphered :)
     
  2. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Hi!
    What platform are you building to? Is there any error in the player log?
     
    cipheredxyz likes this.
  3. cipheredxyz

    cipheredxyz

    Joined:
    Jun 16, 2019
    Posts:
    8
    Hello,

    Thanks for your answer.

    There is indeed some logs within the player log, I had no idea such a thing existed, thanks for pointing it out. It seems there is a problem with the vertex shader :

    ______

    Mono path[0] = 'D:/work/unity/visualizers/Muvi2/Build3/Muvi2_Data/Managed'
    Mono config path = 'D:/work/unity/visualizers/Muvi2/Build3/MonoBleedingEdge/etc'
    Initialize engine version: 2019.3.0a5 (9aff892fb75b)
    [XR] Discovering subsystems at path D:/work/unity/visualizers/Muvi2/Build3/Muvi2_Data/UnitySubsystems
    GfxDevice: creating device client; threaded=1
    Direct3D:
    Version: Direct3D 11.0 [level 11.1]
    Renderer: NVIDIA GeForce GTX 1050 Ti (ID=0x1c8c)
    Vendor:
    VRAM: 4029 MB
    Driver: 23.21.13.8816
    Begin MonoManager ReloadAssembly
    - Completed reload, in 0.797 seconds
    <RI> Initializing input.

    <RI> Input initialized.

    <RI> Initialized touch support.

    WARNING: Shader Unsupported: 'Hidden/PostProcessing/FinalPass' - Pass '' has no vertex shader
    WARNING: Shader Unsupported: 'Hidden/PostProcessing/FinalPass' - Pass '' has no vertex shader
    WARNING: Shader Unsupported: 'Hidden/PostProcessing/Uber' - Pass '' has no vertex shader
    WARNING: Shader Unsupported: 'Hidden/PostProcessing/Uber' - Pass '' has no vertex shader
    UnloadTime: 2.439296 ms
    Setting up 4 worker threads for Enlighten.
    Thread -> id: 6084 -> priority: 1
    Thread -> id: 63c8 -> priority: 1
    Thread -> id: 3a68 -> priority: 1
    Thread -> id: 2088 -> priority: 1
    ArgumentException: Invalid shader ()
    at UnityEngine.Rendering.PostProcessing.PropertySheetFactory.Get (UnityEngine.Shader shader) [0x00014] in <5219f50adb754be5a6b446b97a34ec97>:0
    at PPtestRenderer.Render (UnityEngine.Rendering.PostProcessing.PostProcessRenderContext context) [0x00010] in <bdfd75cccc684750891480b85820a61b>:0
    at UnityEngine.Rendering.PostProcessing.PostProcessLayer.RenderList (System.Collections.Generic.List`1[T] list, UnityEngine.Rendering.PostProcessing.PostProcessRenderContext context, System.String marker) [0x0008f] in <5219f50adb754be5a6b446b97a34ec97>:0
    at UnityEngine.Rendering.PostProcessing.PostProcessLayer.RenderInjectionPoint (UnityEngine.Rendering.PostProcessing.PostProcessEvent evt, UnityEngine.Rendering.PostProcessing.PostProcessRenderContext context, System.String marker, System.Int32 releaseTargetAfterUse) [0x00046] in <5219f50adb754be5a6b446b97a34ec97>:0
    at UnityEngine.Rendering.PostProcessing.PostProcessLayer.Render (UnityEngine.Rendering.PostProcessing.PostProcessRenderContext context) [0x002f6] in <5219f50adb754be5a6b446b97a34ec97>:0
    at UnityEngine.Rendering.LWRP.RenderingUtils.RenderPostProcessing (UnityEngine.Rendering.CommandBuffer cmd, UnityEngine.Rendering.LWRP.CameraData& cameraData, UnityEngine.RenderTextureDescriptor sourceDescriptor, UnityEngine.Rendering.RenderTargetIdentifier source, UnityEngine.Rendering.RenderTargetIdentifier destination, System.Boolean opaqueOnly, System.Boolean flip) [0x00110] in <090d1e4ec97149dc83d818274fe8ae8e>:0
    at UnityEngine.Rendering.LWRP.ScriptableRenderPass.RenderPostProcessing (UnityEngine.Rendering.CommandBuffer cmd, UnityEngine.Rendering.LWRP.CameraData& cameraData, UnityEngine.RenderTextureDescriptor sourceDescriptor, UnityEngine.Rendering.RenderTargetIdentifier source, UnityEngine.Rendering.RenderTargetIdentifier destination, System.Boolean opaqueOnly, System.Boolean flip) [0x0000d] in <090d1e4ec97149dc83d818274fe8ae8e>:0
    at UnityEngine.Rendering.LWRP.PostProcessPass.Execute (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.LWRP.RenderingData& renderingData) [0x0005d] in <090d1e4ec97149dc83d818274fe8ae8e>:0
    at UnityEngine.Rendering.LWRP.ScriptableRenderer.ExecuteRenderPass (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.LWRP.ScriptableRenderPass renderPass, UnityEngine.Rendering.LWRP.RenderingData& renderingData) [0x00109] in <090d1e4ec97149dc83d818274fe8ae8e>:0
    at UnityEngine.Rendering.LWRP.ScriptableRenderer.ExecuteBlock (UnityEngine.Rendering.LWRP.RenderPassEvent startEvent, UnityEngine.Rendering.LWRP.RenderPassEvent endEvent, UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.LWRP.RenderingData& renderingData, System.Boolean submit) [0x0003e] in <090d1e4ec97149dc83d818274fe8ae8e>:0
    at UnityEngine.Rendering.LWRP.ScriptableRenderer.Execute (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Rendering.LWRP.RenderingData& renderingData) [0x00055] in <090d1e4ec97149dc83d818274fe8ae8e>:0
    at UnityEngine.Rendering.LWRP.LightweightRenderPipeline.RenderSingleCamera (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera camera) [0x000da] in <090d1e4ec97149dc83d818274fe8ae8e>:0
    at UnityEngine.Rendering.LWRP.LightweightRenderPipeline.Render (UnityEngine.Rendering.ScriptableRenderContext renderContext, UnityEngine.Camera[] cameras) [0x00046] in <090d1e4ec97149dc83d818274fe8ae8e>:0
    at UnityEngine.Rendering.RenderPipeline.InternalRender (UnityEngine.Rendering.ScriptableRenderContext context, UnityEngine.Camera[] cameras) [0x0001d] in <08d7d13a3eda4b5f9489a2ef715f815e>:0
    at UnityEngine.Rendering.RenderPipelineManager.DoRenderLoop_Internal (UnityEngine.Rendering.RenderPipelineAsset pipe, UnityEngine.Camera[] cameras, System.IntPtr loopPtr) [0x00023] in <08d7d13a3eda4b5f9489a2ef715f815e>:0

    (Filename: <5219f50adb754be5a6b446b97a34ec97> Line: 0)

    ____


    However, how such a thing could happen ? I have followed the guideline and wrote a very basic custom shader, but it seems a step is missing for it to be compliant with the final compilation.

    I don't want to waste too much of your time, but I have no idea on how to proceed to get this working.

    Do you have any clues ?

    Thanks,
    Ciphered
     
  4. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    This looks like your actual problem :)
    I suppose PPtestRenderer is your custom post effect. You have some kind of error inside the `Render` function.
     
    cipheredxyz likes this.
  5. cipheredxyz

    cipheredxyz

    Joined:
    Jun 16, 2019
    Posts:
    8
    Maybe there is... however my render function is exactly the same as the one given within the guide :

    Code (CSharp):
    1.  
    2. using System;
    3. using UnityEngine;
    4. using UnityEngine.Rendering.PostProcessing;
    5.  
    6. [Serializable]
    7. [PostProcess(typeof(PPtestRenderer), PostProcessEvent.AfterStack, "Custom/PPtest")]
    8. public sealed class PPtest : PostProcessEffectSettings {
    9.     [Range(0f, 1f), Tooltip("Grayscale effect intensity.")]
    10.     public FloatParameter blend = new FloatParameter { value = 0.5f };
    11. }
    12.  
    13. public sealed class PPtestRenderer : PostProcessEffectRenderer<PPtest> {
    14.     public override void Render(PostProcessRenderContext context) {
    15.         var sheet = context.propertySheets.Get(Shader.Find("Hidden/Custom/PPtest"));
    16.         sheet.properties.SetFloat("_Blend", settings.blend);
    17.         context.command.BlitFullscreenTriangle(context.source, context.destination, sheet, 0);
    18.     }
    19. }
    20.  
    Ans since the "hello world" of post processing custom effects is not working but only in build mode, I guess either an extra step not mentioned in the guide is required either there is a bug.

    I have found another solution, by rendering my scene to a TargetTexture and applying my effect to the texture, however I'd like to figure out what could cause the issue. I'll try to build a small project to see if the problem persists :)

    Thanks for your time,
     
  6. aleksandrk

    aleksandrk

    Unity Technologies

    Joined:
    Jul 3, 2017
    Posts:
    2,983
    Code (CSharp):
    1. Shader.Find("Hidden/Custom/PPtest")
    It looks like it doesn't find this shader...
     
    cipheredxyz likes this.
  7. Reangege

    Reangege

    Joined:
    Apr 27, 2019
    Posts:
    1
    it doesn't find this shader.

    You have to add this shader in player setting -> grahpics.
     

    Attached Files:

    OLGV and cipheredxyz like this.
  8. cipheredxyz

    cipheredxyz

    Joined:
    Jun 16, 2019
    Posts:
    8
    This was the solution to my problem. Thanks for your answer.