Gildor's Forums

Author Topic: [SOLVED] Material slot names  (Read 1118 times)
floxay
Full Member
***
Posts: 83



View Profile
[SOLVED] Material slot names
« on: November 13, 2021, 23:13 »

TLDR: There seem to be some issue with the material slot names (which seem to actually be the material names)



Here's this mesh from VALORANT (I realize VALORANT is not supported as is but I don't think this is a VALORANT specific issue, this is also not a new issue)
On this mesh the displayed entries are broken, it exports the same way but null is obviously replaced with dummy material for glTF (as I use glTF since it stores the normals).

The same mesh exported by FModel gives this (I'm not aware of any modifications in FModel (or in CUE4Parse lib) that's VALORANT specific other than the 8 byte skip mentioned at the bottom of the post):


Meanwhile CUE4Parse displays this data:
Code:
"MaterialSlotName": "TP_Deadeye_S0_MI"
"MaterialSlotName": "TP_Killjoy_S0_Glass"
"MaterialSlotName": "TP_Deadeye_S0_Hair_MI"
"MaterialSlotName": "Eye_Shading_Mat"
"MaterialSlotName": "FP_Deadeye_S0_Sniper_MI"
"MaterialSlotName": "chain_sim_MI"
"MaterialSlotName": "TP_Deadeye_Chain_Cloth_S0_MI"


A quick look into UEViewer revealed that "Ar << M.MaterialSlotName;" in UnMesh4.cpp line 582 is getting the same data as the list above.


and

etc...


So material slots have the material name displayed/exported instead (in both UModel and Fmodel), I suppose this is because it's easier to identify what material belongs to a slot as slot names can be irrelevant/make no sense and have no real link to the material once it's exported?

So what could be the cause of the issue on the first picture? I mean even if it displays the material name and not the slot name it should match the one exported from FModel (second picture)

So in action: since something went wrong somewhere later the 'CS_Deadeye_S0_Glass_clear_MI', 'CS_Deadeye_S0_Hair_MI' and 'TP_Core_Eye_MI' materials are replaced by CS_Deadeye_S0_MI



Samples: https://drive.google.com/file/d/1bRAP5JAMeQ5GNzoeGVuOO4bNUdMw2VDx/view?usp=sharing
Please note that VALORANT has 8 unknown bytes between Guid and ThumbnailTableOffset, the game is on 4.25.


I hope I explained it well enough :d
« Last Edit: November 14, 2021, 04:21 by floxay » Logged
spiritovod
Global Moderator
Hero Member
*****
Posts: 2149


View Profile
Re: Material slot names
« Reply #1 on: November 14, 2021, 03:10 »

Probably I can explain this issue. Apparently at the moment LODMaterialMap is not handled properly in some particular cases. According to documentation, in case of certain index value (usually -1) a material shouldn't be remapped, but in umodel it's remapped to first material in the list in this case - that means if all indices from LODMaterialMap will be negative, all materials are replaced with first material (that's what you get).

It can be fixed by implementing additional check for current MaterialIndex - if it should be remapped, remap it, otherwise fall back to original value of it. Required code part can be found around "remap material for LOD".
« Last Edit: November 14, 2021, 13:48 by spiritovod » Logged
floxay
Full Member
***
Posts: 83



View Profile
Re: Material slot names
« Reply #2 on: November 14, 2021, 03:46 »

Probably I can explain this issue. Apparently at the moment LODMaterialMap is not handled properly in some particular cases

Perfect, thanks spiritovod!

Logged
Gildor
Administrator
Hero Member
*****
Posts: 7973



View Profile WWW
Re: [SOLVED] Material slot names
« Reply #3 on: November 14, 2021, 12:47 »

I hopefully fixed LODMaterialMap handling in UModel.
Logged
spiritovod
Global Moderator
Hero Member
*****
Posts: 2149


View Profile
Re: [SOLVED] Material slot names
« Reply #4 on: November 14, 2021, 14:03 »

@Gildor: Thanks, it works as intended now.

I've also updated Valorant specific build in the game topic. In case if someone will bump into the same issue in any other specific build, please let me know (it's not a common issue for every game).
Logged
Jump to:  

Powered by SMF | SMF © 2006-2009, Simple Machines LLC
Leviathan design by Bloc | XHTML | CSS