Clip 3D Object to specific volume
I have a large animated 3D object that I want to be only visible in a small 3D space. Any part of the 3D object outside of this region should be invisible to the camera, no matter where you're standing. How would I clip to this region within Unity?
I've been struggling with this for a very long time, I would love any amount of help or suggestions! Thanks!
Answer by anilhdas · Jan 31, 2017 at 12:01 PM
If I read it right, you want to mask a part of a 3d object in the camera.
You can use Mask script to mask the part of the object from being visible from the camera. Something like this :
Mask Disabled:
Mask Enabled: .
.
You can read further on this link:
Hey! Thanks for the response. I think this is close to what I had in $$anonymous$$d, let me try to explain it a bit further. One caveat is that it would need to stay confined to a 3D area in space, so as you walk around it, it occupies only that area.
I'm basically making a moving topography much like the one seen in the pic I'm attaching, that I want to keep only viewable in the box it sits in. So as you walk around the topography and scroll it around, you can only see the portion that's inside the box.
Would placing a mask around the edges of this box do the trick? Thanks again for the response.
Ok, so if you want to mask a 3D object confining it to a 3D space (possibly within another object as you queried), you can use invicible shaders.
Add planes to 4 corners of your table, scaling it to comfortably to hide your 3D object below it. And add invicible shader to that planes.
The shader will refrain camera from rendering the plane and anything below it.
Hope this helps
Sweet! That makes total sense, but I tried it and it just isn't working in my project. I'm really, really close though.
To make the shaders and set the render queue, I followed exactly these steps and code snippets in a similar forum thread (http://answers.unity3d.com/questions/316064/can-i-obscure-an-object-using-an-invisible-object.html). I'm just trying to obscure any part of the topography at this point as a test.
I made an invisibility shader, applied it to a material, assigned that material to a plane/cube, and set the render queues to render the objects I want to obscure after the invisibility shader plane/cube.
In theory, this should make any part of the topography below the plane invisible, but all it does on my end is make the shader plane invisible without affecting the topography. Is there a step I'm missing in the process?