Facebook have released their new 3D post type allowing anyone to post detailed 3D objects for their followers to view and explore. But authoring to the native glTF file format employed by Facebook is a bit of a minefield for 3D artists at the moment and I’d like to share a production proven pipeline for authoring advanced glTF and GLB files, complete with metallic/roughness physically based shaders and materials with transparency, emission and ambient occlusion. Something that almost no one is doing with the format on Facebook right now.
The goal of this pipeline is to create a .glb file ready for direct upload to Facebook that is under 3MB (the maximum size accepted for 3D posts) and includes materials that have transparency, roughness maps, metallic maps, normal maps and emissive maps that all get respected and correctly rendered in Facebook.
One of the posts I created for AMC can be viewed on Facebook here: Hologram Projector
To use this method you will need:
- Autodesk Maya (or a trial if you don’t have access to Maya otherwise)
- Facebook’s free FBX2glTF command line format converter: https://github.com/facebookincubator/FBX2glTF/releases
- Another 3D package of your choosing if you don’t like modelling and texturing in Maya.
There are many ways of creating the .glb files you need to upload 3D objects directly to Facebook, I’ve explored almost all of them and none come close to working as well and producing .glb files within the 3MB limit as well as this method does. I’ve tried Blender and it’s 3rd party exporters, 3ds Max and it’s Babylon exporter, Modo and it’s native glTF exporter and all of them produce files far too large to be used or fail to produce a file that Facebook will accept without errors. Using FBX files from any package other than Maya fails to convert the shaders required for making advanced 3D posts with roughness, transparency, emission and ambient occlusion.
1: Get your model into Maya
If you’ve made your object in another package like C4D or 3ds Max, then the first step is to export an FBX file from this package and import it into Maya. You can do all of your modelling, UVW unwrapping and texturing in whatever package you like. You can even bake your lighting into your textures in your chosen package, just leave your materials and shader work for Maya as none of this will come through in your FBX export.
2: Make materials using Maya’s Stingray shader
The secret ingredient to this pipeline is Maya’s Stingray PBS. The only shader that gets included with your FBX export, gets converted in the FBX2glTF converter and has the capability of producing materials with roughness, metallic, normal and emissive maps.
Make a Stingray PBS material
Create your first Stingray PBS material by opening the Hypershade in Maya, look in the Create panel on the left and click on Stingray PBS.
Load in your texture maps into the correct slots
The first mistake most people will make is trying to load their diffuse map into the Base Color channel. The FBX2glTF converter will ignore this channel and you’ll end up with a black object. The correct way to load your maps is to first check all the boxes for the maps you wish to use for this material in the Attributes dropdown.
Then using the slots in the Textures dropdown, load your maps using the four square button to choose a file. For glTF you must use either .jpg or .png files for your textures. I recommend .jpg for any map that doesn’t require an alpha channel so you can save on file size. Do note that all your textures need to be sized at a power of 2 for them to work on Apple devices eg. 1024 x 1024, 512 x 256 etc.
All of these texture slots including ambient occlusion are supported by glTF and will be rendered correctly in Facebook. Once you’re done loading all your required maps, your Stingray node graph should look something like this.
The official glTF authoring guidelines show how you should make an ORM map or Occlusion/Roughness/Metalness map for these slots by packing those maps into the RGB channels of a single texture file. This would reduce file sizes for your textures and reduce draw calls for the renderer but not only did this not work well for me when exporting from Maya, it’s not actually required when using this method and the FBX2glTF tool seems to take care of this for us. So it’s perfectly fine to use separate roughness, metallic and ambient occlusion maps.
Make materials requiring transparency with lambert shaders
Since the Stingray PBS doesn’t support transparency in it’s own map slot we need to use a regular old lambert shader to make use of an alpha channel. The important thing to note here is that you MUST use a .png file with an alpha channel to use transparency, you cannot use a separate black and white map.
In the Hypershade create a lambert shader from the create panel and load your diffuse map into the Color channel. Now instead of plugging anything into the Transparency channel like you would normally do, you must take the Out Alpha of your texture node and plug it into the Matte Opacity channel of the material. Your node graph for these materials should look something like this.
You can also make use of the Incandescence channel to make emission like you would in a Stingray PBS material. This is how the hologram projection and rays were created for this 3D post:
3: Export an FBX file from Maya
Once you’ve created all your materials and applied them to your objects inside of Maya you can export your FBX file, ready to be converted into glTF. Go File -> Export All and select FBX as your file format. Go through and unselect unneeded export options like animation, cameras, lights and so on to make sure no extra information is included in the file. One important box to check though is Embed Media, this must be turned on to include your texture maps.
4: Convert your FBX to .glb
Now we can take this FBX file and use the command line FBX2glTF tool to create our Facebook ready file. The glTF format comes in two flavours, .glTF and the binary form .glb. Facebook requires the binary .glb form. Make sure you’ve installed FBX2glTF from the link at the beginning of the tutorial if you’re on Mac (use the darwin download) and if you’re on Windows make sure you have the program downloaded.
On a Mac
Open a Terminal window and navigate to your FBX file. If you’re not familiar with Terminal usage then drop your FBX file on your desktop and use the command:
cd Desktop
This should navigate you to your desktop. Now type this command to create a .glb file, replace the filename with the name of your FBX file.
FBX2glTF your-file-name-here.fbx -b
Once you hit enter, your .glb file will appear in the same directory.
On Windows
Right click on the downloaded .exe file and go to Send To -> Desktop (create shortcut). Once you have a shortcut on your desktop, right click on the shortcut and go to it’s properties. Here you need to adjust the target by adding ” -b” to the end. That’s one space and then -b like so.
Now you can simply drag your FBX file onto this shortcut and a .glb will be made in the location of the original .exe file. For instance if that’s in your Downloads, then the .glb will appear there. You can keep dragging FBX files on this shortcut and it will keep making .glb files for you as long as the original .exe remains.
5: Upload to Facebook
Finally you can upload your .glb to Facebook directly and post it for all to see. In your Facebook feed click on the “What’s on your mind” box to begin creating a new post. You must do this before attempting to upload a .glb or Facebook will not recognise it and your browser will simply redownload the file you’re trying to upload.
Once you’ve started making a new post, you can simply drag the .glb file onto the new post panel and it will accept it. Choose your background from Facebook’s selection (you can’t use your own yet) and post your 3D object to Facebook!
Be sure to test your post on both desktop and mobile to check for issues. You may have some small niggles with alpha channels on mobile that change how you approach certain objects. For instance the text here was made using geometry instead of a plane as the plane became visible on mobile even with a full alpha channel. Emission also tends to be more extreme on mobile than on desktop.
Good luck on creating your Facebook 3D posts! I hope this tutorial has helped you overcome any issues you may have been having creating .glb files.
Joesphsnalf
Hey everyone! Just wanted to pop in and share some exciting news—I’ve just introduced my own drywall repair business right here in beautiful California! рџЏ–пёЏ With the sea breeze in the sky and the sun radiating down, there’s not ever been a more suitable time to ensure your home’s walls are in excellent condition. Our group focuses in coastal properties, so whether you’re managing with damage and tear from the salty air or need some expert fixes after a storm, we’ve got you protected. Can’t wait to help homeowners all over the coast with their drywall needs! Feel open to reach out if you have any questions or want a quote. Let’s keep those walls looking immaculate! рџЉ