Baking PBR Materials to Textures from Blender to Unity

Multiple Materials to Baked Textures

Until now the planes in Happy Dogfights were made of multiple materials so that it was easy to change the colour of the plane in Unity. When a player selects a colour, I just modify the colour of the material used for the body of the plane. It also made sense when working in Blender to have a different material for the tyres, the body, the engine, etc, so that I could control their metalness, roughness, and colour independently.

4color

However, this method has its limitations:

  • it is not optimal in terms of real-time rendering
  • I could not apply surface shaders VFX, like flame or electricity effects, on the plane.
  • the PBR parameters (e.g. colour, roughness, metalness, emission) were not imported by Unity, I had to enter them manually
  • I could not use complex procedural materials in Blender (as I could not export them)

A better but more involved method is to unwrap the plane’s UV and bake all the materials into PBR textures so that the plane only use one material.

This way I could benefit from:

  • better performance using a unique material for the plane
  • an automatic import of the PBR parameters (colour, roughness, etc) as they are saved in a texture
  • surface shader VFX as the UVs are unwrapped
  • I can work with multiple and procedural materials in Blender

But for that to happen, I needed to find a way to bake the materials!

In this tutorial, I am covering that problem: how to bake multiple procedural materials into textures in Blender, in a way that is compatible with Unity. In a future tutorial, I will cover how to change the colour of the plane when its colour information is stored in a texture.

Step by Step Tutorial

  1. Get the Free and Open Source add-on of Daniel Enger.

  2. Install the Add-on:

    • In Blender, go in Edit > Preferences > Add-ons, click Install...,

    • find the zip file you just downloaded, click Install Add-on.

  3. Find the Add-on:

    image-20200606154340911

    • Go to the Shading tab, hover the mouse over the Shader Editor, and press N ,
    • Click on the tab Principled Baker
  4. Use the Add-on:

    • Select the object to bakedimage-20200606154214947

    • Deselect Autodetect, tick Color, Metallic and Roughness.

      image-20200606162743678

    • In Additional Bake Types, tick Glossiness, this is what Unity calls Smoothness (i.e. 1 - roughness)

    • Scroll down and find Combine Channel, and click + (in Unity, the metal map includes the roughness map as alpha channel)

    • Set the Channels as follow:

      image-20200606163923937

    • Scroll up and click bake!

Now if you export the plane as FBX without materials and import it in Unity. Create a material where you use the colour texture as a base map, and the combined texture as a metallic map.

image-20200612122542943

You should get your object with the materials looking as they do in Blender.

image-20200606185940453

Next Steps

Now that the different colours of the plane are contained in a texture, it will be more complicated to change its colour 😅 but worry not, the problem can be solved with a custom shader, and it is easy to implement with the Graph Shader. See you around!


Also in Recent Posts

comments powered by Disqus