Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice
  4. Dismiss Notice

Bug Custom pass volume does not work in build

Discussion in 'High Definition Render Pipeline' started by lowbl_dan, Jun 28, 2023.

  1. lowbl_dan

    lowbl_dan

    Joined:
    Jan 22, 2019
    Posts:
    34
    Has anyone managed to get custom pass volume working in HDRP builds?


    Note: I have included the shaders in build settings "Always include shader",
    Tried both global and camera mode on the custom pass volume component to no avail.
    Tried with several different types of shaders.

    Tested on 2021.3.18f (LTS)
     

    Attached Files:

  2. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    639
    Do you maybe have different render pipeline assets assigned to the different quality levels, and the one that is used in the build has custom passes disabled?
    The quality level used in the editor (highlighted one in the quality settings) can be different from the default in build (with the green checkmark)
    upload_2023-6-28_8-36-0.png
     

    Attached Files:

  3. lowbl_dan

    lowbl_dan

    Joined:
    Jan 22, 2019
    Posts:
    34
    Hi,

    I have configured custom settings that point to a different renderpipeline asset each and enabled custom pass for each of the assets, as shown in the screenshot.

    To be sure, I have also removed all other settings and still got the same result in the build.

    Do kindly advise if I have missed anything.

    upload_2023-6-28_15-9-57.png
     
  4. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    639
    Would you be able to share the project here so I can look at it ?
     
  5. lowbl_dan

    lowbl_dan

    Joined:
    Jan 22, 2019
    Posts:
    34
    Hi Remy,

    Apologies for the late reply,

    I have attached the project below. The example scene with the shaders is called ShaderTestScene.unity.
     

    Attached Files:

  6. Remy_Unity

    Remy_Unity

    Unity Technologies

    Joined:
    Oct 3, 2017
    Posts:
    639
    So, after a first surprise looking in the project and some help, we've found the issue and workarounds :
    You need to change the "Lit Shader Mode" setting in your render pipeline assets to "Both" or "Forward Only". (see doc here)

    Explanation:
    In the code you are calling
    CustomPassUtils.DrawRenderers(ctx, outlineLayer);
    .
    This will try to draw the matching renderers with their "Forward" pass, but this pass is stripped for opaque objects in deferred rendering in a build.
    So you either have to force it to be there with the "Lit Shader Mode" setting, or change the code to use an other pass. Either you could use the Depth-Prepass and also base the edge detection on depth, or use an unlit shader as material override.

    As the code you've used comes from ou doc, I pushed to add some notes there to avoid future issues like this.
     
    lowbl_dan likes this.