How to create thick layer Mesh on top of complex Mesh


I currently have a complex imported mesh. (.stl)
I need to create a sort of thick plastic layer on top of the mesh.
This plastic layer should have a certain fixed thickness.
The plastic layer mesh should fit perfectly on the original mesh.

So for a simple shape like a box, the end result would be:

  • an empty box
  • that is just a bit bigger than the original box
  • and the original box fits perfectly inside this new box

Obviously for complex shapes, this will be more challenging.

I tried doing it with CSG and scaling. But this is not really correct.
A scaled up mesh doesn’t guarantee a fixed thickness in every direction.
But achieving something is better than nothing.

  • clone the original mesh
  • scale up the cloned mesh
  • create a CSG for cloned mesh and original mesh
  • subtract the original CSG from the cloned CSG
  • create a mesh from the result

The problem with this method is, it is way to computationally heavy.
When I do the substract call, the process just freezes.
I quit it after 5 minutes of being busy so don’t know the exact time it takes.
Subtracting 2 duplicated stock stl meshes in the playground took about 130 seconds on my pc.

This is more of a high level question. So I don’t have a playground.
But if you need one, the default .stl playground is pretty complex:

Another possible method would be to take al the vertices of the mesh and scale/position them in the direction of their normal. But this will probably also be very computationally heavy.

Any ideas?
Thank you very much.

Hi Stijn,

Pretty interesting use case! The easiest thing I can think to try would be to do exactly the mesh morphing you describe – translating each vertex by a defined amount along its normal – in the vertex shader. You might get some minor problems like self-intersection for concave meshes, but I think it should work reasonably well for most scenarios. What you’d end up with at the end of this would be two copies of the same object in the scene, one with its ordinary materials on it and another with this custom material that “inflates” the mesh slightly in the vertex shader before rendering it as plastic in the pixel shader. This will at least double your GPU-side rendering work, but that was probably going to happen anyway, and the CPU-side work shouldn’t be increased too dramatically. Will this approach work for your use case?

I currently did not do it in the vertex shader.
Just did it manually. But it covered my use case.