PDA

View Full Version : Finding a UV map



Andy Webb
12-16-2016, 03:50 AM
I seem to have found myself in a silly situation.

I have purchased a 3D model and many layers have been UV mapped.

However not all the surfaces have been surfaced and all the UV maps are only labeled 1 to 80 :cursin:

Is there a way of selection a surface and finding its associated UV map?

Cheers

Spinland
12-16-2016, 03:54 AM
Kind of cumbersome, but "i" with a poly selected will tell you the associated surface. From there you can use the surface editor to see the texture info.

Andy Webb
12-16-2016, 04:10 AM
Kind of cumbersome, but "i" with a poly selected will tell you the associated surface. From there you can use the surface editor to see the texture info.

Unfortunately that doesn't tell me what UV map is associated with the selected polygons.

To put it another way, I have a set of polygons selected, they makeup a surface called "windshield" which must have a UV map associated with because I have a "windshield" transparency map .PNG but it has not been assigned to the transparency channel. I need to know which of the 80+ UV maps is the "windshield" map.

Cheers

Spinland
12-16-2016, 04:27 AM
And none of the surfaces came in with UV information, not even diffuse? Hmm.

Andy Webb
12-16-2016, 04:57 AM
This is a question after the event as I was too busy at the time.

So after trawling through 80+ UV maps I found the one I needed.

Selecting the polygons did work, all I had to do was go to each UV map until I found the one that its self was selected.

I just need to know if there is a quicker and simpler way to do this?

Spinland
12-16-2016, 05:08 AM
Yeah, that's a great question. I'm wondering whether 3D Coat might have been useful, but that doesn't help with a LW centric solution. Interesting problem!

Andy Webb
12-16-2016, 05:13 AM
Sounds like the sort of problem a plugin could solve, if anyone is interested?

Cheers

Andy Webb
12-16-2016, 05:30 AM
Well I seem to have found a cumbersome way of doing this, I am annoyed that I had not thought of this earlier.

But select the polygons and just copy and paste to a new object, the UV map copies with it and is then the only UV map in the UV list of maps. :D

It would be nice though if LW just showed any selected UV maps associated with selected polygons. :rolleyes:

Sensei
12-16-2016, 05:36 AM
Single surface can use multiple UV maps at the same time.

If UV maps are used in nodes, it's not even possible to check it.
(at least using LWSDK)

Danner
12-16-2016, 06:45 AM
I would have tried the following. Export the model as an FBX file from layout and select "colapse Materials" then import that fbx back into modeler. It basically puts all your UVs into one.

Andy Webb
12-16-2016, 06:57 AM
I would have tried the following. Export the model as an FBX file from layout and select "colapse Materials" then import that fbx back into modeler. It basically puts all your UVs into one.

Yes that's a possibility.

It somehow seems odd that if you select a set of polygons you cannot then see a list of UV maps associated with that selection. :(

ernpchan
12-16-2016, 08:06 AM
If you select a point and hit the 'i' key to get the Point Info panel it'll show you all the vmaps associated with that point. Vmaps contain point info, not so much the actual polygon.

Andy Webb
12-16-2016, 08:14 AM
If you select a point and hit the 'i' key to get the Point Info panel it'll show you all the vmaps associated with that point. Vmaps contain point info, not so much the actual polygon.

No it doesn't, all I get is X, Y, Z info... :)

ernpchan
12-16-2016, 10:23 AM
No it doesn't, all I get is X, Y, Z info... :)

Works for me. I just made a sphere where I made a planar uv map and then a spherical one. With the point selected I can see the UV values.

135330

Kryslin
12-16-2016, 11:22 AM
Sounds like a simple task for an lScript; select a polygon, get its points, and then display the UV maps on the points. Cycle through multiple selected polygons, if needed.

MonroePoteet
12-16-2016, 11:31 AM
Here's an LScript which displays the Texture Image UV Map names for a user-selected Channel (e.g. Color, Diffuse) for a set of selected polygons. Although it works for multiple polygons, you may have less confusion about which polygon(s) have which UV Maps by doing them one polygon at a time.

To use it, select one or more polygons in Modeler, invoke the LScript and specify which Channel you want to scan. It will display the Surface for each polygon and the names of any UV Maps in any Image-type Texture Layer of the Surface.

The point selection info works proposed by Sensei, but I tend to think of UV Maps as being associated with polygons rather than a Point, although I know they're actually implemented as vertex maps. If two adjacent polygons share a vertex, you'd have to know which UV Map was associated with the polygon you want to identify. As well, the LScript may be easier to use for bulk processing, as I think you may need to do.

Hope it helps!
mTp

JohnMarchant
12-16-2016, 12:36 PM
Thanks and useful.

Andy Webb
12-16-2016, 04:39 PM
Works for me. I just made a sphere where I made a planar uv map and then a spherical one. With the point selected I can see the UV values.

135330

It works if like you I make a uv map in LW, but my object was purchased and was originally a .OBJ file, I assume this is where the problem arises?

ernpchan
12-16-2016, 06:44 PM
It works if like you I make a uv map in LW, but my object was purchased and was originally a .OBJ file, I assume this is where the problem arises?

Ah yes, I just tested that on an obj out of Maya and it doesn't show that my selected point is associated with a vmap. Not sure if that's a bug or limitation of obj files when loaded in Modeler. It certainly is worth submitting as a bug request.

Andy Webb
12-17-2016, 04:38 AM
Hi MonroePoteet, thanks for the Lscript. Unfortunately I need to know the UV map associated with the polygon/points.

In my case there are no channels to choose as no channel is using the UV map, I need to find the map so I can use it in a channel... so its the polygon association I need not the channels.

But thanks again for the LScript.

MonroePoteet
12-17-2016, 08:04 AM
Ah, OK, I misunderstood. A *much* easier LScript than the Channel to UVMap I posted earlier! Ah well.

The attached LScript only works on a single polygon. It walks all the Texture / UVMaps available, and for each Texture map, if all the points of the polygon are mapped that UVMap, it calls out that UVMap. You'll have to determine which of the called out UVMaps is approriate to which channel (e.g. Color, Diffuse, etc.).

Sorry for the confusion!

mTp

Andy Webb
12-17-2016, 11:44 AM
I'm afraid this is all I'm getting...

135346

MonroePoteet
12-17-2016, 12:14 PM
Huh. Interesting. I'm not sure how an Image would be UV Mapped to a Polygon which doesn't have all its Points mapped, even if some UV values go negative or above 1.0. I guess maybe if the edge of the image crosses the polygon? I'll leave how to interpret that up to you, or maybe someone else has some input. The reason I implemented the original LScript that way was to avoid confusion over vertices that were shared between two polygons with different UVMaps. Maybe if *most* of the points are mapped to a UVMap it would be considered part of that Surface? Dunno.

Here's a variant of the LScript which will lists out the UVMaps for each point unconditionally. If all points have a UV value in the map, it will add that information.

Again, good luck, and hope it helps!

mTp

MonroePoteet
12-17-2016, 12:29 PM
...and (finally?), here's an LScript which produces a simple list of all UVMaps which have any point mapped to them for the selected polygon. We'll hope that if you set a Polygon's Surface to an adjacent polygon's UV Map, that the UV value of the point will be appropriate. I'd guess that you'll want the Width Tile and Height Tile set to Reset rather than Repeat on all your LW UVMap Texture layers in this case, but I don't know.

In the end, this basically reproduces the Polygon Info information suggested by Sensei. Ah well... :)

mTp

JoePoe
12-17-2016, 02:36 PM
Monroe thanks for all the scripting.

Unfortunately I think the initial problem persists.
This is what I get with a UV brought in as part of an obj. (poly/points are fully within the UV)

135349

MonroePoteet
12-17-2016, 03:04 PM
Hmmm. Can you point me to the OBJ file you're using so I can try to figure out why it doesn't work? Or, copy a small portion of the problem mesh into a new LWO file and post it?

Thanks,
mTp

JoePoe
12-17-2016, 03:46 PM
You actually want a piece of the Hulk?! HULK SMASH! :D

Here ya go....

MonroePoteet
12-17-2016, 04:03 PM
You actually want a piece of the Hulk?! HULK SMASH! :D

Here ya go....

:D

Sadly, I have no clue as to what's going on here. If I select a point or points in the mesh you posted, it shows no Vertex Map information, which is what I based the (failed) LScripts upon. Indeed, the mesh seems to have no Vertex Map information at all. It's clear that the UV mapping is done in some method, since if I go into UV Texture view mode, the mesh is clearly stretched and inverted to bring portions of the texture image into place, but I don't know where that data is stored or how to access it.

If anyone with more .OBJ import experience or technical knowledge of OBJ format has some input, it'd be welcome. I don't have time to go look at the specification for OBJ files to try to figure out where to glean the data.

Sorry!

mTp

jeric_synergy
12-17-2016, 05:44 PM
I guess I'm not understanding the question, since here I'm seeing the Vertex map in the VMap panel-- is that info not showing up programmatically for the script?
135352

Andy Webb
12-18-2016, 05:00 AM
I guess I'm not understanding the question, since here I'm seeing the Vertex map in the VMap panel-- is that info not showing up programmatically for the script?
135352

Yes you are right BUT if you open an object with (as in my case), 95 layers and each layer has a UV map the VMap Panel shows all 95 UV's. My problem is the UVs are just labeled 1 to 95, even when you have only one layer selected and it doesn't show which UV is associated with the layer you have selected!

So then the only thing to do is laboriously go through each UV map, one at a time, until you find the one you want :(

MonroePoteet
12-18-2016, 07:53 AM
I guess I'm not understanding the question, since here I'm seeing the Vertex map in the VMap panel-- is that info not showing up programmatically for the script?
135352

Yes, I'm sorry, I misspoke. The Texture Vertex map is defined, but the individual points of the polygons don't have VMap information. For objects created with LW Modeler, when a Texture (i.e. UV map) is assigned to a polygon, each point in that polygon has a VMap attribute added to the point containing the UV data for that point. The UV data in the VMap attribute is the X,Y coordinates within the associated image to map to the point, which if the polygon is completely within the texture image will be between 0.0 and 1.0, but if the point falls outside the image may be negative or greater than 1.0. My scripts were intended to take the VMap attributes of the individual points, lookup the associated UV map, and display their names.

In the piece of Hulk ( :) ) JoePoe posted, the individual points do not have VMap attributes mapping them into the UV map, but it appears there's SOME method that does so, but I don't know what method that is or how to access the data.

mTp

MonroePoteet
12-18-2016, 08:47 AM
A little research (TMI?): the LW Object specification was updated back in 2001 to the LWO2 format to support "discontinuous vertex maps" which attempts to resolve the seam problem with image maps. The seam problem is seen on (topologically equivalent) cylindrical or spherical or other closed objects where one edge of the image UV mapped meets the opposite edge.

It appears that the LScript access to VMap information doesn't understand the 15-year-old VMAD chunks in the LWO2 object format, so it doesn't see the per-point VMap information in LWO2 object files with discontinuous vertex maps. I *think*. Opening the LW object posted by JoePoe in Notepad, I can see what I think are the single VMAP chunk defining the texture map, and a couple of VMAD chunks for per-point definitions (maybe), but there doesn't appear to be per-point VMAP chunks that are accessible to LScript (or probably binary LW plug-ins either). The LWO2 format is a binary format, so without a LW Object "interpreter tool", it's hard to say looking at it in Notepad.

All this is speculation, unfortunately.

References:

http://fileformats.archiveteam.org/wiki/LightWave_Object
http://static.lightwave3d.com/sdk/11-6/html/filefmts/lwo2.html

mTp

Andy Webb
12-18-2016, 09:13 AM
Well it was worth a shot. Many thanks for your effort.

It has highlighted (for me that is), some short comings for the Vertex Maps panel.

Cheers

JoePoe
12-18-2016, 09:25 AM
**SOLUTION**
(well, very minimal workaround..... :))

Unweld all then Merge. Done.
Now both work. Info works with points.
Monroe's works with polys.

135355

JOEPOE SMASH! :D

Andy Webb
12-18-2016, 09:40 AM
**SOLUTION**
(well, very minimal workaround..... :))

Unweld all then Merge. Done.
Now both work. Info works with points.
Monroe's works with polys.

135355

JOEPOE SMASH! :D

YES! works a treat. Thought going through 95 layers doing that is still a real pain in the butt!

JoePoe
12-18-2016, 09:48 AM
Do it all at once! :beerchug:
(if you have a million points.... maybe in two or three chunks)

MonroePoteet
12-18-2016, 01:33 PM
Nice work, JoePoe! Unfortunately, what I suspect your workaround does is eliminate the discontinuous vertex maps, which means the seam problem (if any) may show up on the modified model. I don't know for sure, though!

Again: nice work!

mTp

P.S. saving out the merged model and opening it in Notepad shows the VMAD chunks are gone and new VMAP chunks are there, seeming to confirm my prior hypothesis. As I said, the modified / merged model may show seams in the UV maps that weren't there with the discontinuous vertex maps.

MonroePoteet
12-18-2016, 03:39 PM
Bug reported: discontinuous vertex maps should appear in the Point Information and be accessible via LScript.

mTp

oliverhotz
12-18-2016, 04:20 PM
try this one... should work..select polygon.. and run it

MonroePoteet
12-18-2016, 04:49 PM
Excellent! I added the information to my bug report that the discontinuous vertex maps are accessible via the Python function:

lwsdk.LWObjectFuncs().numVMaps(<vmap_type>)

using the <vmap_type> of lwsdk.LWVMAP_TXUV. Hopefully, LWDG can use the code from the Python library to provide accessibility to Point Information and LScript.

THANKS!
mTp

oliverhotz
12-18-2016, 05:36 PM
should be availabler via lscript as well.. you just has nothing to do with lwobjectfuncs().numvmap

you need to check for discontinuous/continous info in the points/polys

MonroePoteet
12-18-2016, 06:08 PM
should be availabler via lscript as well.. you just has nothing to do with lwobjectfuncs().numvmap

you need to check for discontinuous/continous info in the points/polys

No clue what you're saying or what you mean. Sorry for my stupidity.

mTp

jeric_synergy
12-18-2016, 06:30 PM
No clue what you're saying or what you mean. Sorry for my stupidity.
mTp
Ha! Now you know how I feel as I kibitz these threads! ;) :thumbsup:

oliverhotz
12-18-2016, 06:48 PM
in the script.. check for where i do pointvpget and pointvget... thats what you need to check for.

Andy Webb
12-19-2016, 03:40 AM
Hi Oliver, that works a treat.

You need to add it to your tool set.

Cheers

MonroePoteet
12-19-2016, 08:36 AM
in the script.. check for where i do pointvpget and pointvget... thats what you need to check for.

OK, thanks for the clarification. It doesn't appear that the VPGet function is available in LScript (I only see VMapObject.getValue()) although perhaps it's just undocumented (I'll try it when I get a chance), and I don't think the VMapObject.isMapped() function should return FALSE if the point is in a discontinuous vertex map. The Point Information panel also doesn't show these DVMs. I think at least Point Information should show them, so I'll probably leave my bug report in place, updating it if I can find the equivalend of VPGet in LScript and implement your algorithm.

Thanks again!
mTp

P.S. I tested the VMapObject.getValue() function, and it returns NULL for a point which is in a DVM

JoePoe
12-20-2016, 08:56 AM
Oliverhotz SMASH!!

135370

tburbage
12-31-2016, 12:50 AM
Ah yes, I just tested that on an obj out of Maya and it doesn't show that my selected point is associated with a vmap. Not sure if that's a bug or limitation of obj files when loaded in Modeler. It certainly is worth submitting as a bug request.

Not sure why the UV assignment isn't visible initially, but I found that if I unwelded and merged the model, the UV map assignments are then visible in the Point Info list. Map:Weld UV also seemed to work.

Once that is done, change to Polygon mode, then Selection > Polygons: VMap Poly Select.

jeric_synergy
12-31-2016, 09:31 AM
It's possible some updating is occurring. Here's a thought: if you DON'T want to mess w/your model, Unweld/Merge a different model or mesh, and see if the update got the original too.

jwiede
12-31-2016, 06:24 PM
It's possible some updating is occurring. Here's a thought: if you DON'T want to mess w/your model, Unweld/Merge a different model or mesh, and see if the update got the original too.

There's not supposed to be that kind of asynchronous processing/ambiguity visible through those APIs, though. I could understand if unweld/merge of same (or different) model (synchronously) caused LW to "notice and fix" the situation, but IMO, that's still a bug -- those APIs should always properly reflect accurate data. If they don't, that's a serious coherency problem.

jeric_synergy
12-31-2016, 07:01 PM
Just a possibility.

jwiede
01-06-2017, 01:20 PM
It'd be nice if LW3DG could give some kind of official answer as to the future of LScript in LW.Next and beyond -- Will LScript be updated to offer equivalently-broad scripting capabilities and access going forward as in past, or deprecated (and/or left in an unsupported state)? If the latter, is Python to be the "official" LW scripting language replacement in LW.Next and beyond?

As of LW.Next's geometry, deformer, and render engine changes, there appear to be equally-solid arguments for updating LScript as deprecating it, so "official guidance" would be appreciated.