gpvigano / AsImpL

Asynchronous Importer and run-time Loader for Unity
MIT License
212 stars 37 forks source link

Load meshes containing multiple materials #48

Closed X2Stone closed 2 years ago

X2Stone commented 3 years ago

Hi, First of all, thank you so much for your awesome work ! It rocks ! I would like to have some feedback concerning my problem using it : I need to load an OBJ file containing a mesh that have multiple materials on it (assigned to different faces of the mesh). The OBJ is perfectly imported into Unity via the Editor (it keeps the mesh as is, 1 shape with 3 materials on it) but when I load my OBJ file with AsImpl, it splits the mesh into sub-meshes (childs) that have only 1 material each. I really need to keep single meshes as single meshes with their several materials, is there a way to modify your plugin so that it keeps the OBJ as it is ? Thanks a lot for your answer.

gpvigano commented 3 years ago

The implementation of this feature is not trivial, it requires important changes to the object building process. I'm working on it...

gpvigano commented 2 years ago

I just committed a new version supporting sub-meshes for each material.

I added an option to split meshes by materials (splitByMaterial, default = false) that can be changed both in inspector and in the AsImpL asset import dialog.

Important: now sub-meshes are enabled by default, if you need to keep the old loading mode (e.g. you need to access object parts like in the previous version) you need to enable the Split By Material option. For older Unity versions without the support for 32 bit indices the building process falls back to the old mode (split by material).

I made a massive refactoring of the object building process.

This is a summary of the call hierarchy in ObjectBuilder:

split by material option (old implementation):

default (new implementation):

X2Stone commented 2 years ago

Wahouuu thank you so much for this update, i’m conscious that it hasn’t been easy to modify your plugin to take into account my request, really appreciate it ! Can’t wait to test it ! You rock man !

gpvigano commented 2 years ago

You're welcome. If you find some problem we can reopen this issue.