GLB Considerations
This page goes into how to create GLB Materials in Blender including ways to optimise texture to export as glbs...
GLB assets have certain things to do in order to have textured materials appear how you want within Unity. This document will go over different material setups using the Blender Node graph.
For more information you can go to the Blender documentation.
All of the following material examples are created in the Blender 'Shading' menu at the top of the window. You'll have your File Browser (Top left), 3D viewport (Top Middle), the Image Editor (Bottom left), and the Shader Editor (Bottom middle). Along with the Outliner and Properties tabs to the right.
Make sure that the Render Mode is set to Material or Rendered at the top right of the 3D Viewport so you can see the results as you update the node graph.
Make sure that the material that you are modifying is selected as well in the Material Properties panel after you have selected the asset that uses it.
Diffuse + Normal Map
The most common type of material would be a Diffuse, also known as color or Albedo, for color and a Normal map which offers bump details on your asset. You could also skip either of these if you don't want to use it. Note that the Normal map texture requires a specific Normal Map node to work correctly.
Adding a Diffuse Texture
In the Shader Editor at the bottom, go to the 'Add / Texture / Image Texture' menu , use 'Shift + A', or Right click on the Shader graph background, to add an Image Texture node. Move it to where you like and left click to place it.
Use the 'Open' button to load your desired diffuse texture from your computer.
Make sure it is the correct size. For important assets we recommend 1024x1024 or less, for smaller assets use 512x512 or less.
Connect the yellow 'Color' dot on the 'Image Texture' node to the Yellow color dot on the 'Color' Parameter on the 'Principled BSDF' node.
Adding a Normal Map Texture
Either add another 'Image Texture' Node, or select the previous one and use 'Shift + D' to duplicate it.
Use the 'Open' button to load your desired normal map texture from your computer.
Make sure the texture resolution is as small as possible. For important assets we recommend 1024x1024 or less, for smaller assets use 512x512 or less.
Add a 'Vector/Normal Map' mode from the Add menu or 'Shift + A' hotkey.
Connect the Yellow 'Color' dot on the 'Image Texture' node to the Yellow color dot on the 'Color' Parameter on the 'Normal Map' node.
Connect the purple Color dot on the 'Normal Map' node to the Purple color dot on the 'Normal' Parameter on the 'Principled BSDF' node.
Change the 'Color Space' parametter from sRGB to 'Non-Color'.
Metallic and Smoothness
GLB/GLTF has specific requirements for texture use much like the Unity Standard Materials shader.
When it comes to Smoothness, GLB actually uses Roughness instead. So White on the texture makes the asset not smooth, and Black on the texture is very smooth and polished.
Both Metallic and Roughness are combined into one texture :
Roughness - Green channel.
Metallic - Blue channel.
With your textures created in your texture creation tool (such as photoshop or substance Painter) :
Load the Image Texture node with your Roughness Metallic texture.
Add a 'Converter/Separate Color' node and connect your image texture
Make sure to set the Roughness/Metallic node 'Color Space' parameter to 'Non-Color'.
Connect the Green channel to Roughness
Connect the Blue Channel to Metallic.
Using Alpha as transparency
It is possible to use transparency by setting the 'Materials Properties / Settings / Blend Mode' to 'Alpha Blend' shown below with the green box under 'Backface Culling'.
It is best to have Backface Culling enabled. If Backface Culling is disabled you will have semi translucent results even where it should be solid.
If you are having issues with your assets transparency as one material, you may need to split the Transparency and Opaque areas of your asset into two separate materials.
Double Sided materials
If you want your material to show the texture on the front and the back, you can enable/disable Backface Culling to do so. You can find this setting in the Material properties / Settings section.
Emissive textures
It is possible to use emissive textures on your asset but the bloom effect within Mona (the glow effect on Unity materials with high emissive strength) will not be applied for now. That said you can use the emissive channel to apply bright areas on your asset.
You can either change the color property, or set the Color parameter to its own emissive texture.
Mirrored Polygons & Overlapping UVs
Depending on how you are creating and optimising your asset you may be using Mirrored assets and/or Overlapping UVs. If these assets are placed in Unity you may find there are some issues with the mirrored/overlapped UV polygons as a GLB, whereas an FBX would work without issue.
One approach around this is :
Import your asset as an FBX into Unity so that the mirrored/overlapping UV polygons look correct.
Add the GLTFast Package, this is covered in Useful Unity Packages.
Export the FBX as a GLB from the 'Gameobject / Export GLTF / GLTF-Binary (.GLB)' menu.
Import this GLB into Blender and update all the Maps with your original textures, as exporting from Unity as GLB seems to reduce the quality of the textures.
Make sure to update the 'Color Space' property to 'Non-Color' in the texture node on the Normal, Metallic/Roughness, and Emissive texture. This can be found under the Shading category at the top.
Reimport your asset into Unity to see the result.
Troubleshooting
Materials don't look right...
A common issue is that in some cases the material doesn't look correct in comparison to the settings of the material. eg. The material looks matte where the roughness/metallic settings imply otherwise. Make sure that the Specularity parameter is set to non zero in Blender, this may apply to other parameters as well.
Opacity looks broken...
A pretty common issue is with Opacity settings making the asset look broken. First, make sure that the Opacity Blend Mode is set to Alpha Blend, and that Backface Culling is on. If this still doesn't work, you may need to separate the opaque material and the transparent material into two differnt materials so there are no conflicts between the two material types.
Summary
As always it is better to use less textures as possible, both in number and in filesize. So if you can use a parameter on its own rather than a texture channel, don't use the texture to create the result.
Last updated