-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Obj2Gltf doesn't always convert materials #27
Comments
Sorry for the hassle. The OBJ-to-glTF-conversion currently only transfers the texture information. The point is: MTL files may contain really complex material definitions. There is a branch of the OBJ library where the support for MTL has been extended to cover (nearly?) everything that is supported by MTL. Translating this information into the "most appropriate" glTF PBR material is far from trivial. I agree that as a starter, I could just dump the diffuse colors ( |
I did what you described in your last paragraph and that got me rolling. I'll try the So, I'm good, now. Once I try the Thank you for the quick response. |
Admittedly, I'm a bit surprised to hear that this is "resolved" now. Did you add some sort of translation logic near https://github.com/javagl/JglTF/blob/master/jgltf-obj/src/main/java/de/javagl/jgltf/obj/v2/MtlMaterialHandlerV2.java#L68 ? I think that's the point where the MTL could be examined further: If it has a I'm not sure how well an MTL could map to a PBR at all. Some contortions might be justifiable, e.g. mapping the "shininess" to "metallicFactor" or so. But all this would have to be verified with a glTF PBR renderer that is much more powerful and closer to the intended behavior than what JglTF currently supports (the renderer is, indeed, only a very basic one, and it's a bit unfortunate that I did not continue the development there for a while now...). And after all, the translation will become a real challenge when the different possible textures that may be contained in an MTL come into play. Suggestions (or pull requests) are welcome, of course! |
Well I closed it, since it isn't an issue for me anymore. There is a glTF extension you can declare that tells renderers that you've defined classic material values, rather than PBR materials. I don't know the extension name off-hand, nor do I know how to tell this API to use that extension. My need is not photorealistic, so I closed it, and with my comment now, it will reopen, and I'll leave it open. |
There's the Leaving the issue open until the MTL-to-glTF-PBR translation is extended to at least a "more reasonable" state is fine. I hope that I can allocate some more time for this soon... |
Related question - I'm not using textures at all. Is there a straightforward way to use diffuse/specular colors in a basecolor/metallic system like glTF uses? I just want to convert the colors & specular data into a PBR workflow. I understand that textures require a lot of work, and I'm hoping that plain colors do not. Thanks. |
As already mentioned above: I think that it should be possible to obtain the Currently, it exports materials that do not have a diffuse texture as uniformly gray. Passing in the If this doesn't work for you, I could try to do some basic test this weekend (something similar would have to be a small building block of a more sophisticated MTL-to-PBR-translation anyhow...) |
OK, that's what I thought. I was hoping that the "far from trivial" stuff you mentioned earlier only applied to textures, and that simple colors were more straightforward. You don't need to work on that or anything else for me, the change you suggested did work. Of course the colors are "different" in glTF viewers because of PBR, but that doesn't matter in my circumstances. This library does everything I need of it. Thank you for your work on it, and thanks again for your help. |
Regarding conversion of materials, I found this, which may be of interest to you. I can't find it again, now, but the link to this was presented alongside a viewer which showed the old material format compared alongside the converted, and they looked identical, as far as my eyes could tell. Maybe this will help you in your material conversion efforts. |
Thanks @naikrovek . Some snippets from that might be helpful, but the particular functions there are mainly intended for the conversion between the "default" glTF PBR mode (Metallic-Roughness) and the Specular-Glossiness model from the extension at https://github.com/KhronosGroup/glTF/tree/master/extensions/2.0/Khronos/KHR_materials_pbrSpecularGlossiness . The models are quite similar (they basically contain the same information, in a slightly different representation), so the conversion is a bit simpler than that of creating a PBR model from OBJ. |
Ah. I thought the Specular-Glossiness model was the "old" way that materials have been defined in the past before PBR came around. I have more to learn. |
A very basic extension of the translation from MTL to PBR was done in 2470c78 . It will have to be extended after the extended MTL support is part of a released version of the OBJ library. |
I've spent some time trying to get this library to use the proper materials in the glTF files it creates, without success. I decided to do a sanity check and attempt to use
Obj2Gltf
to convert a.obj
created with this library to glTF and see if materials were imported. To my surprise, they were not.Every OBJ viewer I have tried loads the materials properly. The materials, in this case, are just some colors, and not any textures. The materials are stored in a
.mtl
file with the same basename and path as the.obj
file.If you would like the files I am using, please let me know.
The text was updated successfully, but these errors were encountered: