Hello. New to the forum but hoping to get some insight into how I may be able to resolve an issue I am seeing with the decal system that I am currently working on.
I have a decal volume in the shape of a box. The center of the volume is placed at the collision point and rotated so it is facing along the normal. Any overlapping meshes are then clipped to the volume and the clipped vertices are triangulated and given a normal.
The problem is that when I assign the UVs to the vertices they project onto separate axes relative to the centre of the box and do not take into account the collision normal and current size of the projected image.
Here is a link to a short video demonstrating the problem - https://www.dropbox.com/scl/fi/f5ysstjcz3i38gf7823ow/UVDecalProblem.mov?rlkey=meo3f43wnl5h0bw7vpcznoug7&st=adhwx4p7&dl=0
I've embedded a still image to provide some idea also.

In the image above the collision normal is on the left, the red wireframe is the decal volume, and the duplicated projection onto the 90-degree face relative to the box centre is on the right.
I would like the uv coordinates on the right face to take into account that most of the image has been projected onto collision surface normal and wrap around the uv coordinates accordingly (created one seamless image) rather than project and duplicate the image onto the adjacent surface using the box center.
I would also like this to be robust enough to handle other cases such as concave surfaces so computing a weighted-average normal and projecting onto that plane will not be enough to resolve this.
Does anyone have any ideas on how this can be resolved? Happy to share code if anyone would find it useful?


