Best way to paint a Camera's Line of sight

Hello everyone.

In my unity scene I have a Camera and I would like to paint everything to green dynamically which is seen by that camera and red which is not seen by the camera. I have near plane’s and far plane’s corner points. And for now I’m casting rays from near plane to far plane one by one and it takes too much performance to cast rays and I’m putting decals at hit positions of rays so it lowers the FPS dramatically.

So is there any performance-friendly method to create such effect inside Unity ?

What I’d like to achieve is shown perfectly in this picture:

I’m afraid I don’t have a solution prepared for this myself, but I stumbled across a pretty reasonable-looking example of a Volumetric Occlusion Mask here. Combine this with an impromptu mesh made based on the intended camera and you’ll have your “occlusion” field to recolor within a post-processing shader.

Vector3 fbl; // front-bottom-left
Vector3 fbr; // front-bottom-right
Vector3 ftl; // front-top-left
Vector3 ftr; // front-top-right
Vector3 bbl; // back-bottom-left
Vector3 bbr; // back-bottom-right
Vector3 btl; // back-top-left
Vector3 btr; // back-top-right

void Start()
{
	// A few examples, based on camera at (0, 0, 0), no rotation
	// (use the camera's Transform.InverseTransformPoint()
	//    if it has any applied transformation)
	fbl = targetCam.ViewportToWorldPoint(new Vector3(0f, 0f, targetCam.nearClipPlane));
	btr = targetCam.ViewportToWorldPoint(new Vector3(1f, 1f, targetCam.farClipPlane));

	// ...
	// Once you have all 8 vertices, create a mesh from them, attach a MeshFilter and MeshRenderer to the GameObject as a child of the camera so it moves with the camera
}

Anyone got any ideas to how to create such imagery in Unity ?