- Home /
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 know this was posted two years ago, but I'm doing something similar, did you ever figure this out?
I just tried to run the webplayer...in ie, ff, and chrome... doesn't do anything but show me some blue shapes... unless there's some really odd input buttons that I didn't think to try.
Also will you be posting the code samples here or on your blog?
Bump on this. Please share code if you've managed to solve this problem. Cheers
@Jacktang can you please post a code sample? Your link isn't active anymore either.
Answer by Jacktang · Feb 13, 2014 at 05:32 PM
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.
http://morgan-davidson.com/2012/07/31/procedural-surface-painting/
Your answer
Follow this Question
Related Questions
Assigning UV Map to model at runtime 0 Answers
Identical material with different textures 0 Answers
UV tiling to fill face? 1 Answer