Tested using Blender and UE4:
- Create a simple mesh in Blender and import it into Unreal
- Create an LOD 1 version of the mesh in Blender, import into Unreal using the “Import LOD 1” button under LOD Settings->LODImport in the static mesh viewer
- Place the static mesh in the world and check the details panel. You should see 2 materials (this is correct)
- Now reimport either LOD1 or the base mesh again. Now the details panel shows 3 materials instead of 2! Reimporting more times inflates the material count even further.
The only workaround is to import the base mesh from scratch with a new name, setup LODs from scratch and delete the bad mesh and make it point to the new one. Not ideal!
Hi VSZ -
Thank you for your report. This is a known issue currently under investigation as UE-1394. I have added your information to the report and updated the community interest. As we continue to investigate and work toward a solution I will keep you informed here.
Any updates on this one? It’s chasing me as well. It seems the dummy material slots hold valid references to materials. I had a number of cases where I was cleaning the project up and removing unused materials and I couldn’t do that. And there’s no way to break those references since they don’t appear in the Static Mesh Editor (just in the Details panel for the related static mesh actors).
Hi bstone -
No updates for this issue. It is currently backlogged in our system, but I have added you information to it and updated the community interest.
Thank You -
To add more info I’ve discovered that having imported a base LOD and added 3 other LODs to it, then reimporting those a few times to get the material slot count up to 9 - in the static mesh editor I go to Assets->reimport and it’s now down to 2 slots, which seems odd when there are 4 LODs and each use the same material in blender. Surely that’s either 4 slots or just 1?
This is a valid concern for Blender users IMO.
I read elsewhere on Answerhub that this was considered an editor-only bug with no in-game impact. This is not accurate though; run-time mesh/material assignment code is seriously affected because the order of material indices can no longer be relied on! Also spawning duplicate materials all over the place is not a benign usability issue (as bstone’s problem with invalid project references illustrates) so I would consider this a major bug by any metric.
EDIT: Another example; consider a project that has been in development for a year and has a mesh that has been reimported say 30 times. That mesh will now have >30 material slots if it had 2 LODs and close to 100 material slots if it had 3 LODs. Even considering just the Editor, surely, this is a bug worth fixing!
In terms of workflow, while Maya/Max users can simply bundle their LODs into a single FBX, Blender users rely solely on the LOD Importer pipeline to get their LODs in. AFAIK the LOD importer feature introduced was specifically to support LODs for Blender so it would be nice to finally see a resolution for this ancient bug! I’ve been tediously reimporting meshes from scratch all this time even for a tiny change to any given mesh.
My thanks to bstone and TomH for bumping this! I haven’t followed up on my bug report as keenly as I should have due to a real lack of time, so I thank you for keeping the focus on this bug going. Also thanks to Eric Ketchum and Epic for looking into this!
I’ve added your concerns and notes here to the ticket in question. I’ll bring it up and see if we can get this to a higher priority but I cannot guarantee that currently.
@VSZ @Tom H
If you have a test FBX that can reproduce this can you please attach something here in a .zip file. I’ve not been able to reproduce this in the latest 4.12. Thank you!
Hi Tim, which Blender version did you use? (assuming you used Blender that is, but it if not it shouldn’t matter as I believe the bug is in the LOD Importer code itself). I’m asking so we’re on the same page when I send you a test file.
PS: To recap, the duplicate materials do not show up in the Static Mesh editor itself but they are visible when you place a static mesh in the map. More importantly they manifest internally; i.e. any material operation relying on index like mesh->GetMaterial(i) or mesh->CreateDynamicMaterialInstance(i) won’t work logically because of the duplicate materials messing up the index order.
I was actually able to get it to reproduce now. Happens with any FBX no matter software. The one point I didn’t do was place an actor in the world and look at its Details panel there. I was only looking at the one in the Static Mesh editor. One of the engineers is in progress to get this fixed for 4.13. Thanks!
This is still happening. Reimported LODs 1 - 6. Messages indicated success for each. The editor added something like 66 Material Slots.
These are FBX files exported from Blender 2.79.
Also, LODs 1 - 6 aren’t actually appearing, but that would be a different issue.
Try to check the sameness of material names in Blender and Slot Names in UE4 Static Mesh Editor. Edit if needed.
FWIW I don’t normally apply materials in Blender. The import comes with a default material that then gets discarded.
I suppose I could try that though. Thanks.
Few years down the line, the problem still persists. I have distributed my foliage, made some changes to the lightmaps, reimported and now I have plenty of unused empty material slots, which I can neither get rid of, nor populate with a material. In order to fix that, I’ll now have to delete ALL foliage from my level, delete the mesh from content browser, reimport, setup LODs and their distances and populate the level back again.