How to use mesh as a mask? I'm trying to do an animation where a desertic road scrolls like a treadmill.
I have a long road designed like this :

as the road scrolls (moves) from right to left, I'd like to show only the center square of this long road.
What I mean really is to show only what's inside this cube (without actually seeing the cube obviously) :

I tried to use the mask modifier but I can't really get to what I want. I was thinking that instead of displaying only what's happening in the cube, it might be easier to mask everything that is inside these ones :

Either way I can't really figure out how to use the mask modifier in that case, to use these cubes as masks without seeing them in the render...
I hope I'm clear enough, sorry if it's not.
I'd appreciate your help, and wish you a great week-end.
Cheers
With a boolean modifier
You had it right with either of these solutions. I would use the first one. But as you noticed, the cube mask hides the part you want to show. Select the cube and go into object properties and set the viewport display to &quot;Wire&quot;. also don't forget to uncheck &quot;Render&quot; in the visibility so it doesn't appear in your animation.

Then Select the road object, add a boolean modifier set to &quot;intersect&quot; and pick the cube mask.
Now you can either move the mask or the road to get the desired effect.

With a custom shader
You can limit the visibility of the road with a custom shader. You then don't have to use a mask object, and you won't have boolean artifacts, but the drawback is the mesh doesn't get &quot;cut&quot; on the edges of where it needs to stop displaying.
Select the road, go into the shading editor and add a new shader. Let's say you want the
road to display between y = - 1 and y = 1.
Add this setup to visualize the alpha of the material (1 is white, meaning the material is opaque. 0 is black, meaning the material is transparent):

Plug it into the alpha input of a principled bsdf shader and connect the bsdf to the material output. In the right hand side panel, go to options and set the blend mode to &quot;Alpha Clip&quot;.

Result :