Mesh cut-off effect on Node3D subtree

For a museum exhibit, I’d like to create an interactive cut-off effect like this to show the inside of a model. The model comes from a CT scan of an object that has moving elements inside (it’s a rattle, basically). In the first instance I’d like to replicate the effect below on the static mesh (no moving elements, as in, the objects are there but part of one big mesh) and subsequently I’d like for the objects inside to be able to move and be sliced too.

In this example I made in Blender, I just created a box surrounding the meshes and set it to intersect with a boolean modifier.

I thought I could use a CSGBox3D as the intersecting object but obviously those are meant to work together but not with MeshInstance3D (not that I could see anyway). I also found a shader-based alternative that I could use but I don’t like it very much (I need to be able to hand this project off to someone with limited graphics experience and I can easily teach them to push a few buttons, but not to work with shaders…).

I’m open to suggestions.

Make the shader work with a script and show them how to use the script.

You could pre-shatter the object into a cloud of submodels and control visibility on thise individually, though it wouldn’t be as clean as your blender video above.

I would think the shader approach wouldn’t be too bad, though; presumably it would just take a uniform value that was either a float (if you just wanted to do this in one dimension) or a plane (if you wanted to do this in arbitrary directions), and the shader would just discard any vertices on the wrong side of the plane (or the axis-aligned plane constructed from the float).

All that would need to happen in script would be feeding a value into the uniform so the shader had something to chew on.

I can do this with a fragment shader (setting the alpha to 0.0) and then I’d need to find a way to close the gap to simulate the straight face resulting from the cut. I’m not sure how to do it with a vertex shader, I thought discarding vertices wasn’t a thing.

Could be; I haven’t actually tried this.

As for filling the gaps, rather than trying to generate geometry my suggestion would be turn off backface culling, and make all the backfaces flat-shaded in some neutral color with no lighting. You’d be looking at the interior of the geometry, but if it was all a uniform color and intensity it would just look like solid fill.

You can use a custom mesh with a CSGMesh3D, however it doesn’t provide the most clean results (also the mesh has to follow certain criteria), but it is relatively quick to set up.

Also not sure about how it behaves at runtime.

1 Like