How to make a .glTF model for Facebook tutorial

Posted on Mar 25, 2018

Facebook since February 2018 allows .glTF models. glTF is a 3D format. For now it allows clicking and dragging and that’s it, but it will get more advanced over time.

 

What we need:

  1. Blender, a free, open source 3D program.
  2. The Blender > .glTF exporter.

1. How to install Blender and the Blender > .glTF exporter

How to Download Blender

Downloading Blender

Go to blender.org and click the big download button. Open the installer and follow the instructions.

 

Downloading the Blender > .glTF exporter

How to download the Blender .glTF exporter

1. Go to the Blender > .glTF exporter website and click the link “download the exporter”. It will prompt you to download “glTF-Blender-Exporter-master.zip”. Download and unzip it.

2. Open the “glTF-Blender-Exporter-master” folder you just unzipped. Then “scripts” and “addons”. Compress “io_scene_gltf2” to a zip file.

Blender Splash Screen

Blender User Preferences

2. Open Blender. On the top left there’s a menubar. Click “File”, then “User Preferences”. A dialog will open. Select the tab “Add-ons”. Finally click the button “Install Add-on from file”.Install Add-on Blender .glTF Exporter

3. An “open file” dialog will open. Go to the folder “glTF-Blender-Exporter-master” you just unzipped. Click on subfolder “scripts”, then “addons” and finally click the “io_scene_glTF2.zip” file we’ve made on step 2. Click “Install Add-on from file”

4. Well done, you’ve installed the addon! It should appear a new option called”Import-Export: glTF 2.0 format”. Click on the checkbox on the side to enable it and save the settings.

 

 

2. How to create a 3D model and export it in .glb format for Facebook

 

If you already know how to use Blender
Export your models as usual via “File” > “Export” > “.glTF 2.0 .glb”. However materials won’t export just as easily. If you have any doubts refer to “Assigning a material” section.

 

Creating an Earth 3D model

1. Delete the default cube by pressing the delete button “Del” or “Supr”. In the bottom menubar you will find a button called “Add”, A contextual menu will appear. Click “Mesh”, then “Sphere”. That’s it. We only have to texture it and give it a material.

2. Clicking “Shading” > “Smooth” in the left panel will smooth the faces of the 3D model.

We need a square “power of 2” sized texture.

3. Download an “earth texture” (hint: first result on Google). Open it on your favorite photo editing program. Resize it to one of the following sizes: 128x128px, 256x256px, 512x512px, 1024x1024px, 2048x2048px, 4096x4096px, 8192x8192px. (hint: these are sizes that are powers of 2. You can choose any other size as long as it’s a power of 2).

4. Back into Blender switch to “Edit Mode”.

Shading UVs

5. In the left panel, click on the tab “Shading/UVs” and then the button called “Unwrap”. As it’s a default model there’s already a premade unwrap option, click “Sphere Projection”.

 

 

What’s unwrapping?

Let’s imagine we grab an inflatable planet and stick a pin into it. As we unfold it we’ll notice that it was a flat surface, arranged in a way to make it as a three dimensional object. Likewise, when we “unwrap” an object we are “unfolding” a 3D model in a flat surface so we can stick an image texture into it.

UV Unwrapping Example. Source: Wikipedia
UV Unwrapping Example. Source: Wikipedia

UV Unwrapping Example. Source: Wikipedia

 

You will use this button a lot.

6. Switch to “UV/Image Editor” by clicking the button on the bottom left corner.

Scaling the mesh

7. Click “Open” and load your texture. Adjust it by pressing “S” to scale or “G” to drag, followed by “X” or “Y” to lock it in the X or Y axis. For example “S” > “Y” will scale only in the Y axis.

7. Go back to the “3D Mode”. Switch to the “Texture” mode. You will see the sphere with the texture.


8. To adjust the rotation of the mesh go to “Object mode” and press “R”, then use the mouse to adjust.

3. Assigning a material

Blender uses a material system that isn’t compatible with glTF. Fortunately most of the work is already done.

1. Go to “File” > “Link” and open the “glTF-Blender-Exporter-Master” folder. Click “pbr_node” and then “glTF2.blend”. Next, click “NodeTree” and finally “glTF Metallic Roughness”. Finish by clicking “Link”.What we’ve done was to link the glTF material from “glTF2.blend”. If that file gets updated so does our linked material. The same if the file is deleted.

2. Switch render engine. Click “Blender Render” button and switch to “Cycles Render”.

3. Switch to “Node Editor”. Click “New” and assign a name.

4. Click “Add” > “Group” > “glTF Metallic Roughness”. Left click anywhere to place the node.

5. Click “Add” > “Search”. Search “Texture Coordinate”. Click it and place the node.
Do the same with “Image Texture” node.

6. Now we have to connect the nodes to create our material. From “Texture coordinate” click the “UV” point and connect (drag) it to the “Vector” point of “Image Texture”.
Then click the box next to “Object:” and select “Sphere”.

7. On “Image Texture” open the texture you used for unwrap. Click the “Color” point and connect it to the “Base Color” point of “glTF Metallic Roughness”.

8. In “glTF Metallic Roughness” connect “Shader” and “Surface” output.

4. Exporting

1. Click “File” > “Export” > “glTF2.0 .glb”

5. Uploading to Facebook

1. Open Facebook.
2. Click in the textarea to write a new status.
3. Drag the .glb file we’ve just created. Done!

Other material options

 

 

 

Adjust the materials glossiness and roughness

Roughness and metallic set to 0.

Adjust the “Metallic” and “Roughness” of “glTF Metallic Roughness” by clicking and dragging to adjust the glossiness of the material.

 

 

 

 

No texture, just a color

Setting “Base Color Factor” to red will result in a red model.

Don’t use “Image Texture” and “Texture Coordinate”. In “glTF Metallic Roughness” just click on the color of “Base Color Factor” and adjust it to your liking

Share on