How do I disable post-processing at runtime?

On the advice of another thread, I used the name space UnityEngine.Rendering.Universal and called the following on my scene’s main camera:

var cameraData = mainCamera.gameObject.GetComponent<UniversalAdditionalCameraData>();
cameraData.renderPostProcessing = false;

This successfully unchecks the Post-processing box for the camera in the inspector–however, this appears to be a purely cosmetic effect, as it does absolutely nothing as far as actually disabling post-processing effects in the scene. Surely there is some way to accomplish this?

  1. I managed to do this by creating a second Universal Renderer Data asset (duplicated UniversalRenderPipelineAsset_Renderer) and disabled post processing on that asset.

  2. I then added that asset into the renderer list on the Universal Render Pipeline asset (UniversalRenderPipelineAsset).

  3. I then used the following code to enable/disable post processing by setting the renderer index that the camera should use, as needed:

camera.GetUniversalAdditionalCameraData().SetRenderer(1); // Disable
camera.GetUniversalAdditionalCameraData().SetRenderer(0); // Enable