How to convert a 3D object to ".glTF" (Blender 2.80)¶
If you have an ".obj" file or another 3D format object and want to convert it to ".glTF", there is a way to do it with Blender.
About Blender's latest version
Blender 2.80 is the latest version of Blender, which is really good. However, if you prefer staying on Blender 2.79, go to this tutorial.
1.1. If you don't have Blender, go and download the latest version (2.80, or later the orange button) on https://www.blender.org/download.
1.2. Open Blender. If you have a cube in the scene, select it by clicking on it and delete it by pressing "Delete" on your keyboard.
1.3. Then import your object by going to "File / Import" and choose ".obj" (or the format of your object). You should soon see your object in the viewport.
1.4. Select your object by clicking on it (it should be outlined in yellow).
1.5. Open the Shader Editor in the window below the viewport. To open the Shader Editor, you must first drag up the lower window.
1.6. Then click on the lowest-left button and choose "Shader Editor".
1.7. Normally, you should see your materials and textures already settled. In that case you can go straight to Section 3 "Export your object to ".glTF"". If that's not the case, then go to Section 2 "Set materials" below.
2.1. If you don't have any materials on your object, start by checking that "Use Nodes" is toggled.
2.2. To see your materials in real time, don't forget to activate the "Look Dev" mode that you can find on the top right-hand side of the viewport.
We noticed some troubles with Blender 2.80 rendereing system. That is why sometimes the new rendering engine, Eevee, doesn't render right (totally dark objects, visual artefacts...). If that happens to you, try the button next to "Look Dev"(on the right), which is "Rendered". If that doesn't solve your problem, try to switch to Cycles engine in the render options. For more information about this, feel free to check that video by Blender Guru.
2.3. If you want to reset all your textures for some reason, or that you don't understand how Blender has interpreted your material, it might be best to make your material again from scratch. To do that, go to the "Material" panel.
2.4. In the "Material" panel, delete the current material (if there is any) by clicking on the "-".
2.5. Click on "New" to create another material.
2.6. In the Shader Editor, you should now see a "Principled BSDF" node connected to the "Material Output". This node is basically the most complete shader in Blender, which enables you to create all types of shaders from glass to metal to plastic to silk. But for now, it doesn't have an input for Ambient Occlusion. That's why we are going to need another special shader.
2.7. Go download the "glTF-Blender-Exporter" on https://github.com/KhronosGroup/glTF-Blender-Exporter.
2.8. Unzip the addon you have just downloaded and remember the path.
2.9. In Blender 2.80, go to "File / Link".
2.10. In the browse bar, navigate to your unzipped addon, and follow that path :
glTF-Blender-Exporter-master\pbr_node\glTF2.blend\NodeTree. There, you should have a list, and you must click on "glTF Metallic Roughness". Then click on "Link from Library" on the top right corner.
2.11. In the Shader Editor, delete the "Principled BSDF" node, and type "Shift + A", go to "Group" and choose "glTF Metallic Roughness". You can also find that node by going to "Add / Group", next to the "Use Nodes" option.
2.12. Now you have to connect the "glTF Metallic Roughness" node to the "Surface" input of the "Material Ouput" node. To do that, click on the green dot next to the "Shader" output of the "glTF Metallic Roughness" node, and don't release your click. Now, as you drag your cursor away from the green dot, you can see a little white string attached to the "Shader" output. Just drag it over to the "Surface" input of the "Material Output" node, and release. Here you are! You have successfully connected your shader to the "Material Output" which will compile it.
2.13. Now we have to load the textures into the Shader Editor and attach them to the "glTF Metallic Roughness" node. There are two ways to do that. The first way is simply to drag and drop your texture from your computer in the Shader Editor (one at a time).
2.14. The second way is to type "Shift + A" and choose "Search". Write "Image Texture" in the search bar and click on "Image Texture" in the list below.
2.15. Click on "Open" and load your first texture.
2.16. Navigate to your texture folder and choose the first one you want to connect, for instance the Base Color (or Diffuse, or Albedo).
2.17. You then have to connect your diffuse texture to the "BaseColor" input of the "glTF Metallic Roughness" node.
2.18. For your Normal Map, don't forget to turn on the "Non-Color Data" mode, then connect it to the "Normal" input of the "glTF Metallic Roughness" node.
2.19. You might have an ORM map, which is a map which contains a specific map in each channel: Ambient Occlusion in the red channel, Roughness in the green one, and Metallic in the blue one. This method has been advised by the Khronos Group, creator of the ".glTF" format. Check that your map is in "Non-Color Data" mode, then plug it once in the "MetallicRoughness" input, and once in the "Occlusion" one.
Creating an ORM map
If you don't have an ORM and that your Occlusion, Metallic and Roughness textures are separated, please turn them into an ORM by following the steps given in https://www.khronos.org/blog/art-pipeline-for-glTF.
Currently, metallic maps do not render too well in Minsar Studio because there isn't anything to reflect in the Minsar Studio world (no skybox for instance). We are working on it.
Export your object to .glTF¶
3.1. You're all set! Now you just have to export your model in ".glTF". To do that, just click on your model in the 3D view, and go to "Files / Export" and choose ".glTF 2.0".
3.2. The export window will appear. On the left-hand side, you have some options for your export. In "Format", you can choose to pack all your files in a ".glb format" (glTF Binary), or export only the ".glTF object", or at last export the ".glTF object and all its textures". That's up to you! Don't forget to check the "Selected Objects" box just to be sure you don't end up with undesired items.
3.3. Once your choices are made, you just have to choose the folder in which you want to export your object, and click on "glTF 2.0" on the top right-hand side!
You have successuflly converted your object in ".glTF"!