I’m working on a special purpose application which is supposed to render animations as image sequences. For each frame, we want to render a regular-color image and a depth-only image.
Using the built-in render pipeline, we could handle this easily with a two-camera setup. The two cameras were parented together, and we used a replacement shader to make the second camera render depth. Each Unity frame, we rendered each camera to an image file.
HDRP does not have the same replacement shader feature as the built-in render pipeline, so we have to use Custom Passes instead. We’ve set up a global custom pass volume with a full screen custom pass for rendering depth, but the custom pass volume is applied to all cameras so this also affects the default camera. Setting the custom pass volume to Local won’t do any good, because the cameras have exactly the same position, so it would still affect both cameras.
I’ve tried enabling the custom pass volume immediately before we render the second camera, and then immediately disabling it again, but with this approach the custom pass isn’t used and the second camera renders in normal color. I’m guessing that we’d have to wait a frame for the custom pass to take effect, which would interfere with the animation (we’re using motion blur on the regular pass).
We could render the full animation in regular color and then re-render it from the beginning with the custom pass active, but that’s going to take longer and total render time is an issue for this application.