PBR Texture Bakery (for Cycles)

by Daniel Mo in Scripts and Addons

Bake Cycles-Materials to textures!

The PBR Texture Bakery is an addon for Blender that allows you to bake complex Cycles-materials to PBR-textures. The approach is similar to what Substance Painter does: You are able to use a powerful material-node system to create complex materials and finally bake them down to textures. The baked textures will (almost) produce the same results like your complex Blender-materials do if you use them in a PBR metallic-workflow (e.g. in game-engines) because the bakery is based on the Principled BSDF (PBR shader). It also comes around with some useful tools like texture channel packing (e.g. UE4, Unity, Sketchfab ...), texture-transfer from one UVMap to another, a powerfull all-in-one shader node etc. This closes the gab in Blender when it comes to PBR-texture baking.

I used the bakery to combine multiple individual meshes into one when i created this model:
https://skfb.ly/6wQ79

What can it do specifically?

  • Bakes Cycles-materials for a PBR metallness-workflow
    • Albedo
    • Normal
    • Roughness
    • Metallic
    • Specular
    • Emission
    • Ambient Occlusion
    • Sub Surface Scattering Color
    • Sub Surface Scattering Mask
    • Refractionmask 
    • Alphamask
  • Export textures to specific platform targets (Channel Packing)
    • Default with OpenGL Normals
    • Default with DirectX Normals (inverted green channel)
    • UE4 (MRO channel packing)
    • Unity (Metallic/Softness packing)
    • Sketchfab
  • Bakes textures in different resolutions 32 x 32 - 8192 x 8192
  • Bakes objects with multiple materials from individual UVMaps to one texture-atlas
  • Possible to transfer textures from one UVMap to another UVMap
  • Possible to exclude certain faces from baking
  • Bakes also flipped and overlapping UVs like a charm!
  • Possible to export every baked texture at the same time
  • Export meshes with bakery
  • Non destructive workflow


    Example - Bake Cycles-material to PBR Texture
    Frozen Eye: Object consists of 3 separate meshes. Each one has its own UVs and materials. Exporting textures for PBR would be really tedious. The bakery simplifies this drastically ...


How does it improve your texturing- and optimization workflow?
There are multiple scenarios which can be improved by the bakery:

#1 Reallife - Scenario: Baking Cycles-Materials to PBR - textures
If you create more complex materials in blender Cycles and you want to put them into a game-engine or bring them to another render-engine you have to do at least 1 thing: create appropriate textures that can be read and handled in the shaders of the destinating render-engine. In Blender you must bake them by hand - one by one which can become very tideous and time consuming. The baking process of the PBR Texture Bakery does it automatically for you for each texture with one click :) ... 

#2 Reallife - Scenario: Transfer textures from one UV-map to another:
If you have an object that is already fully unwrapped and textured, you may want to create a complete new UV layout for this object and transfer the current textures from it's current UV-layout to another one (especially when you join multiple objects into one).

Combining Scenario #1 and Scenario #2 would look like this:
#3 Reallife - Scenario: Optimize textures by combining multiple objects/textures into one
Say you create certain props for ingame indiviually - Maybe some shoes, pants and a t-shirt. You baked some normals for those objects and created more or less complex materials/textures to make them look really nice (either in Blender or any 3rd party tools like Quixel or Substance Painter). That way you end up with 3 individual objects with individual UV-maps. That means you either need 3 materials in your render-engine for each object or you join them into one big object and serve all 3 UV-maps from one shader. Serving 3 UV-Maps from one shader is possible without too much performance-loss so this can be tolerated  ... But in both cases you need 3 sets of PBR-textures (maybe one texture for albedo, normals and roughness/metallic) - you need at least 9 textures (probably more) for your object ... Even this can be fine because there might be not a huge difference if you use multiple small textures or one bigger texture atlas ...

But - Using multiple UV-maps for this purpose can involve you in trouble: UE4 supports up to 8 UV-channels. One channel is used for the lightmap. So you can use 7 UV-channels for your various objects. If you join more than 7 objects together with everyone having its own UVMap (so you would need more than 7 UV-maps) you are out of luck because it is simply not possible (... without customizing UE4 shaders). In Unity it is way worse since it's shaders only support 2 UV-channels per vertex by default or up to 4 UV-channels if you write own CG-shaders (again one for the lightmap). 

In addition to those problems, you always have to fiddle around with a lot of textures. If you want to update them, you either have a really good update-process or it becomes really tedious if you do it by hand (well 7 objects - at least 3 textures per object = at least 21 textures plus several LODs ... this is ridiculous)

How to solve this problem?

The best thing to do is to clean things up and join those multiple objects (e.g. shoes, pants, t-shirt) into one object (let's call it outfit1), repack your UVs on a new UV-map (atlas) and bake all the textures (respectivley materials) from the previous UVs onto this new UV-atlas. That way you end up with one huge object (outfit1) and one UV-map (atlas) that combines every texture on one single texture-atlas. And that is what the Bakery enables you to do :)  ... This image illustrates this specific workflow:


How it works (for those who are interested in some technical details)
The PBR Texture Bakery can only work with a specific material setup - the Bakery-material. That means all the materials assigned to an object you want to bake textures from must be Bakery-materials. Basically it is just a standard Cycles-material but with a specific arrangement of nodes. This is important because the bakery reads these shader-nodes and converts the whole material into a bakable pendant. If it is not a Bakery-material, it will not work. This is the only limitation you must always have in mind while creating materials that shall be baked by the bakery ...

But don't panic: This Bakery-material is very flexible, easy to use and offers almost everything you need.

Basically the PBR Texture Bakery reads a material's node-tree and recursively rewires an arbitary number of Principled BSDFs and MixShaders etc. in the way Cylces need it to bake things. For Example: If we want to bake the albedo, the bakery creates an emission-shader node, an image-texture node, hooks the emission to the material-output,  assignes a newly created texture to the image-texture node and sets it to active. Then it hooks the Base Color - input node of the Principled BSDF to the emission's Color input. After that the bakery triggers the regular Bake-process (Emit) and the albedo becomes baked to the newly created images via the emission-shader.

It is doing it recursively with an arbitary number of Principled BSDFs per material. This also works with multiple materials on one object. The bake-process also involves the mix shader-blendings while doing it. More or less that way every texture is created.

Let's dig right into it!
Of course this information does not tell you how to use the bakery in detail. Please watch the Documentation-tab to get detailed information about it's specific usage. Thanks for reading till here :) ...