Collapse UDIM not work for customized UV island and tiles

Issue #1085 closed
engetudouiti created an issue

Collapse UDIM tile only work for daz default UV (I suppose so)

But it not work for merged Grafted gen parts Tile which located to other UV tile.

I located gen parts UV as 1009 like this

Collapse tool , Collapse all UV tile to 1001 with keep eadh UV,

but about These part are merged or simply disappear. (UV broken)

At same time it Merge Torso3 and Anus (Grafted part mesh for Torso>> it need to merge for Torso2, UV island)

seems merged as One point (or disappear)

To confirm now I select Torso 3 mesh in 3d view. with use UV sync selection. as you see, they seems merged or disappear. (though I usually merge Torso3, and Torso2,,and anus as one material, when I bake etc)

If I use “Restore UDIM” it can return as same as before Though.

Same thing happen if I set UDIM tile for Genpart as 1011. after all those user customize (change UV island)

part (torso3, anus, and other grafted parts) break when Use Collapse .

Comments (8)

  1. engetudouiti reporter

    I suppose, Thomas do not make it work for custom UV

    if you make it work for all mesh (which cordinate as usuall UV tiles) to locate on 1001 tile, you may need to change way

    import bpy
    import bmesh
    import mathutils
    import math
    
    ao = bpy.context.active_object
    auv = ao.data.uv_layers.active
    auv_name = auv.name
    auv.name +=  "_keep"
    ao.data.uv_layers.update()
    tuv = ao.data.uv_layers.new(name = auv_name)
    ao.data.uv_layers.active = tuv
    tuv.active_render = True
    bpy.ops.object.mode_set(mode = "OBJECT")
    bpy.ops.object.mode_set(mode = "EDIT")
    ao.data.update()
    
    bm = None
    bm = bmesh.from_edit_mesh(ao.data)
    uvl = bm.loops.layers.uv.active
    
    def get_delta(face, uvl):
        xl = []
        yl = []
    
        for lv in face.loops:
            u_vec = lv[uvl].uv
            dx = int(u_vec.x)
            xl.append(dx)
            dy = int(u_vec.y)
            yl.append(dy)
    
        dx = int(min(xl))
        dy = int(min(yl))
        return mathutils.Vector((dx, dy))
    
    
    for face in bm.faces:
        delta_vec = get_delta(face, uvl)
        if delta_vec.x != 0 or delta_vec.y != 0:
            for lv in face.loops:
                c_uv = lv[uvl].uv
                lv[uvl].uv = c_uv - delta_vec
    
    bmesh.update_edit_mesh(ao.data)
    bm.free()
    
    bpy.ops.object.mode_set(mode = "EDIT")
    

    Without there is UV loop which cross over 2 tile (wrong UV so I ignore them)

    this script can collapse correctly all loop on to 1001 UV with keep each island

    Though I do not know how you return as UDIM. (it seems toggle everytime)

    I simply keep current UV and only edit duplicate UV as collapse. then rename them. (old UV are rename with staffix)

  2. engetudouiti reporter

    Though I do not check your code, but I found why I lost collapsed UDIM about specific part, but it can still render,, I suppose so there should be UV for those part. but hidden from view. then I focus on it. with select.

    Now I confirm, you fly away UDIM for those part like this (maybe check texture etc?)

  3. Thomas Larsson repo owner

    It looks like you are merging the base and geograft uv layers into a single uv layer. That could be clever, but it is not something that works with the plugin tools. The uv tile is stored in a custom material property, and there is only one such property per material. The intended use is to move the geograft uvs in the base layer to the torso layer 1002. You can move the uvs on the geograft layer to 1009, but if you merge the base and geograft layers all geograft uvs will move to 1009. And the materials really need two layers as well.

    Illustration is for GP, I will check NGV8 soon.

  4. Thomas Larsson repo owner

    I checked with NGV8 and it is the same. The uvs don’t match yours but are similar, so I suppose you use another version of NGV. Anyway, the udim tools will not work propertly if you move things on several uv layers.

  5. engetudouiti reporter

    I see,, I had not merged toros 3, and anus (grafted part) with torso2 before,

    but I notice, actually they may better to locate same place. (because UV perfectly match = when bake or paint, they can paint texures as one tile. so I usually locate anus, torso 3 as same main torso2 tile (but keep materials)

    (and actually I need to remove graft part seam, and re-generate which can along with island. + for some other 3d tools, I sometimes need to merge UV verts about clonnec loop verts. (those aprication, think they are separate island, even though I locate same place, so it sometimes cause issue, when I make one texture for them. >> merge UV verts with distance solve issue.

    And yes I suppose,, maybe It work when I keep your described prosedure, and not move around individual island.

    About this case, I just test if it work, and at first I miss understand, it seems work.

    but when bake, or export to 3d coat, I notcie, about grafted part show strange way. then just check it how actually collapsed. I suspected, they seeem merge as one vartex, but actually they seems remain, + seems locate different place.

    So now confirmed, ok, I may close this.

  6. Alessandro Padovani

    Or you can use the blender uv editor to “collapse“ udims as you want. Just select 1009 then grab to 1001.

  7. Log in to comment