Script : Overlapping UVs?

Hello guys
I have been looking for a solution to check for overlapping uvs as Mari does not like uvs overlapping
We work with UDIMS and sometimes an assets UDIM can go upto 100 uv tiles as well
I am looking for some kind of script that could do the help for us

 • I looked around the internet but most of the scripts use the bounding box method which cannot be 100% accurate...

 • Zbrush has a way to color code the uvs red that overlap but that too does not seem to work for udims and i dont want to split my mesh based on uv tiles nd then extract maps for all of them

I am looking forward to have a solution that can select the vertices that overlap in the uv space…
I can code stuff but I am still wondering how to execute this whole thing
Anyone of u can help with this??
I would be really grateful to you guys…

PS : I thought of a very wierd way of doing this… So basically you select your uv shells one by one and flood paint black color on to a blank texture with an opacity of 0.2 using maya’s 3d paint tool . This ways any shells overlapping will have a value of more than 0.2 at the intersection area(coz that area gets painted twice or more ) This ways we get a color coded map for the particular tile and then bake that texture to the vertex colors and then somehow read vertex colors nd select the once which have color values more than 0.2.
I know the above solution sounds stupid but that’s all i could think of using the maya tools available…

to find overlaps you really do need to check every triangle against every other triangle for overlaps, and it can get slow if done with python. there are some things you can do to speed it up tho, you can partition UV space into some number of buckets or tiles, and collect triangles that cross the boundaries into buckets. this will limit the number of triangles that need to be compared against each other.

to find overlaps you need to perform two tests - point inside triangle test, and a line intersection test. Just doing a line intersection test will not find triangles that are contained completely within another triangle.

Depending on the nature of your data, you can probably accelerate this kind of thing with a quadtree – that will make it fairly quick to elminate big areas of the map where things are pretty good if the data is regular (if the UV edges tend to run N-S-E-W and not at other angles) But for noisy data you’re stick with all-against-all, which is pretty brutal.

The UV-Shell to texture method would actually pretty well for dense data (where the disk time cost of writing out lots of maps would be balanced out by the substitution of a lot of simple linear ops for one huge quadratic one. However for smaller meshes the 100x slowdown of involving hard drives would eat up the savings fast.

One issue I seem to be facing now is painting on selected faces using maya.cmds :confused:
Is there any command that could help me do that
I can’t seem to find anything in the python technical docs for maya.

check out http://download.autodesk.com/us/maya/2011help/CommandsPython/artUserPaintCtx.html and http://download.autodesk.com/us/maya/2011help/CommandsPython/index.html

do you only care about overlaps between shells? it is possible for uvs within a shell to overlap…

Yeah mostly the issue occurs when laying out uv in udim in maya
Human error is very much possible when you gotta layout your uvs in 40+ tiles :D:

One thing you can do pretty easily is to make sure than no shell crosses a tile boundary - that’s just a range check against the shell bounds and the tile boundaries

I think rasterization is the way.

I would probably do something like in your original idea, generate a mesh where each vertex [x,y,z] corresponds to uv vertices [u,v,random-jitter-value-to-avoid-z-fight], assign a semi-transparent material, render isometrically from the top and search for less-transparent pixels. Will probably be rather slow in pure python.

If you’re looking for more performant option, I would go with C++ plugin or external executable and OpenCV for maximum speed to find overlapping blobs, it’s great for tasks like “find and mark me blobs of different color”.