Enabling/Disabling custom scriptable render pass during runtime

Hey everyone,

is there a way to enable/disable a custom scriptable render pass during runtime (the one created in the editor via rightclick-> create → Rendering → Universal Render Pipeline → Renderer Feature)?

Greetings,
Desoxi

For those who are interested:

I figured out how to do it in some way, not sure if that’s the optimal way though.
You reference your custom pass into a monobehaviour inside your scene. There you can write a method or turn on/off a variable which controls if the AddRenderPasses method returns or not.

Also a problem I stumbled upon: When you are inside the editor the source rendertarget from renderer.cameraColorTarget alternates between “SceneCamera”, “Preview Scene Camera” and the Main Camera. If you want to eliminate the scene cams here is a way for it:

public override void AddRenderPasses(ScriptableRenderer renderer, ref RenderingData renderingData)
    {
        if (Application.isEditor && (renderingData.cameraData.camera.name == "SceneCamera" || renderingData.cameraData.camera.name == "Preview Scene Camera"))
        {
            return;
        }
        Debug.Log(renderingData.cameraData.camera.name);
        m_ScriptablePass.Setup(renderer.cameraColorTarget, RenderTargetHandle.CameraTarget);
        renderer.EnqueuePass(m_ScriptablePass);
    }

The isEditor check is not necessary, I was too lazy to remove it :smile:

3 Likes