3

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, unity forum, and google...found some similar pleas for help but no answers.

Any help is much appreciated : ]

Edit: After speaking with some of the artists, a UV Island is also sometimes refered to as a shell.

quetzalcoatl
  • 32,194
  • 8
  • 68
  • 107
gord0
  • 111
  • 5
  • 1
    I guess you mean 'Unity, the 3D engine', not 'Unity, the IoC', correct? Try to be more careful when choosing tags :) – quetzalcoatl Feb 13 '14 at 15:48
  • Unity maps UVs and vertices one-to-one, so you can treat their indices interchangeably. Given a triangle index, you can pull three vert indices from the mesh's [`triangles`](http://docs.unity3d.com/Documentation/ScriptReference/Mesh-triangles.html). Consider that triangle and its verts "marked". From there, we perform a graph search: find and mark any triangle containing at least one marked vert, mark all of its verts, repeat until finished. This information might be worth caching. – rutter Feb 13 '14 at 22:13
  • Sorry for taking 3 days to reply. Friday was a snow day and I don't work weekends. Anyway, I'm kind of confused with this. The Mesh has an array of UVs(Vector2[]), an array of Vertices(Vector3[]), and an array of triangle indexes(int[]). How can I figure out which 3 vertices from the vertices array belong to any given triangle index? Are you saying triangles[0] represents the triangle made of vertices[0], vertices[1], and vertices[2]? Also how do I know which triangles do and do not belong to the desired island? – gord0 Feb 17 '14 at 14:37
  • 1
    The only way to not bleed over to another triangle is for the triangles to not share vertices, I think the terrain shares vertices how ever the basic shape cube in unity does not so a good test would be to test it on each and see if that is your problem, although depending on how your uvs are setup im unsure if you will be able to isolate them without editing the uvs – Shredder2500 Feb 28 '14 at 05:53
  • What I really need to know is how to detect the border of an island when analysing the verts/tris/uvs. If I can do that, I should be able to mask out the rest of the islands. – gord0 Feb 28 '14 at 15:44
  • @quetzalcoatl Fix the misnomer tag, and this won't be a problem. Unity isn't unity3d. Rename it to unity-engine or similar. –  Mar 05 '14 at 19:41
  • I see that there's a unity-game-engine, but it's not strictly for games, and nobody uses that tag. Migrate everything to a better tag and delete the worthless ones. –  Mar 05 '14 at 19:50
  • @rutter it would be clearer if you said "UVs and positions one-to-one"; Unity's Mesh.vertices is not named well; it should be Mesh.Positions. –  Mar 05 '14 at 19:59
  • @jessy: what misnomer? there's none. [unity3d] (framework) has "just" ~4000 questions. [unity] (IoC) has "just" 2000 questions. Both are well-defined and well-known and well-described. Here I've corrected unity->unity3d because apparently the question author (a) didn't know the Unity IoC from Microsoft (b) did not care to check the descriptions. – quetzalcoatl Mar 06 '14 at 01:24
  • The tag was corrected back on Feb.13, so it's not even worth discussing tags at this point. As Quetzalcoatl said, I simply didn't notice I had the wrong unity tag, in fact I had no idea there was something programming related also named Unity. End of the day, no harm done. I've had this issue on hold for a while working on other things, but if anyone knows how I can determine island borders with the information available to me, I would be most grateful. – gord0 Mar 06 '14 at 12:47
  • No, it's still wrong. "unity3d" is a web address chosen without enough forward thought, not the name of a product. http://unity3d.com/unity/whats-new/unity-4.3 This isn't gord0's problem. Just please don't be snarky to people to people who don't use an inaccurate tag. –  Mar 06 '14 at 13:47
  • That's a bit nit picky, no one would be confused when you say you're working with "unity3d". I've made other threads on this with that tag and no one ever said anything, mods or otherwise. – gord0 Mar 06 '14 at 14:41

0 Answers0