HELP! Fix FBX seams in Unity when exported from Layout with Merge UVs?

sami

Active member
Any ideas how to fix seams that appear between different LW surfaces in an FBX in Unity? Turns out I had an old rigged model that I needed in Unity - but it had 3 UV sets and Unity only supports 1. So instead of splitting the mesh up (which I tried but I got slightly weird seams at the splits, I exported via Layout and ticked the "Merge UVs" box - which actually helped in that it created the right materials into LW - but a nasty seam shows up at the neck. My 3 LW surfaces (and UV sets) are HEAD, BODY, EXTRAS (shoes & sunglasses).

I don't have access to the 3DCoat files where these textures were painted, but I did try loading up the textures into image editing app and "Inpainted" the "blank"areas between UV clusters/islands and that helped only ever so slightly. (I inpainted on the color, normal and spec textures just in case - but it seems the color is the biggest issue. What am I missing here?

I'm really hoping I don't have to spend a ton of time reworking this character (budget doesn't allow) to fix this. Thanks for any help!

The pictures below show Modeler on top, Layout on left, and Unity on right - this is WITH the inpainted textures (on both the head and body textures)
also attached are the original head texture and the inpainted one - I'm fairly certain the issue is in the head texture not the body one... In Unity they are 2K textures - I've reduced them here because the forum was rejecting them for size reasons.

SeamsHead.jpg
 

Attachments

  • orig_head_color.jpg
    orig_head_color.jpg
    161.8 KB · Views: 53
  • orig_head_color_inpainted.jpg
    orig_head_color_inpainted.jpg
    170.1 KB · Views: 54

sami

Active member
I’m exporting the full scene and animations as an FBX- so I’m in layout. The Merge UVs checkbox is in the FBX export window. Are you saying I should open the character in Modeler and unweld this point loop where the surface changes and then put it back in Layout and export again with merge UVs there? Thanks for your help!
 

sami

Active member
Sadly nope. I unwelded the loop which separates the LW surfaces and then Merged UVs using the export and I still get this in Unity.
1633328404600.png
 

sami

Active member
Also it turns out the only place to get detailed info on LW is in the Unity docs 🤷‍♂️
1633328610149.png

none of this helps my issue though - as far as I can tell...
 

sami

Active member
Looks like the Layout -> Save - > Export - > FBX with MergeUVs does this to my UV maps:
1633329005232.png

those stretched lines are what's surely causing the issue - not padding like I thought.
Unweld before merge didn't seem to fix this. I also ensured that "Weld Vertices" was off in the Unity FBX import settings - but that didn't help either
 

Sensei

TrueArt Support
Merge UVs manually i.e. in Modeler, instead of using Export FBX equivalent. And Unweld Points before, and after you have one UV, Merge Points.

those stretched lines are what's surely causing the issue - not padding like I thought.
I assume, when you have 3 UVs it does not look like this? Show screen-shot. Eventually attach .lwo so somebody here can play with it.. It will be quicker..

Are you saying I should open the character in Modeler and unweld this point loop where the surface changes and then put it back in Layout and export again with merge UVs there?
Not exactly. I was thinking about unwelding everything, not just a few points..

"Merge UVs manually" means: Unweld Points, Edit Vertex Maps > Copy Vertex Maps (enter name of vmap, existing one e.g. "Texture"), repeat with "Texture 1" and "Texture 2" (or whatever other name you have), then Merge Points.
 
Last edited:

Kryslin

Well-known member
I've gotten this when healing UV's in Lightwave. The solution I came up with isn't a pleasant one, namely manually editing the UV's in error so that they were in the correct place.

I had a similar issue when taking models from Lightwave -> Blender. Blender expects UV coordinates per vertice per polygon (what LW call discontinuous UVs), whereas Lightwave can do both. I made a script that made all UV's discontinuous, which solved the issue there. If you have them mixed, things go wonky along the seams.
 

sami

Active member
Thanks everyone for your help. It did seem that the problem came from Layout's FPX Export "Merge UVs" on. When you do that it seems to tie UV clusters in a weird way that I don't fully understand - it does have something to do with the discontinuous UVs. I solved it by saving it out as a 2015 LWO and loading into 3DCoat and moving all the UV islands/clusters from the 2nd and 3rd UV sets to the 1st one. Essentially manually copying the UVs from the other maps over to the 1st map making them overlapped (but without those weird stretchy lines). Then I deleted the empty UV maps and reloaded back into Modeler, saved as a 2020 LWO, then into Layout and did Export FBX without the "Merge UVs" button checked and it worked:

1633373378688.png
1633373483345.png

Having the UV's overlapped into 1 UV map, but maintaining different surfaces in LW allows me to have 1 UV map in Unity with 3 materials each pointing to the different islands in the 1 UV map.

@Sensei to answer your question - when you have 3 UV maps in Unity it does not look like that. The only surface/material that works in Unity if you have multiple UV maps is the "default" one (the one with the bullet point in Modeller) the other surfaces cannot be set inside Unity and remain Black.

Also @Sensei , can you please elaborate a little on the unwelding and what that does? I mean I know what unwelding does to the geometry (detaching the poly contiguity from each other by creating additional points) but can you unweld UV points separately from geometry unwelding? So that the polys are contiguous within Modeler as geometry but their UVs are not? I'm a little confused how Lightwave works with that - I have been using 3DCoat to UV unwrap and there is a fundamental bit of knowledge I'm missing. 3DCoat lets you create UV seams - I don't understand the LW equivalent.

Also, I don't know how to combine UV maps in LW - when I copy them from the Vertex Maps menu it just duplicates a map - do i need a plugin to combine UV maps? It seems much more straight forward in 3DCoat - but I'd like to stay in LW if i can next time.

@Kryslin thanks - can you share your script? If what you mean by "manually editing the UV's in error so that they were in the correct place." is moving the points in the UV window in Modeler, then that would be too time-consuming and imprecise for me. I've read the docs, but what exactly is "healing UVs" - the docs aren't clear.

thanks for all the help - great community as always!! (even if it is smaller now)
 

Sensei

TrueArt Support
@Sensei to answer your question - when you have 3 UV maps in Unity it does not look like that. The only surface/material that works in Unity if you have multiple UV maps is the "default" one (the one with the bullet point in Modeller) the other surfaces cannot be set inside Unity and remain Black.
Sorry, but my question was not about Unity. I asked whether before merging UVs manually in Modeler (i.e. not by using Export FBX Merge UVs) do you have those stretched lines in Modeler UV viewport...

Also @Sensei , can you please elaborate a little on the unwelding and what that does? I mean I know what unwelding does to the geometry (detaching the poly contiguity from each other by creating additional points) but can you unweld UV points separately from geometry unwelding?
When I asked to Unweld Points, I meant the first one, with full geometry detaching not just UVs. Later used Merge Points creates proper discontinuous and continuous UVs in the right places for you.
but can you unweld UV points separately from geometry unwelding?
The easiest way you can unweld UVs alone is in Modeler, UV viewport preview mode, you click on polygon(s), and move it if "Free Move" is enabled (default it is on).
Try with simple sphere if you did not know this technique.
 
Last edited:

Sensei

TrueArt Support
So that the polys are contiguous within Modeler as geometry but their UVs are not? I'm a little confused how Lightwave works with that - I have been using 3DCoat to UV unwrap and there is a fundamental bit of knowledge I'm missing. 3DCoat lets you create UV seams - I don't understand the LW equivalent.

Point=Vertex has x,y,z, and pointer, eventually index in the list of geometry.
Vertex Map is special key-value array *). For each Vertex there is one, just one Vertex Map value with given name. i.e. programmer asks "give me vertex map value(s) with name XXX for LWPntID pntid (point identifier)" and LW returns value(s) and boolean "mapped/not mapped".
*) It can be implemented a few different ways.
There is also per-polygon vertex map. i.e. programmer asks "give me vertex map value(s) with name XXX for LWPntID pntid AND LWPolID polid (polygon identifier)".
Users know them as "continuous UVs" and "discontinuous UVs". But, actually they are not just limited to UVs, but any other vertex map can be used.. One programmer can create continuous/discontinuous weight maps, or endomorph maps.

If you have vertex identifier (LWPntID), it can receive unique vertex map value(s).
Such point/vertex can be part of many different polygons.
So it can receive other values, depending on which polygon, such point is attached to.

After "Unweld Points", the all UVs are per-vertex (the first one, which are simpler, programmer just asks for "give me vertex map value(s) with name XXX for LWPntID pntid (point identifier)" and LW returns value(s) and boolean "mapped/not mapped".
(because there is no need to ask for per-polygon version).

per-vertex vmap have no color in UV viewport in Modeler.
per-polygon vmap have red color in UV viewport in Modeler.
Unweld Points in Modeler => have no red dots in UV viewport.
Merge Points in Modeler => you have them back in UV viewport, but in different places, than before Unweld Points (unless it was optimal configuration).


Displacement plugins receive just LWPntID pntid, without LWPolID polid, therefore problems with UVs. They could not read per-polygon part of vmap.
 
Last edited:

Kryslin

Well-known member
@sami : Healing UVs is found on the UV Tab -> UV Modify -> Heal UV. It works by taking selected UV coordinate(s) and if they all belong to the same vertex, are collapsed from a per polygon, per vertex UV coordinates to a per vertex UV coordinate. This can result in space savings in the model file. Lightwave has no problems handing mixed per vertex and per poly/per vertex UV maps, but other software, such as Blender, expect one or the other, it seems. I'm not sure about Unity.

My lScript for doing so is a very inelegant, brute force solution that took a long time to run on a relatively light - 10K polygon - character mesh. In fact, it was written for a single use, and was never developed past the prototype stage. So remember, you asked for it. :)

C-like:
@warnings
@name Make Discontinuous UV

main{
    var srcmap = "tkrys_main";
    var dstmap = "tkrys_main_DC";
    editbegin();
        tm1 = VMap(VMTEXTURE,srcmap);
        tm2 = VMap(VMTEXTURE,dstmap,2);
        foreach(p, polygons){
            pl = nil;
            ti = polyinfo(p);
            tc = polypointcount(p);
            for(i=1;i<=tc;i++) pl += ti[i+1];
            foreach(v,pl){
                tuv = @0.00,[email protected];
                t1 = tm1.isMapped(v);
                t2 = tm1.isMapped(v,p);
                if (t1) tuv = tm1.getValue(v);
                if (t2) tuv = tm1.getValue(v,p);
                if (t1 || t2) tm2.setValue(v,tuv,p);
            }
        }
    editend();
}

What is does is cycle through ALL the polygons and then all the vertices for that polygon, looking for mapped points for srcmap, whether or not they are continuous or discontinuous UV coordinates. If it gets a hit, it writes that UV coordinate to dstmap, and repeats. It is slow, and I never bothered to give it a UI. You would have to copy and paste this into a text document, change the srcmap and dstmap names, and save it to <yourname>.ls file for it to work on your end.

I suspect there might be another tool out there that does it in a way that's much easier - select uv map, press button, done - fashion.

But, as you said, you solved the problem.
 

Sensei

TrueArt Support
Code:
                t1 = tm1.isMapped(v);
                t2 = tm1.isMapped(v,p);
                if (t1) tuv = tm1.getValue(v);
                if (t2) tuv = tm1.getValue(v,p);
                if (t1 || t2) tm2.setValue(v,tuv,p);
@Kryslin per-polygon UV must be read prior per-vertex UV..
Once you learnt that there is existing per-polygon UV, there is no need to read per-vertex UV map.
 
Last edited:

Kryslin

Well-known member
@Sensei : I never said it was good code, did I? Just code that did the job I needed it to in an "...inelegant, brute force way." :)

(I've already made that note in my source file; should I ever re-write it into a more general solution w/UI, I'll use it. Thanks. :) )
 
Top Bottom