Last weekend I devised and built a little test for a system that would be able to mostly solve character mesh clipping issues for my modular character system. What this system is essentially going to be used for are similar but not compatible clothing meshes that have clipping issues, if you have two different artists making character art and they are not in communication with a uniform workflow for clothing shapes / definitions there will naturally be problems with those meshes being used in tandem. (for example if you use asset packs for clothing and dont have an artist, OR your artists' clothing designs are different enough from each other it would be highly difficult for them to make all articles of clothing compatible)
This is most definitely more of a stop-gap and not a one size fits all solution, as you can see with some of the video examples there are edge cases and complications trying to shove extremely different meshes together BUT it atleast for me will save a wild amount of time pushing/pulling verts endlessly on tons of character models to make them all perfectly uniform.
What this system does at a functional level is basically the following;
1. Copy all meshes that will be used for tracing into their own dynamic mesh
2. Give each mesh a priority value for the overlap trace
3. iterate through lowest to highest priority mesh, then iterate through each of its vertices
4. trace inwards (either use bone weight avg location or vertex normal or combination) and look for higher priority mesh hits
5. using the highest priority hit location, get a location just below that for the vertex offset
6. convert the offset position into linear color (0.5 vertex color is the *origin*) for example -6/6 units could be mapped to 0-1 linear color input
7. (I used a plugin) apply the vertex color to each vertex for use in material world position offset
8. In material get vertex color and unpack that from 0-1 back into -6/6 and offset the vertex using its pre skinned position
9. use that same offset intensity (get vector length) to push the verts backwards from camera / cull entirely if necessary to prevent any final clipping issues (especially during animation)
Note that this is a heavy operation so it cannot be done in 1 frame or else there will be a hitch at minimum of atleast 300-500ms or greater based on mesh complexity / number of meshes (we are doing many thousands of iteration loops) Either A. get this operation off the game thread (should possibly be safe) or B. iterate through a chunk of the work per frame, maybe 50-100 iterations per frame would be acceptable, after 1-5 seconds the operation should be completed without a frame hitch.
Another caveat is cloth simulation, if you have a skirt that simulates cloth and WILL move "backwards" and clip into other underlying meshes, that has yet to be accounted for. One potential solution is if the dynamic mesh contains cloth sim data that could be checked for and used in the offsetting process to protect from cloth sim overlaps, I've yet to test that since I've been strapped for time with work and this already works quite well.
The plugin I used which is critical to this functioning
https://www.unrealengine.com/marketpl...
The original inspiration for this system (Kingdom Come Deliverance's mesh deformer that I decided to try my hand at achieving a similar end result)
https://www.gdcvault.com/play/1022822...