The current baking workflow has some issues:
- The way to specify which image should be used is cumbersome and unintuitive
- Baking multiple channels has to be done by baking, changing settings and image, baking again etc.
- When baking two objects sharing a material, the image has to be changed before each baking pass.
- Bake types are hardcoded, other rendering engines have no way of specifying their own
Therefore, this patch introduces a system that allows to persistently store the combinations of Object, Image, Material and Settings that should be used for baking.
This is handled by the BakePass, a new type that replaces the Bake settings that used to be part of the rendering settings.
Each object holds a list of bake passes, and each bake pass holds an image and the settings that should be used to bake that image.
When running the Bake operator, it iterates over all bake passes of the currently selected object and executes them.
This way, the user can configure which images should be generated from each object and rebake quickly. Especially with the trend of baking PBR maps for e.g. game engines, this workflow is a major use case of baking.
Previously, it was possible to specify a different image for each material. To keep that functionality, the user can optionally select a material, in which case the baking pass will be limited to that material. Then, by adding a pass per image/material-pair, you get the same functionality.
In order to get rid of the hardcoded types, the Blender-side baking code doesn't care about the type anymore - the engine just provides the pixels and some additional info (for example, setting is_normal enables the normal space conversion).
This patch is not really finished yet, here's a list of ToDos:
- Polish the UI
- Versioning code - do we want to create a BakePass from the old settings? If yes, some versioning has to be done in Cycles, which means that we need to keep the old data in RNA :/
- Share renderer session (currently afaics the scene is synced and a Cycles session is started for each pass, it would be better to keep the session for all passes)
- Setting verification (used to be part of the Blender side, has to be moved into Cycles)
- Also supporting the new way of specifying images in the case of Multires Baking
- More Testing