Clipping texture to UV island

Hey, I’ve got a question on how to clip textures in a UV island. What I’m trying to achieve, is being able to throw a blob of paint at a mesh, and have it embed in the texture. I’ve got it working relatively nicely by casting a ray at the collider, and using a renderTexture, painting a blob at the UV location my ray hit. My problem is that when the blob hits close to a seam in the UV map, paint will show up on two different parts of the model. I’ve minimised this a bit by using the generated lightmap UVs which have no shared vertices, but it still happens when there are two different parts of the model appearing close together in the UV set.

Now this does not need to be perfectly exact (although if anyone has a suggestion I’m all ears). I just want it to look half decent so I thought that the way I’d get away with it is to just clip each paint blob to the UV island that was hit from my raycast. I’m kind of at a loss for how I might be able to go about isolating the UV island from an arbitrary point though. Does anyone have any suggestions that might steer me on the correct track? I thought about using a second texture to mask out everything but the UV island, but I’m not sure how I would go about generating this mask in real time on the fly at reasonable performance levels.

Also, the reason I’m not simply using projectors or spawning decal meshes is that these paint splats can be thrown anywhere in the world which would drag performance down pretty fast if I’m spawning lots of meshes. And they also need to stick around indefinitely, so I think my best approach is to paint it directly into the material.

I did, you can see the result on my blog here. It gives a brief 2 sentence description on what I did. I will try and remember to post a code sample later.