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

Resolved How to run my CS function at a specific pass ?

Discussion in 'High Definition Render Pipeline' started by Sheynes, Dec 5, 2020.

  1. Sheynes

    Sheynes

    Joined:
    Mar 27, 2017
    Posts:
    66
    Hello,
    I've digged around the web and I havn't found a clear example of what I'm trying to achieve.

    Say this picture with all the passes from HDRP that can be found in the doc here https://docs.unity3d.com/Packages/c...s.high-definition@7.1/manual/Custom-Pass.html

    Say my CS script function

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class MainCamera : MonoBehaviour {
    4.  
    5.     void OnPreCull () {
    6.         Debug.Log("This function was called on the specific pass");
    7.     }
    8. }
    OnPreCull doesn't work anymore as said here https://forum.unity.com/threads/fee...e-render-pipelines.470095/page-8#post-3408481

    How can I let's say inject my code on "BeforeRendering" like :

    Code (CSharp):
    1. using UnityEngine;
    2.  
    3. public class MainCamera : MonoBehaviour {
    4.  
    5.     void BeforeRendering() {
    6.         Debug.Log("This function was called on the specific pass");
    7.     }
    8. }
    Is there a way to run my CS function at a certain point of the HDRP passes ?
    I tryed to use the custom pass script, but it seem to require a material, and it was pretty obscure, I just want my CS function to run at a certain point.

    Thank you for any answers !
     
  2. Sheynes

    Sheynes

    Joined:
    Mar 27, 2017
    Posts:
    66
    I do tried to make a custom pass :

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Rendering;
    3. using UnityEngine.Rendering.HighDefinition;
    4.  
    5. public class CustomPassPortal : CustomPass
    6. {
    7.     public MainCamera mc;
    8.  
    9.     protected override void Setup(ScriptableRenderContext renderContext, CommandBuffer cmd) { }
    10.  
    11.     protected override void Execute(ScriptableRenderContext renderContext, CommandBuffer cmd, HDCamera camera, CullingResults cullingResult) {
    12.         mc.debugBeforeRendering();
    13.     }
    14.  
    15.     protected override void Cleanup() { }
    16. }


    The idea was to trigger my camera debugBeforeRendering function.
    But the script inside the Execute function of the CustomPassPortal class is never called.
    And I do not know why...
     
  3. Sheynes

    Sheynes

    Joined:
    Mar 27, 2017
    Posts:
    66
    Restarting the scene seemed to do the trick.