Render wireframe on cut section of polygons

Hi, after researching for a few days and trying everything free I came across I’m giving in and asking here.
I’m looking for a way to render wireframe so that it’ll complete the lines where geometry is cut off, either because of a cross section or from the near plane on a camera. I’ve found that the Source Engine does this which you can see in this picture and the video. Unlike source however I’d like it to be double sided, and though unlikely, if only the clipping edge could be isolated that’d be even better.

The reason I want this behavior is that I’ve been looking for any way to scan a models shape in layers from the top-down using an orthographic camera and reconstruct it using layers of textures. I’ve tried many ways, had a pretty good one but it relied on the model being well made, my system has to account for any model from the user. I’ve also tried using highlight shaders, which worked well for the most part, but if a polygon is perfectly vertical (like on a building wall) there will be no highlight since it’ll be too thin.


I’ve come to think this wireframe method is going to be the cheapest way to obtain an outline of a models shape at any point, by sending an orthographic camera through the model with the near and far plane extremely close to eachother. I’ll take any solution that isn’t too heavy tho, needs to be able to make a scan relatively quick for models with millions of polygons.
Thanks for reading, hope there’s a way to do something like this.

Video demonstration

I quickly created a script that will create a wireframe mesh (which consists of lines) based on a given object. In addition it will clip the edges against a plane.

The actual MonoBehaviour in this script is ment for demonstration. Modify it as you need it or just use the “WireframeClipMesh” to create / update the wireframe mesh on the fly. Unfortunately Unity still has no SetIndices variant that takes a generic List. So if the number of edges that has to be drawn changes we have to create a new index array. Though even when moving through an object that shouldn’t happen too often.

When you attach this script to an object it will initialize the “WireframeClipMesh” with the mesh of the object it’s attached to. It will create a child object “wireframe” which will actually draw the clipped wireframe mesh. The clipping plane is defined by a single Transform reference. The positive z-axis (forward) of that transform is the plane’s normal vector. Note things in front of the plane get cut away. So it’s not an “allow” plane (like the viewing frustum where the normals point inwards) but a cutting plane.

It’s probably easier to look at this animated gif

@Bunny83 , Hi, thanks for your sharing! I applied the script, but it seems there is no cut happens. May I ask why? I think that if I don’t close the mesh renderer, it should show part of the object when moving the clipping plane