Can I use RenderWithShader(..) to render the scene normally but change the depth buffer output?

Hey guys, I want to render my scene like normal, but I want to change the depth buffer that gets outputted (for the sake of the example, lets say I want to invert the depth buffer that gets writen).

I wrote a shader which outputs 1 - COMPUTE_DEPTH_01 as the depth, which inverts it correctly, but the scene renders as a flat color. I want to render the scene and have the objects in the scene use their normal materials.

Right now I have to use 2 render texture, both the same size as the screen… I render normally into one RT, and render again into the second one using RenderWithShader (using a shader that inverts my RT). I get my RGB values from the first RT, and A (Depth) value from the second.

This is terribly inefficient. Can I just combine the 2 operations using the one RT and one render call?

I feel like you could probably Blit the texture with a material that inverts the depth much quicker than a full scene render. Have you considered options like that?

Alternatively, as far as I know, the depth write comes from the ShadowCaster passes. But to actually change that up, you would need to rewrite and use custom shaders for all objects.