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. Dismiss Notice

EnquePass not working in Start?

Discussion in 'Universal Render Pipeline' started by chrismarch, Apr 29, 2020.

  1. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    465
    I know I can probably make this work by implementing a ScriptableRendererFeature, but the APIs I use in this snippet suit my use case better, and yet my custom ScriptableRenderPass never has Execute invoked:
    Code (CSharp):
    1.  
    2. void Start() {
    3.     _currentCamera = gameObject.GetComponent<Camera>();
    4.     _customPass = new CustomPass();
    5.     UniversalAdditionalCameraData cameraData = _currentCamera.GetUniversalAdditionalCameraData();
    6.     cameraData.scriptableRenderer.EnqueuePass(_customPass);
    7. }
    (URP 7.3.1, Unity 2019.3.9f1)
     
    INeatFreak likes this.
  2. xgonzal2

    xgonzal2

    Joined:
    Jul 3, 2012
    Posts:
    62
    The scriptable render pass array gets cleared every frame in UniversalRenderPipeline.RenderSingleCamera so what you're doing isn't going to work. I don't know that there is a way around it without making a scriptable render feature.
     
  3. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    465
    Ah, OK, thanks.
    I had no idea the pass queue was cleared every frame, must have missed that in the docs.
     
  4. chrismarch

    chrismarch

    Joined:
    Jul 24, 2013
    Posts:
    465
    Hmm, EnqueuePass (for after transparent) doesn't work from
    RenderPipelineManager.beginCameraRendering, so I guess I have to make a ScriptableRenderFeature
     
  5. INeatFreak

    INeatFreak

    Joined:
    Sep 12, 2018
    Posts:
    46
    Having the same problem here. I need to add passes dynamically from script but this breaks my coding architecture.