assimp icon indicating copy to clipboard operation
assimp copied to clipboard

OBJ + MTL Loaders - work with PBR materials

Open GitHubDragonFly opened this issue 2 years ago • 4 comments
trafficstars

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):

  • Sheen, sheen roughness, sheenColorMap (map_Psc) / sheenRoughnessMap (map_Psr), clearcoat, clearcoatMap (map_Pcc) / clearcoatNormalMap (map_Pcn) / clearcoatRoughnessMap (map_Pcr), transmission, transmissionMap (map_Ptr), thickness, thicknessMap (map_Pth), attenuationColor, attenuationDistance

What didn't work for me:

  • map_Pm and map_Pr textures were never set so I used textureRMA instead

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 avatar Sep 26 '23 23:09 GitHubDragonFly

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:

  • Use my GLTF Viewer to load the original GLTF file via the viewer's URL option where you could enter the following url:
    • https://github.com/KhronosGroup/glTF-Sample-Models/blob/master/2.0/IridescenceMetallicSpheres/glTF/IridescenceMetallicSpheres.gltf
  • Use the viewer's OBJ export option to get OBJ + MTL + texture in a zip file
  • Extract all the files to a folder on your device (this needs to be done since my viewers currently don't support loading of zip files)
  • Use my ASSIMP Viewer's Browse option to load these extracted files all at once - your device will have to allow loading local files
  • After the model is loaded then make sure to check the Eq box in the viewer to get the environment texture / lights

OBJ   MTL - Iridescence

GitHubDragonFly avatar Sep 30 '23 04:09 GitHubDragonFly

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.

GitHubDragonFly avatar Oct 02 '23 01:10 GitHubDragonFly

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

kimkulling avatar Aug 02 '24 16:08 kimkulling

@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.

GitHubDragonFly avatar Aug 02 '24 21:08 GitHubDragonFly

OBJ import issues tracked via epic #6179

tellypresence avatar May 14 '25 15:05 tellypresence