Manual
Contents
- 1 System requirements
- 2 Prerequisites
- 3 Installation
- 4 Quickstart
- 5 Render settings
- 6 Advanced render settings
- 6.1 Light probe mode
- 6.2 Asset UV Processing
- 6.3 Denoiser
- 6.4 Adjust sample positions
- 6.5 Unload scenes before render
- 6.6 Denoise
- 6.7 Fix Seams
- 6.8 Split by scene
- 6.9 Hole filling
- 6.10 Min resolution
- 6.11 Scale per map type
- 6.12 Checker preview
- 6.13 Emissive boost
- 6.14 Indirect boost
- 6.15 Backface GI
- 6.16 Ambient occlusion
- 6.17 RTX Mode
- 6.18 Export terrain trees
- 6.19 Terrain optimization
- 6.20 Compress volumes
- 6.21 Samples multiplier
- 6.22 GI VRAM optimization
- 6.23 Tile size
- 6.24 Temp path
- 6.25 Output path
- 6.26 Use scene named output path
- 6.27 Render Selected Groups
- 6.28 Beep on finish
- 7 Experimental render settings
- 8 Components
System requirements
To use Bakery you'll need:
- Windows (7 or higher) PC.
- Nvidia GPU. Minimum supported model is Kepler (GeForce 650 or newer. For Quadro cards check the specs).
- 64-bit Unity editor. Bakery was tested on all versions from 5.6 to 2019.1.
Prerequisites
- Make sure your project does not have any script compilation errors, as it will prevent Bakery scripts from compiling as well.
- Make sure you have the latest GPU driver. Update it if needed.
Use the Game-Ready (standard) driver, not the "Studio" one.
Installation
1. Import Bakery to your project via Asset Store.
2. Unity will show a list of files to import. If it's your first time using Bakery, it is recommended you just click Import. Experienced users may want to untick the examples folder for a more lightweight installation.
Files will be imported to Assets/Bakery and Assets/Editor/x64/Bakery. These folders can be moved later.
3. Unity will then import Bakery and compile the scripts. It may show a window like this:
In which case you should click "Go Ahead".
You should now see Bakery menu added to the editor:
Quickstart
1. Add some model or primitive and mark it as Static.
Meshes must have non-overlapping UV for lightmapping. UV2 is used if present (otherwise UV1). If you did not unwrap models for lightmapping, make sure to check Generate Lightmap UVs on the asset. Unity primitives already have correct UV2.
2. Select Directional Light (the one Unity created for you) and add Bakery Direct Light component to it.
3. Bakery Direct Light has many options to tweak, but you can easily match it to Unity light. Click Match lightmapped to real-time. Now Bakery light should have the same yellowish color as Unity’s default Directional.
4. To get shadowed ambient lighting, create Skylight (Bakery->Create->Skylight).
5. Select Skylight, give it some bluish color and click Match scene skybox to this light. This will make scene skybox match lighting exactly.
6. Click Bakery->Render Lightmap. By default, Full Lighting mode is active. It will bake both direct and indirect contribution from all lights. If you want to combine real-time shadows with baked GI, change it to Indirect.
7. Click Render.
8. Done! You should now have baked GI:
Render settings
All render settings can be accessed via Bakery->Render Lightmap. Settings are saved for every scene. The topmost option in Bakery window allows you to switch between Simple, Advanced and Experimental settings, each succeeding mode revealing more tweakable options. Simple mode is enough for most scenes and it's a good way to get started.
Render mode
Defines the type of lightmaps to bake.
Full Lighting
Complete direct and indirect lighting for all Bakery lights.
Indirect
Basic mixed mode. It will look at the Baked Contribution selector on every light: if it’s set to Direct And Indirect, the light is baked as in Full Lighting mode. If it’s set to Indirect Only, only indirect contribution (GI) from this light is baked. In latter case you should keep both Unity and Bakery lights on the object, one giving real-time direct contribution, and another for precomputed GI.
Shadowmask
A more advanced mixed mode. It works by generating two types of lightmaps - one with baked color (as in Indirect mode), and another with shadows from static objects. It has several benefits:
- Real-time shadows can render only a handful of dynamic objects, instead of the whole scene.
- Real-time and baked shadows blend together properly.
- Real-time lights can render bump, specular and other surface effects, while still being occluded by high-quality baked shadows.
Currently only Direct, Point and Spot lights can interact with shadowmasking (because they are the only types Unity supports in real-time). To enable this behaviour, you must have both Unity and Bakery lights on the same object, with Baked Contribution set to Indirect and Shadowmask. Unmarked lights will be baked as in Indirect mode.
Distance Shadowmask
This checkbox is only visible if you chose shadowmask and simply toggles equally named setting in project’s Quality Settings. More details.
Subtractive
Enables Subtractive lighting mode.
This option does not do anything special to lightmaps and, in fact, works just like Full Lighting.
The only difference is that it also sets up real-time Unity lights to work with Subtractive mode (as it cannot be done through UI).
You will need to additionally set up global subtractive parameters (like the global shadow color) in Unity lighting window.
Ambient Occlusion Only
Only bakes AO. May be useful if you know what you're doing. Make sure to set up AO options.
Directional mode
Defines how directional information is baked. Standard lightmaps only store a single color per texel, while directional lightmaps give shaders a hint of how lighting changes over a hemisphere around the texel. This data is required to combine fully lightmapped areas with normal maps. Plugging it into the built-in Bakery shader can also produce approximate specular response.
None
No directional data, single color per texel.
Baked Normal Maps
Still no directional data, but normal maps are taken into account when rendering the lightmap. There is no additional runtime overhead. Since lightmaps usually have lower resolution than normal maps, the result may look blurry. Other problems include aliasing at distance due to lack of mipmapping and denoising step potentially smudging the detail. To learn how to use custom shaders with procedural normals in this mode, read Normal Mapping section.
Dominant Direction
This mode is similar to what Enlighten and Progressive bake in Unity. It is compatible will most shaders, only generates one additional map and the runtime overhead is minimal. The downside is that bump-mapping looks rather faint and gray-ish and can be quite different comparing to the same object under real-time lighting.
RNM
Based on Radiosity Normal Mapping technique originally invented for HL2 (slides) and later used in many games (e.g. Mirror’s Edge). It generates 3 HDR maps in total, being the most memory-demanding mode of all. Runtime overhead is still relatively low. This mode is more precise than Dominant Direction. It is better at reproducing surface contrast and handling colored lights affecting normal maps from different angles.
SH
Based on “Precomputed Global Illumination in Frostbite” paper. This is the highest quality mode, giving much better surface contrast and representing differently colored lighting coming from different directions. Generates 4 maps in total, only one of them being HDR, therefore takes less memory than RNM. Runtime overhead is slightly higher than that of RNM.
Limitations
- RNM and SH can be only used with Bakery shader or require adjustments to your shaders.
- In RNM and SH modes, standard color lightmaps are not created. You need to either have Bakery shader on all materials in the scene, or use Lightmap Groups to separate RNM/SH objects from the rest.
- RNM and SH maps are applied to objects using MaterialPropertyBlock and so may be not shown completely in Unity’s Lighting window.
- Dominant Direction, RNM and SH modes may require slightly more samples for GI and Light Meshes to get comparable quality.
Texels per unit
Approximate amount of lightmap texels per world unit. Affects the amount and resolution of generated lightmaps.
Example values to get you started:
- Large outdoor area (a city): 1 - 5
- Medium outdoor area (a few alleys): 10-20
- High quality interior: 100
It is assumed that scene scale is roughly 1 unit = 1 meter. Such scale is generally recommended when working in Unity for better navigation and for physics simulation. If your scale is different, multiply Texels accordingly.
Keep in mind that Texels Per Unit is base resolution, but every object can be additionally tweaked using Scale in Lightmap option on Mesh Renderers as well as Scale per map type in Bakery window.
Max resolution
Maximum lightmap size limit. If objects can't fit in a single lightmap (given current Texels Per Unit value), additional lightmaps will be allocated. Same 4 square objects can take four 512x512 maps or one 1024x1024.
Bounces
Defines how many times light rays should bounce off surfaces. Usually lower values are sufficient for outdoor scenes (e.g. a city), while higher values are required for more closed scenes (interiors, caves).
Samples
Affects quality of GI. Typical values are from 16 to 32.
GPU Priority
While GPU is working on lightmaps, OS and other software may become less responsive. This option allows you to balance between baking speed and system responsiveness.
Render
Bakes lightmaps for all opened scenes. If Light Probe Mode is set to L1, also bakes light probes.
Render Light Probes
Bakes light probes for all opened scenes.
Note that to get correct mixed light shadowing on dynamic objects in Shadowmask mode you also need to enable occlusion probes.
Render Reflection Probes
Bakes reflection probes for all opened scenes. This button is just for convenience and will call built-in engine reflection probe update.
Update Skybox Probe
Bakes global diffuse and reflection probe for the current skybox. As with "Render Reflection Probes", it just calls built-in engine functions.
Occlusion probes
When "Render Light Probes" is pressed, lets Unity bake occlusion probes using currently selected built-in lightmapper. Occlusion probes is additional data stored inside regular light probes, and it prevents dynamic objects from getting lit in shadowed areas. Currently there is no way to use custom occlusion probes in Unity, and it has to call its own lightmappers instead to do the job.
Warnings
These options will validate the scene after one of the Render buttons is pressed and show warning dialog boxes asking to continue or stop the baking process.
- UV validation: will check if all models have fully correct lightmapping UVs - specifically if they lie within 0-1 range and don’t overlap.
- Overwrite check: will tell which lightmap files are going to be overwritten.
- Memory check: will tell a very approximate amount of video memory required.
- Sample count check: will check if any lights, GI or AO have unreasonable sample counts that can make GPU go out of available resources.
- Lightmapped prefab validation: validates Lightmapped Prefabs and notifies if some prefabs are going to be overwritten.
Advanced render settings
Light probe mode
Changes the way light probes are baked.
- Legacy: use Render Light Probes button to generate the probes. Point and directional lights are calculated within the lightmapper, while area/sky/indirect lighting is gathered by rendering a cubemap at each probe position. Results are stored as L2 spherical harmonics. The downsides are slow cubemap rendering performance and possible mismatch between lightmaps and probes in cases where shaders in your game do not physically represent lit surfaces or your project is set up for mobile (Unity can clip high intensity values away).
- L1: light probes will be rendered together with lightmaps when you click Render. This option provides superior baking performance and will guarantee that probe lighting matches the lightmaps. Results are stored as L1 spherical harmonics (can be still used by regular shaders). Results can be further improved by using Non-Linear Light Probe SH option in Bakery shader.
There seems to be a bug in Unity 2019.3 preventing Legacy light probe colors from being properly saved IF occlusion probes option is enabled. L1 mode is now default and recommended when using occlusion probes. Legacy mode will be soon deprecated and replaced with a new L2 mode based on L1.
Asset UV Processing
Configures UV padding adjustment for assets. Possible values:
- Don't change: don't touch the assets.
- Adjust UV padding: will look for models with auto-generated UVs (“Generate Lightmap UVs” on the asset) and adjust them further to have proper padding between UV islands per-mesh. Model-wide Pack Margin in importer settings is ignored. Optimal values are calculated instead, given area of each mesh and lightmap resolution.
- Remove UV adjustments: reverts all previous UV adjustments, makes auto-unwrapped models look they way Unity originally unwrapped them.
Denoiser
Sets the desired denoiser. Possible values:
- Optix 5: uses OptiX 5.1 AI denoiser (previously known as "Legacy denoiser"). Runs on the GPU. Supported on everything from Kepler (typically GeForce 6xx) to Turing (typically Geforce 20xx). Not supported on Ampere (30xx). OptiX 5.1 uses a static training dataset which is embedded into it, meaning it is not affected by the driver implementation.
- Optix 6: uses OptiX 6.0 AI denoiser (previously the default option). Runs on the GPU. Seems to fail on Kepler (6xx) GPUs, but runs on everything newer, including Ampere (30xx). Since 6.0 the training dataset for the OptiX denoiser is in the driver. Before driver v442.50 its behaviour was similar to OptiX 5.1; however, after it NVIDIA has changed the dataset, and results can be different. The updated dataset may sometimes produce grid-like patterns and more bright edges (still fixable with "Denoise: fix bright edges"), but it runs faster.
- Optix 7: uses OptiX 7.2 AI denoiser. Behaves similarly to OptiX 6.0, but might be better supported on Ampere (30xx).
- OpenImageDenoise: uses Intel Open Image Denoise library. Runs on the CPU (any CPU that supports SSE 4.1). Can be slightly slower than OptiX, but the quality is comparable.
Adjust sample positions
Find best sample positions to prevent lighting leaks. Details of the algorithm are outlined here. In some cases (usually large and very low poly geometry with smooth normals) it may produce incorrect results, in which case you can disable it.
Unload scenes before render
Unloads Unity scenes before baking to free up video memory. Complex scenes can take a few gigabytes of VRAM by simply being shown in editor.
Denoise
If enabled, will apply denoising algorithm. Bakery uses Nvidia’s AI denoiser.
Fix Seams
If enabled, will attempt to blend seams created by UV discontinuities. Useful for smooth geometry, including Unity’s default sphere.
Split by scene
If multiple scenes are loaded at once, and this option is enabled, each scene will have its own set of lightmaps, not shared with others. It can be useful for limiting the amount of textures loaded when scenes are streamed at runtime.
Hole filling
If Atlas Packer is set to xatlas, will try to fill every hole, resulting in more efficient atlases. For scenes with very complex geometry it can increase scene export time, but otherwise recommended.
Min resolution
Minimum lightmap size limit. Can be used to balance between many small but fully occupied lightmaps vs few incompletely filled.
Scale per map type
Allows you to scale the resolution of color/shadowmask/direction maps differently. For example, a common case would be to have low resolution indirect color but highly detailed shadowmask. Note that scaling is applied after the lightmaps are rendered, so it won’t save baking time. If “Adjust UV padding” is on, padding will be based on the lowest resolution map to prevent texel leaking.
Checker preview
If Show checker checkbox is on, Scene View will render a checkerboard pattern on top of visible objects to demonstrate lightmap texel size. This is useful to make sure you are using adequate values for Texels Per Unit and other resolution-affecting settings before you bake.
Enabling checker preview will force Bakery to perform atlas packing. It can take some time, but shouldn’t be longer than a few seconds. Press Refresh checker to re-atlas the scene after you changed something to see changes.
Checker preview also uses random colors to show how the scene will be split into different lightmaps.
Emissive boost
Multiplies any surface emission by this number.
Indirect boost
Multiplies all bounced lighting by this number. Same as Indirect Intensity on light components, but global.
Backface GI
Determines how much light is passed through front faces to back faces and then bounced off by GI. This is especially useful for thin translucent surfaces like leaves. Values are in 0-1 range.
Ambient occlusion
Simple non-physical ambient occlusion you can apply over final scene lighting for aesthetic purposes.
- Intensity: controls visibility of the AO effect. Value of 0 disables the effect.
- Radius: determines the ray distance used in the AO effect. Smaller values give localized occlusion (corners, wrinkles), while larger values make it more similar to Skylight, giving shadows from distant objects.
- Samples: affects the quality of ambient occlusion. Typical values are from 4 to 32.
RTX Mode
Enables RTX hardware acceleration. Only RTX GPUs will benefit from this option. Minimum supported driver version is 418.
Drivers can emulate RTX mode on most non-RTX Nvidia cards, but the result is usually slower.
RTX mode must be enabled on Ampere (3xxx) cards.
Export terrain trees
If enabled, painted terrain trees will affect lighting. Trees themselves will not be baked. Note that highest possible LOD level is used for every tree during baking. It is not recommended to use this option for rendering multi-kilometer forests with highly detailed models.
Terrain optimization
If enabled (default), Terrains use separate ray tracing technique to take advantage of their heightfield geometry. Otherwise they are treated like any other mesh. Terrain optimization significantly reduces memory footprint required for high-resolution landscapes. In some cases it can also make terrain baking faster, in other cases (especially with simple low-resolution landscapes) it might make sense to disable it.
Compress volumes
If enabled, applies texture compression to volume 3D textures and switches Bakery shaders to a corresponding sampling mode. Not recommended for very low resolution volumes. Volume size may be increased to be a multiple of 4.
Notes:
- Currently it can only compress to BC6H/BC7 texture formats (desktop/consoles).
- Volume compression is only supported on Unity 2020.1 or newer.
- Currently only Bakery shader for the standard rendering pipeline supports using compressed volumes.
Samples multiplier
Multiplies all shadow and GI samples by the specified factor. Use it to quickly change between draft and final quality.
GI VRAM optimization
Toggles memory optimization used for very large scenes, especially when baking too many lightmaps at once. If enabled, may slow down rendering a little bit. If disabled, and the scene is too big, Bakery may go out of memory.
- Auto: guess if optimization is needed based on open scenes. The guess is only approximate, so if you know the scene is huge, set it to Force On.
- Force On: always enabled.
- Force Off: always disabled.
Tile size
Same as GPU Priority, but instead of abstract priority you set tile size. Bakery splits lightmaps into smaller tiles and updates one at a time. Smaller size means more GPU work interruptions, and can make system more responsive.
Temp path
Temporary files folder. Bakery may require a few gigabytes of free space during rendering. Having this folder on SSD can make rendering slightly faster comparing to HDD. At the moment, this folder is not cleaned automatically. You can delete its contents anytime (except during rendering).
Output path
Lightmap folder. This is where all lightmap, and also lightprobe and vertex color assets will be saved. This path is relative to your Assets folder.
Use scene named output path
If this option is enabled, output path will be automatically set to a folder with the same name as the currently active scene (Assets/CurrentSceneName/). This is similar to how built-in Unity lightmappers behave.
Render Selected Groups
Only bakes Lightmap Groups containing selected objects. Not only selected objects will be redrawn, but all Lightmap Groups they belong to. Other lightmaps will not be updated. If objects are not a part of some manually assigned group, then a part of the scene using the same lightmap will be rebaked.
Beep on finish
If enabled, Bakery will play a sound when the bake is finished.
Experimental render settings
Unwrapper
If Adjust UV Padding is enabled, defines the unwrapper that will be used.
- Default: standard Unity unwrapper. Bakery will call Unwrapping.GenerateSecondaryUVSet for every mesh with different padding parameters.
- xatlas: uses xatlas by jpcy, a modified version of thekla_atlas by Ignacio Castaño. thekla_atlas was used in The Witness (blog post).
Atlas Packer
Selects the algorithm to use when packing different object UV layouts into large lightmap atlases.
- Default: original algorithm Bakery used before v1.7.
- xatlas: uses xatlas.
Some features are only supported with one atlas packer:
Default | xatlas | |
---|---|---|
Override resolution | Yes | No |
Efficient LOD packing | No | Yes |
Hole filling | No | Yes |
Note that atlas packer can be also chosen separately for every Lightmap Group.
Export geometry and maps
If enabled, Bakery will export the scene to its format before rendering. If you are sure that geometry and textures of the scene and lightmap resolution settings were not changed (e.g. you are only tweaking GI or light settings), you can disable this checkbox to make next rendering faster.
Update unmodified lights
If enabled, Bakery will recalculate light sources that didn’t change since last rendering. If you are only tweaking one light and don’t want to wait for other lights to re-render, you can disable this checkbox.
Update modified lights and GI
If enabled, Bakery will recalculate GI and lights that were changed since last rendering.
UV padding: increase only
Only visible if Adjust UV padding is on. By default, optimal UV padding for a model asset is calculated only based on currently loaded scenes. If there are multiple instances of the same model using different lightmap resolution, the smallest one will define padding, so spacing between UV charts is large enough to prevent them from leaking over each other. However, baking the same model in 2 different isolated scenes will possibly break UVs in previous scenes while optimizing for the new one. This checkbox allows to prevent such behaviour by never decreasing the padding value, so it will be always optimized for the lowest resolution instance ever baked.
Denoise: fix bright edges
Only visible if Denoise is on. Sometimes the neural net used for denoising may produce bright edges around shadows, like if a sharpening effect was applied. If this option is enabled, Bakery will try to filter them away. Denoising stage may get slightly slower, when enabled.
This feature may also be used to filter "fireflies", i.e. occasional bright dots from the lightmap.
Combine with Enlighten real-time GI
If enabled, then when the Render button is pressed, it will first try to bake with Enlighten to calculate real-time GI. After that, regular Bakery lightmapping process will happen. Both baked and real-time GI will work together.
Bake on remote server
Enables network baking.
Components
Bakery Lightmap Group Selector
Specifies which Lightmap Group to use for the object and all of its children. Lightmap Group is a term Bakery uses for a collection of objects sharing one lightmap. Groups have properties telling Bakery how to pack the objects, which lights should affect them, should the result be baked into a texture or vertices. By default all static objects are automatically packed into multiple lightmaps groups (atlases), so you don’t have to worry. Defining groups manually should be only used for special purposes, for example:
- Marking certain objects use per-vertex lightmap instead of textures.
- Baking a lightmap using exact unscaled UVs as they were in a modeling package.
- Grouping certain areas of the level to use single lightmap to facilitate resource streaming or to switch different baked lighting at runtime via scripts.
- Using Render Selected button to only update grouped objects.
To manually define a group, you create Lightmap Group Assets, either by using Assets->Create menu, or using the Create New button in the component. When using the Create New button, new asset will be created based on these forms:
- Name: name of the Lightmap Group Asset to create.
- Packing mode: this selector defines the packing mode of the Lightmap Group. There are 3 modes:
- Original UV: object and its children will be baked with unmodified UVs. No packing is performed. This is useful for models when multiple meshes share the same already packed UV layout.
- Pack Atlas: object and its children are packed into a dedicated texture atlas. Before v1.3 every packable child needed to have the component, but it’s no longer necessary. Every child will be packed as its own rectangle, except when Bakery auto-detects a child having non-overlapping sub-children, in which case multiple objects can use a single rectangle.
- Vertex: object and its children will use vertex-colored baked lighting instead of textures. Note that you’ll need a custom shader for this to work, like Bakery Shader. One simple shader ("Bakery/Simple Vertex Lightmapped") is also included for demonstration and reference. Learn more about vertex lightmaps.
- Directional mode: allows you to override directional mode on the group. Options are the same except for Auto, which will simply use the global setting.
- Resolution: desired lightmap resolution.
- Atlas packer: select atlas packing algorithm for this group.
- Bitmask: a list of toggles used to exclude light sources from affecting the lightmap. Every Bakery light source also has a bitmask setting. Lights only affects Lightmap Groups with which they share at least one of these toggles. Default settings mean all lights affect all lightmaps.
If you have a Lightmap Group with the Pack Atlas mode assigned, additional settings will appear on the component:
- Override resolution: override the resolution this object and its children occupy in the lightmap.
- Resolution: manually defined resolution. For example, if you have a lightmap with a resolution of 512 and it is assigned to 4 objects with override resolution set to 256, Bakery will generate a single 512x512 lightmap where each object takes exactly 256x256 square.
If you select a Lightmap Group asset, additional experimental settings will be visible:
- Subsurface scattering: (click to read more)
- Normal offset: allows you to offset rays from the surface. This is rarely useful and mostly present for experimental purposes.
- Transparent selfshadow: start rays behind the surface so it doesn't cast shadows on self. Might be useful for translucent foliage.
Bakery Lightmapped Prefab
This component allows prefabs to store lightmapping metadata. Such prefabs can be then instantiated in any scene, both in editor and at runtime. The component should be added directly to the root object of the prefab. Nested prefabs are not supported. Because the prefab is going to be overwritten after bake (the same way as when the “Apply” button is pressed), it is required that the prefab does not have any unapplied changes (child objects shouldn’t be moved, materials and script parameters should be unchanged, etc). If such changes are detected, an error will be printed in the component UI and no metadata will be saved after bake. If Lightmapped prefab validation warning is enabled, all prefab errors will be also shown in a dialog box before the bake.
Lightmapped prefabs support all Bakery features, such as LODs, terrains, directional lightmaps, RNM, SH, per-vertex modes and shadowmasks. For shadowmasks to work, you need lights to also be a part of the same prefab.
After baking, an object named “BakeryPrefabLightmapData” will be added to prefab. This object holds a script with all necessary data to apply the lightmaps.
Additionally, Lightmapped Prefab allows to save current render settings and load them back to any currently open scene, using two buttons:
- Save current render settings to prefab: stores a copy of current Render Settings on this prefab.
- Load render settings from prefab: sets current Render Settings to those stored on the prefab.
Bakery Direct Light
In