Converting 3D .glt objects?
April 4, 2021 5:26 AM   Subscribe

What is the best way to convert some 3D objects that are in the .glt (GLTF) format so that I can use them as .OBJ files (or other compatible format) in Unity?

I gather so far that I need to convert them from a format that bundles the textures into a single file to one like Wavefront OBJ in which the textures live in separate files.

Hoping to avoid lossiness, and also to perform the conversion offline rather than through an online converter tool. A little confused by all the options out there though.

Any help much appreciated. Can do either Mac or Windows.
posted by johngoren to Computers & Internet (6 answers total)
Not quite what you're asking for, but Khronos Group provides pretty good tooling for GLTF. One option is their Unity integration, which will allow you to load GLTF inside the editor at design time, or in your build at runtime. I think it can also export to other formats, but I have not used that feature. It's been 2 or 3 years since I used this but it worked extremely well on a project that used a lot of GLTF (actually 3dtiles, which is gltf + geospatial info).

If you absolutely don't want to have your gltfs touch Unity, they also provide a Blender plugin (once you're in Blender you can export whatever you want).

One challenge for you is that gltf specifies a bunch of things that OBJ doesn't necessarily support, like animation, etc. You may want to use fbx or collada as an interchange format (they support more metadata like animations, bone weight, etc) or just stick with gltf.
posted by Alterscape at 7:09 AM on April 4, 2021

There's another plugin that I've used available here: - if you open the package manager in Unity, press the + icon and choose "Add Package from Git URL" and enter the url it should just work and load any gltf format files you drop into your project.

Depending on what features your GLTF files use one or the other plugin might be better, I'm sure they will both handle plain textured models fine.
posted by samj at 8:05 AM on April 4, 2021 [1 favorite]

Response by poster: Thanks for the helpful answers. Up til now I’ve managed to extract the files from Blender, but got stuck trying to reunite the objects with the textures (which I was surprised were not named as filenames in the .mtl materials.)
posted by johngoren at 10:40 AM on April 4, 2021

Once you've got the GLTF open in Blender, I believe you can access the maps through the Blender Image Viewer (the same view one uses for UV unwrapping, etc). From there, you can Image->Save As.. to save as a separate image on disk, and update the material in Blender to point to the map on disk rather than the embedded GLTF. This may be painful for more than a few models, but Blender has very deep integration with Python so I imagine you could write a Python script to repeat this process automatically.

Looks like AssImp also supports GLTF, so if C/C++ is more your speed you could probably also write code to do the same "import, extract textures, re-connect materials, export as obj/fbx/whatever" process with that.

I'm a bit surprised there isn't a command-line tool available for gltf/glb to obj. I think what I was using was this Cesium-supported library/tool in my workflows back then, which will separate maps from a glb/gltf, but won't convert back to OBJ or another non-gltf format.
posted by Alterscape at 10:56 AM on April 4, 2021

Response by poster: Update on this. I've been trying these options but running into a few different obstacles, including my Blender ignorance.

UnityGLTF seems really good, but I'm having trouble setting it up for use. The README setup instructions are sparse and I think outdated, referring to some directory I can't seem to find in the downloadable resources. I found some other instructions in a pull request, but couldn't get those to work either.

GLTFUtility brought the object into Unity but with an all-pink texture instead of the texture files...

The Blender Image Viewer solution seems most promising but I'll have to look up how to change the material path so that it points to disk, because the mysterious Blender interface is confusing me...

If I just set filenames for graphics on the .mtl entries, maybe that will work? Only I'm not sure when I should use which categories of map (map_kd, map_ka...)...
posted by johngoren at 3:48 AM on April 5, 2021

Hm are the gltf files definitely good - do they look ok if you drop them into this:

If it's not many files then you could consider recreating the material in unity, as long as you can extract all the maps you should be able to match things up.
posted by samj at 6:45 AM on April 6, 2021

« Older How can a new immigrant build a network in Canada?   |   Fixing FM-band RFI from homebuilt desktop PC Newer »
This thread is closed to new comments.