Hide anything outside cube HoloLens

hello

I am building a simple hololens project in Unity and within my scene I have a simple semi transparent cube.

for the purpose of building for hololens, how can i tell unity to show any object as it moves inside of the cube, and then to disappear as it exist the cube.

if the object is animating half in and out of the cube, then it would just display the part that is within the cube

i tried surrounding the cube with black cubes, which kind of worked, but it seemed a messy way, and the cubes ended up being huge to ensure no part of an object was being shown

thanks for any advice

You need to work with a custom shader, Vertex shader will give you the transition effect. Pass in a position of the cube & size and then within the shader Fragment function, check to see if the worldposition is within you cube position plus size. If not, discard.

This took me an age to work out for a scrollable holographic map, so best of luck!