Rendering an Object only inside of a certain area

I’m working on a VR game where you are looking down on at a level with your units (think RTS view in VR basically), and I’m trying to get it so that only objects in a given area are rendered, and objects on the edge are partially rendered, very similar to what you see in this video of Airmech Command.

However, despite my best efforts I’ve yet to find a great way to do this. I’ve tried stencils, but have only managed to create something like a window, where things to the left or right of the area aren’t shown at all, but even if an object is in front or behind the area they are still rendered. I’ve tried depthmasking, but had similar problems. The best I’ve managed is a setup where I use a depth mask to remove an area from being rendered at all on one camera, and filled the area with the rendering of another camera, but this resulted in just a flat image basically, so if you had objects with height, they would be cut off at a certain height.

Basically, everything I’ve found seems to just cull pixels on a 2d level, just based on screen position, as opposed to world space, and I need something that stops rendering based on 3D space. Any help given would be greatly appreciated

you definetly need a stencil buffer. One object is the mask it has the shape of everything you want to cut and is placed directly in front of the camera. The rest of the objects are normal where the schould be.

the mask object need a shader, put this in the subshader part of the shader you create (assets->create->shader->Standard Surface Shader):

	Tags { "RenderType"="Opaque" "Queue"="Geometry-1" }
	ColorMask 0
	ZWrite off

	Stencil{
		Ref 1
		Comp always
		Pass replace
	}

and this in the shader that will be put on every object that should be hidden:

	Tags{ "RenderType" = "Opaque" "Queue" = "Geometry" }
         LOD 200
	Stencil{
		Ref 1
		Comp notequal
		Pass keep
	}

I hope this helps

Where you able to find a solution?
@ronike