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:

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 :) ...

1. Getting startet
So you decided to use the PBR Texture Bakery and want to create great PBR textures in Blender ... Now there are two possible starting-situations you might be in:

  • You already have objects with complex Cycles materials on it. If that is the case, the bakery probably won't work directly for you. If you want it to bake your materials to textures you have to re-arrange your material so the bakery can read it - it must fit the prerequisits of the Bakery-materials. Depending on your material's complexity this can be very easy to achieve. Please read the "Bakery-material setup" - paragraph of this documentation to find out what is neccessary to bring your existing materials into an appropriate format.

  • You start your texturing process for an object from scratch. This is the easiest way to start from because while creating your material you can move along the Bakery-materials specification to keep the material in a bakable format (read the "Bakery-material setup" - paragraph to find out what those specifications are). You are able to create a material with ...
    • Albedo
    • Normal
    • Roughness
    • Metalness
    • Specular
    • Ambient Occlusion
    • Emission
    • Refraction
    • Sub Surface Scattering

2. The BakeryPBRShader
The PBR Texture Bakery is completely build ontop of a powerfull custom shader which combines Principled, Emission, Transparent and Glass shader into one shader. Well technically it is just a custom Nodegroup but it behaves like a new Cycles node, PBR-shader. As soon as you install the addon it will be available in Cycles Node-Editor under "Group -> BakeryPBRShader". The shader allows you to set all the mentioned properties from Albedo to Sub Surface Scattering:

  • Alpha | 0.0 (Transparent) - 1.0 (Opaque)
    Defines the transparency of your mesh.
  • Refraction Mask | 0.0 (not Refractive) - 1.0 (fully Refractive)
    Defines the refractiveness of your mesh.
  • Subsurface | 0.0 (no Light Scattering) - 1.0 (max Light Scattering)
    Use this input to define which parts of your mesh shall scatter light. This will be baked to a Subsurface scattering mask wich will only consist of completely black or completely white parts. Even if you define a value of 0.1, these parts will be baked as complete white.
  • Subsurface Color
    Defines the color which will be scattered.
  • Emission Color
    Defines which parts of your mesh emits light. Attention: Read "Emission Power" description too!
  • (Emission Power) | 0.0 (no Light Emission) - 60000 (max Light Emission)
    Defines the power of the light emission. This value will not be baked! It is multiplied with the Emission Color. If you bake the Emission Color, the (Emission Power) will be clamped to 1.0 and then multiplied with the Emission Color.
  • Base Color
    Defines the Color of your mesh. This value is multiplied with Ambient Occlusion
  • Ambient Occlusion
    Defines which parts use Ambient Occlusion. AO is mulitplied with Base Color in the BakeryPBRShader.
  • Specular
    Defines the specularity of your mesh.
  • Metallic
    Defines the metalness of your mesh.
  • Roughness
    Defines the roughness of your mesh.

3. The Bakery-Material
Please read the paragraph 2. The BakeryPBRShader before you continue with this paragraph ...

The PBR Texture Bakery can only bake materials to textures if you use a specific node-structure in your materials. This structure must be consistent in every material you use on an object. But don't worry: It is very flexible and offers you almost everything you need for realtime PBR. The structure of the Bakery-Material is very simple. The rule of thumb is: You must only use these shaders: The BakeryPBRShader and the MixShader and forget about all the other shader-nodes.

Apart from this you can use every other nodes to create your materials! If the bakery detects a wrong node at a specific position it will tell you what to do to fix it right. 

Rules for a Bakery-Material:

  • It must have exactly one Material Output-Node.
  • You are free to use Reroute-nodes everywhere!
  • The Surface-input of a Material Output-Node must be connected to a BakeryPBRShader or a MixShader
  • The first Shader-input of a MixShader must be connected to a BakeryPBRShader, a MixShader or can be empty.
  • The second Shader-input of a MixShader must be connected to a BakeryPBRShader or can be empty.
  • Rendered view (instead of material view) looks closest to final result.

The most simple material looks like this:

A more complex setup using 3 BakeryPBRShaders could looks like this:

Actual reallife example: Object consists of 3 separate meshes. Each one has its own UVs and material with at least one BakeryPBRShaders inside of it:

Materials were baked to an atlas-UVMap using the Bakery, imported and rendered in Sketchfab:

4. The PBR Texture Bakery - UI
After installing the PBR Texture Bakery it will be accessible from Object-mode in the "Tools"-tab of your "Tools"-panel (toggled by pressing "T"):

  • Texture Name Prefix

This value defines the prefix that is used for the naming of the generated textures. E.g.: If you bake a normal-map for your "Cube.002"-object the resulting texture will be named "PBR_Cube.002_Normal".

  • Texture Size

Size of the baked textures in pixels. Maximum value is 8192.

  • Island Margin

Margin between UV islands in pixels.

  • Target UV

If you have multiple UVs you can define here which UV-map should be the destinating one. You can also use this to transfer textures from one UV-map to another (e.g. an atlas)

  • Exclude Selected UV-Verticies
    This function allows you to exclude certain faces from the baking process. Click "Select Excluded UV-Vertices" to switch to Edit Mode and select the excluded UV-verticies. Alternatively you can switch manually to Edit Mode and add, remove or show excluded faces:

    Excluded verticies will be stored in a new vertex-group (Bakery_Exclusion). This group will be automatically created and removed. Alternativelly you can also remove this group by hand if you don't want to use the "Subtract Selected Vertices From Exclusion"-function.

  • Channel Packing
    Here you can choose a bake-target you want to bake the textures for. According to the selected bake-target the channels of some textures (e.g. UE4 - RGB =Metallic, Roughness, Ambiend Occlusion) will be packed. Read more under "Channel Packing (Export Targets)".

  • Bake All
    This will bake all textures at once.

  • Save Textures
    This will save all the baked textures of your selected object. You must select the object you baked the textures from since it identifies the textures by the Texture Name Prefix, and the selected object. You will be asked for the save-location. All the textures will be saved at once in PNG-format.

  • Export Selected Objects
    This one allows you to export mulitple objects (meshes) - equal to what you get when you use blender's export functions. But in addition to that the bakery's export function also allows you to pre-process the exported objects. That means only the exported object (fbx, obj etc.) will become processed while your original object in blender's stage remains untouched. Read down below why this is useful. The export function offers you two options. If you have no one checked, no processing is made to the exported object:

    • Collapse Materials
      If checked every material (and material slot) will be removed from your mesh except for one, which is assigned to the whole mesh. This material slot will be named "Mat_<object name>".
    • Collapse UV Maps
      Check this option if you want the exporter to remove every UV Map stored inside of your exported object except for the UV Map you configured in the "Target UV Map"-property.

      Why is this useful? Your objects (meshes) might consist of multiple materials and UV Maps. The bakery's bake functions bake all material's textures onto one texture (material). After that you only need one material assigned to your object. Since the textures where created using one specific UV Map (you can choose it defining the "Target UV Map"-property) you only need this single UV Map in your exported mesh. If you want to export your object for an external application or production (e.g. U4, Unity etc.) you would remove those unneccessary materials and UV Maps by hand before exporting. That way you would destroy your object or work with duplicates of your object inside blender. The export function just does this cleaning process with the exported object and remains your original file untouched to keep the workflow as non-destructible as possible.


Channel Packing (Export Targets)
The PBR Texture Bakery supports channel packing. Therefore it generates the textures in the best possible format for a specific target. For example, Unity 5's standard metalness shader needs a softness texture instead of a roughness texture. It also needs the softness texture inside of the alpha channel of the metalness texture. The approriate Channel Packing preset for Unity 5 will automatically convert the roughness texture to a softness texture and pack it into the alpha channel of the metalness texture. Actually these Channel Packing presets are implemented:

  • Default (OpenGL/Unity Normals)
    • Albedo + Alpha
    • Ambient Occlusion
    • Normal (OpenGL +Y)
    • Specular
    • Roughness
    • Metalness
    • Emission
    • Sub Surface Scattering Color + Scattering mask in alpha channel
    • Refraction-Mask

  • Default (DirectX/UE4 Normals)
    • Albedo + Alpha
    • Ambient Occlusion
    • Normal (DirectX -Y)
    • Specular
    • Roughness
    • Metalness
    • Emission
    • Sub Surface Scattering Color + Scattering mask in alpha channel
    • Refraction-Mask

  • Unity 5 (Metallic - Softness/Alpha)
    • Albedo + Alpha
    • Ambient Occlusion
    • Normal (OpenGL +Y)
    • Specular
    • Metalness + Softness in alpha channel (Softness = inverted Roughness)
    • Emission
    • Sub Surface Scattering Color + Scattering mask in alpha channel
    • Refraction-Mask

  • Unreal Engine 4 (MRO)
    • Albedo + Alpha
    • Normal (DirectX -Y)
    • Specular
    • Reflection + Metalness in red channel, Roughness in green channel, AO in blue channel
      -> Roughness in green channel offers best compression quality
    • Emission
    • Sub Surface Scattering Color + Scattering mask in alpha channel
    • Refraction-Mask

  • Sketchfab
    • Albedo + Alpha
    • Ambient Occlusion
    • Normal (OpenGL +Y)
    • Specular
    • Metalness
    • Roughness
    • Emission
    • Sub Surface Scattering Mask (inverted SSS-Mask)
    • Refraction-Mask

The bake-process automatically uses the CPU for baking and renders with 1 sample. Since there are no raytrace operations there is no need for more samples (or even GPU usage). In addition to that, rendering using GPU can cause more trouble than rendering using CPU (GPU-compatibility, -memory etc.). Therefor the bakery automatically uses CPU for baking no matter what your actual render device or sample-value is.

If you encounter any bugs or problems, please let me know that and i will take care as soon as possible. Even if you have some recommendations or suggestions for further features, let me know that. I will this addon to be as good as possible ...

Releases and Changelogs

  • 1.1.1 (12.10.2018)
    Feature: Added functionality for exporting objects with the bakery. Exported objects become pre-processed. See "Export Selected Objects" for further information.
  • 1.0 (22.04.2018)
    Feature: Removed the Bakery-Node setup frame and implemented a single powerfull shader (Nodegroup) called BakeryPBRShader. It allows you to bake more textures and set refraction and alpha from every shader (not only from Bakery-Node setup). It also simplifies the material creation process, makes the materials 100% consistent and more robust. This version is not downward compatible to older ones but future version will be downward compatible to 1.0!
    Feature: Added Channel Packing functionality. Now it is possible to bake textures for different render engines like UE4, Unity5, Sketchfab etc. Probably more to come. Therefore it also supports Normal Map +Y/-Y now.
    Feature: Added texture slots (Ambient Occlusion, Specularity, Emission)
    Bugfix 1: Baking did not work when scene-name was not "Scene".

  • 0.3.2 (25.03.2018)
    Bugfix 1: There was an error in the object-space to tangent-space normal-map conversion when
    used multiple bump- or normal-maps that use different UV-maps. The conversion used wrong UV-tangents which led to wrong tangent-space normal-map information. As a result of this the "Source UV" list was delete from UI. It is obsolete now. You only have to specify the UV-map you want to bake to.
    Bugfix 2: In certain cases the blue channel of the generated tangent-space normal-map was inverted. That was fixed by making the Z-vector (in tangent-space) absolute.

  • 0.3.1 (25.02.2018)
    Initial release

Regards :)

No FAQ's found for this product.

Item Rating

This item has an average rating of 4 from 14 ratings by the community.

  • elfato 12 days ago

    Great tool!!! Thanks

  • Wojciech Klimek about 1 month ago

    Great addon, designing textured models for UE4/Unity seemed impossible before i started using it.

  • Mark 2 months ago

    This is a huge time saver! Thanks for making it!

  • lobos 4 months ago

    looks really cool, but i cant find the pbr shader node, i have followed the instructions

  • lobos 4 months ago

    i cant find the pbr shader, i have followed the instructions

  • thehopefulgamer 4 months ago

    Been playing around with this add-on for about an hour and I'm really liking it. Being able to easily bake everything needed to move from cycles to unity is great. Also, for anyone getting an error about sRGB when they try to bake, be sure to disable any 3rd party color management tools you've installed and switch back over to the default that comes with 2.79. Only good things to say about the add-on though, the color management thing was an oversight on my part :)

    • Daniel Moczarski 4 months ago

      Hey, i am really happy you liked it :) ... Can you tell me which color management plugin you are using? This might help me to fix this issue.

  • newart 6 months ago

    Very well done....this helped me a TON. Just a reminder to those that may be like me and miss a step. Make sure you setup your Target UVs on the size image you will be using if different from your current texture. Or if your existing UVs stretch outside of your Image texture

  • Justin Bess 6 months ago

    Just used it this evening for the first time. Very easy and just what i need.

  • Piotr Pabijan 6 months ago

    Everything works great :)

  • Alexander Podgayko 6 months ago

    So useful and helpful, saved me like million working hours and even more nerves! Thank you! If you're considering improving the addon further, would be very nice to have:
    1. Checkboxes or customizing presets for images to configure output
    2. Baking separated objects

  • indomitusgames 7 months ago

    It works, it's easy and fast.

  • D U 8 months ago

    An essential tool for realtime baking of cycles materials! Just keeps getting better with each release!

  • Ahmad Takhimi 9 months ago

    This addon would greatly improved workflow on creating PBR assets.

  • jiangc 9 months ago

    bpy.context.scene.packingPreset = 'defaultgl'
    SSS White: Mix Shader.001 needs a BakeryPBRShader-, MixShader- or Reroute-Node connected to Shader-input 1

    • Daniel Moczarski 9 months ago

      Hi, you are not serious, are you? This is not an error but a controlled structured message which tells you this: Material with name "SSS White" has a Node which is called "Mix Shader.001" which needs a BakeryPBRShader-, MixShader- or Reroute-Node to the input slot number 1 because you put something else there. If you don't understand this message, just write me and i will tell you what to do instead of down-rating this. If you had read the documentation you would know how to avoid this. I spend a lot of hours writing it as complete and understandable as possible and you obviously did not read a single line of it. According to the documentation: Rules for a Bakery-Material: -It must have exactly one Material Output-Node. -You are free to use Reroute-nodes everywhere! -The Surface-input of a Material Output-Node must be connected to a BakeryPBRShader or a MixShader -The first Shader-input of a MixShader must be connected to a BakeryPBRShader, a MixShader or can be empty. # <- THAT'S YOUR PROBLEM -The second Shader-input of a MixShader must be connected to a BakeryPBRShader or can be empty. -Rendered view (instead of material view) looks closest to final result. -> Review this in the documentation tab for further explenation. You can also write me if you need more detailed support I am really sorry you had a bad experience with the bakery but to be honest, it is not fair down-rating my product because you are too lazy to read the documentation properly or contact me first. In addition to that, you did not even drop a speaking message with your rating. That's just not okay dude.

Purchase this item to leave a review!