- Home /
Isolate a UV Island (aka Shell)
Alright, I'm in the middle of making a decal system that paints directly on textures. I also have it doing the legwork on the video card so there's no lag like using a Texture2D.Apply() approach.
Anyway, essentially I'm just stamping the texture with the decal at the specified UV coord. My next step is to isolate the island hit by the raycast so I can limit the decal to that island. So that way when a decal hits near the edge of an island, it doesn't leak into neighboring islands.
What I know:
-UV coord of raycast hit (where I draw)
-triangle index that was hit (how I find the correct texture to draw on)
-an array of all the UVs (not using it yet, but I'm fairly sure it would help in the isolation process)
Can anyone help me figure out how to isolate the island that was hit? I've really scowered this forum, stack overflow, and google...found some similar pleas for help but no answers.
Any help is much appreciated : ]
Edit: I've asked around with some of the artists and I'm told a UV Island is also sometimes refered to as a Shell.
Unfortunately there's no built in solution that does this in Unity, so you'd need to step through tris in the mesh connected to the one the raycast hit and for each untested vertex, test if it forms part of the edge of the island.
The way I see it, it would work somewhat like flood fill logic for paint programs. This could prove pretty expensive for meshes with many tris and few UV islands.
How would I know when I've hit the border of an island when checking the tris? Also how do I know which vertices belong to each tri? I only have the tri index (int) of the tri that was hit.
Did you have any luck with this? I'm trying to do something similar.
For my case I could make a texture with a different colour for each island (for each of the meshes I want to use). However, it would be a lot nicer to have something automated.
Your answer
Follow this Question
Related Questions
Assigning UV Map to model at runtime 0 Answers
Mesh texture not properly rendered 0 Answers
How to set the colour of a texture, but only within certain UV Coordinates? 0 Answers
Multiple Cars not working 1 Answer
How to rotate a UV/ texture? 2 Answers