Getting all objects in game view to fade to black depending on distance from player

Hi

I’m trying to think of how to achieve the following effect:

The player needs to keep up with an NPC. If the distance between the NPC and the player reaches a certain threshold the objects in the game view should all fade to black over time and the blackness increase as the distance between the player and the NPC increases. Additionally, I would like to make objects nearer the player fade to black slower or after objects that are far away.

This would happen to all visible objects not on in a UI layer, regardless of whether they use a standard or custom shader.

Is there a way to do this? I thought perhaps of having a spherical volume with the player at its center, have it shrink, and depending on the distance to its border adjust the color of objects (with everything on the edge or outside it black).

I guess that using depth info that everything behind the sphere’s “shell” would be rendered black with an outline but I’m unsure of how to handle the interior objects have their colors fade to black towards the shell. Perhaps a better, simpler idea would be to have some kind of light volume shrink with the sphere?

Any other ideas?
Thanks in advance

Could use a post process effect. Calculate the distance from the player vs the NPC, and use that as a to multiply(or otherwise mix) the depth texture over the scene. Maybe render a sphere around the player to mask the area to limit the effect.

As for the sphere, if you render the depth once with back face culling, then once with front face cull, and subtract the two depths you get a sort of thickness map.

For it to work for ANY shader without modifying them you are pretty much limited to post process effects.
Using the depth buffer to reconstruct the world position then comparing and “blackening” that pixel should work as mentioned.
Another option is IF all relevant shaders can have unity fog, you could modify that fog code and it’d happen to all objects.