Render parts of object(s) only when they are within a defined area I'd like to animate a train car entering and exiting a diorama from left to right. As the train car exits the station, &quot;breaking the plane&quot; that is the boundary of the station, the parts of the train car outside the station should be transparent.
Here's what the train car would look like passing through if there were no masking or holdouts or anything:

What I'd like is for it to be &quot;chopped off&quot; outside the diorama bounding box, resulting in something like this:

...but I don't want to accomplish this with booleans. It's way too expensive and intense, as the train will have many objects and shaders involved with it.
I can achieve the desired effect behind the station with compositing and render layers using holdouts. But the foreground part of the train as it exits, I'm lost on how to achieve that.
Thanks!
With Holdout:

Create a layer with the train and with a holdout object both visible (make sure that the holdout object is alpha blend and no shadow):



Create a second layer with neither of these 2 objects visible:



Render and mix in the Compositor through a Color &gt; Alpha Over:


Or create a black and white image that will allow you to mask the left part:


Create 2 layers, one with the train, one without, use the black and white image as a mask in the Compositor: