assimp / assimp

The official Open-Asset-Importer-Library Repository. Loads 40+ 3D-file-formats into one unified and clean data structure.
https://www.assimp.org
Other
10.97k stars 2.91k forks source link

OBJ + MTL Loaders - work with PBR materials #5254

Open GitHubDragonFly opened 1 year ago

GitHubDragonFly commented 1 year ago

Is your feature request related to a problem? Please describe. This is a suggestion with possible solution on how to improve OBJ + MTL loading with PBR materials

Describe the solution you'd like Try to utilize all PBR material properties

Describe alternatives you've considered I have improved this on my end and all my changes are included in the attached zip file

Additional context This topic is mainly intended for those ASSIMP developers who might be maintaining the OBJ files and also for any other users who might be interested in this subject. If any of my changes might serve the purpose of improving the ASSIMP library then feel free to use them.

Try to keep in mind that I normally don't do any C++ programming and that on my end I use a combination of ASSIMP, ASSIMPJS and three.js with lots of customized code. My ASSIMP Viewer is using ASSIMP(JS) to load OBJ + MTL files and then convert the model to GLB2 format and pass it on to three.js for displaying it in the browser. The viewer currently does not support drag-and-drop or zipped files so you would have to load all files from a folder.

Some of the changes I made to the attached OBJ files also include some custom names used in MTL file, like map_Px for textureRMA (its original map_Ps name needed to be changed just so it's distinguishable from sheen texture) or Pac for attenuationColor or Pad for attenuationDistance ... etc. One also might notice that MTL files exported by my OBJ + MTL exporter could have certain lines starting with Pbr_ which are intended for my custom MTLLoader and should normally be skipped by the ASSIMP library.

What seems to be working properly or to a high degree (new PBR additions):

What didn't work for me:

EDIT: The attached zip file was updated since my initial post, including some map names, resolving clearcoat textures issue I was having

All can be tested with my viewers and the attached pictures show the Anisotropy Barn Lamp example file, from the three.js repository, as it looks in my GLTF Viewer and after it was exported to OBJ + MTL format and then loaded in my ASSIMP Viewer.

Barn Lamp - GLTF

Barn Lamp - ASSIMP OBJ   MTL

OBJ & MTL - PBR Modifications 2.zip

GitHubDragonFly commented 1 year ago

Just as a further update, it is possible to improve the library to include iridescence material in OBJ + MTL, which can be seen in the attached picture of the IridescenceMetallicSpheres example.

This does require more significant changes to the library, other than updating just OBJ + MTL files, but would be library wide since it pertains to the glTF2 side.

This can be tested by following these instructions:

OBJ   MTL - Iridescence

GitHubDragonFly commented 1 year ago

All these material / glTF2 / OBJ updates are currently available in the updates branch of my Assimp fork.

@kimkulling , if there is any interest in any of these updates then I could submit a PR or somebody else could review & test all these changes and possibly grab them from my repository and include into the Assimp library.

OBJ + MTL updates are somewhat specific to my usage but are not off limits.

kimkulling commented 3 months ago

Would be great to get an update from you. Sorry for the late response. I just saw the message too late.

GitHubDragonFly commented 3 months ago

@kimkulling when it comes to this, I have finished updating on my end quite a while ago and not really looking to do any further updating.

You can check the updates branch I mentioned in my previous post and grab whatever you want from it. Maybe try compiling it as it is first, just for a test.

As for the custom stuff in the OBJ + MTL loading, there is a document that shows how I did this.

It works for me the way it is and it might not be in sync with any other library.

I would also suggest that you take your time and read anything ASSIMP related in my repository.