Hide mesh outside of bounding area?

There’s a feature in Zbrush and Blender (and probably a lot more apps, but I know for sure it’s in those) that lets you hide the visibility of a mesh within a rectangle you draw on-screen. The visibility of the mesh is simply clipped.

I know Unity has some ability to do this, because it’s what happens between the near and far clip planes of a camera. However, I need to be able to control the same effect, in bounding areas that I define. (I don’t need to worry about users drawing stuff. I’m sure that bouding boxes will be sufficient, but it would be nice to define an arbitrary mesh, within which, polygons fully appear.) How might I go about this?

Cg is not an option, because I need this to work on the iPhone.

maybe you could just flip or reorient the normals of the selected geometry…?

That would work if I were able to do it only to the parts of the mesh that are outside the viewable area.

It’s not Unity that does this. It’s the clipping ability of OpenGL/OpenGL ES/D3D you see. While at least OpenGL has the ability to create custom clipping planes (i.e. user specified planes that are not frustum planes), I don’t believe this feature is exposed in Unity.

However, in your case, I don’t think you need clipping planes, as hiding all geometry inside (or outside?) a rectangle will not reveal any insides of the mesh. You could use a second camera with a viewport set to the coordinates of your rectangle to render the geometry (assuming you want to hide the object outside rectangle). The only tricky part is calculating the correct projection matrix for this second camera.

I’m confused by what you mean by this. I am not actually using any sort of rectangle, as I said. I want to set up volumes, outside of which, the graphics get clipped. Exactly like what the cameras do. Blender and Zbrush just let you drag out rectangles on-screen, and anything outside of them is hidden. It’s like constructing a box, with infinite Z dimension. I don’t actually need to do that, but it is a good reference for what I’m talking about.

In that case you will have to implement the whole thing yourself.

The rectangle case is much simpler, as it does not reveal the insides of objects. Arbitrary viewing volumes require custom clipping planes, which, as far as I can tell, are not exposed within Unity (in fact, OpenGL ES might not even support them).