Bakery GPU Lightmapper User Manual

Bakery - GPU Lightmapper
Manual (v1.5)
Why use Bakery Bakery is designed as an alternative to existing lightmappers and focuses on solving following problems:
- Fixing various baking artifacts, such as seams, light/shadow leaks, incorrect shadow terminators, etc. Baking a lightmap should not bring more problems than rendering a camera frame in an offline renderer.
- Directional information can be baked in the form of dominant direction map (classic “directional” mode in Unity), 3 maps for Radiosity Normal Mapping, or 4 maps for per-pixel Spherical Harmonics (much higher quality than classic directional). Multiple directional modes can be used in a single scene on different objects.
- Physical correctness. Bakery results were thoroughly compared against Mitsuba, a well-known unbiased renderer. Unlike Unity’s built-in solutions, Bakery supports correct inverse-squared lighting attenuation (or if you don’t like it, you can always use Unity-compatible attenuation mode).
- IES light support.
- Render Selected (see details)
- LOD support.
- Baked prefab support.
- Baking multiple switchable lightmaps per object is planned.
Quickstart
1. Open Unity, create a new scene and import Bakery (Assets->Import Package->Custom Package).
2. Add some model or primitive and mark it as Static.
3. Select Directional Light (the one Unity created for you) and add Bakery Direct Light component to it.
Bakery light sources are separate from Unity light sources.
4. Bakery Direct Light has many settings 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.
Bakery Direct Light may complain about project not using linear light intensity. The problem is that by default Unity applies gamma correction to light source colors in a wrong way. Correct mode can be enabled by scripting, and that’s what the “Fix” button does. If you already have many light sources set up with incorrect intensity mode, and you don’t want to change them again, you may skip fixing. Even if you press “Fix”, you can always revert the change anytime.
5. To get shadowed ambient lighting, create Skylight (Bakery->Create->Skylight).
6. Select Skylight, give it some bluish color and click Match scene skybox to this light. This will make skybox match lighting exactly.
You can always do it both ways: match skybox to skylight or skylight to skybox.
7. 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.
Bakery may complain that you are using old gamma mode and suggest to change it. If you care about quality of lighting, using Linear mode is highly recommended. The only excuse not to use it is when you already have a big project set up with incorrect gamma, and you don’t want to change it.
8. Click Render.
9. 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. First option you will see (named Settings) allows to switch between Simple, Advanced and Experimental settings. Simple is enough for most tasks. Common settings:
- Render mode: defines what kind of lightmaps to bake.
- Full Lighting will generate complete direct and indirect lighting. If you have both Unity and Bakery components on the same light, you will need to disable Unity ones to avoid double brightness.
- Indirect is a basic mixed mode. It will look at the Bake to Indirect checkbox on every light: if it’s ON, the light is baked as in Full Lighting mode. If it’s OFF, only indirect contribution (GI) from this light is baked. In the latter case you should keep both Unity and Bakery lights on the object, one giving real-time direct contribution, and another for precomputed GI. Bake to Indirect is enabled by default for Skylights and Light Meshes, because Unity can’t reproduce their lighting in real-time.
- Shadowmask is a more advanced mixed mode. It works by generating 2 types of lightmaps - one with indirect color (as in Indirect mode, so Bake To Indirect checkboxes still apply), 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 Shadowmask checkbox enabled on the latter.
- Distance Shadowmask: this checkbox is only visible if you chose shadowmask and simply toggles equally named setting in project’s Quality Settings.
This checkbox doesn’t appear on Unity 5.6.x due to the lack of corresponding scripting API. Instead you can toggle it in Window->Lighting->Mixed Lighting->Lighting Mode.
Top: Bakery is set to Indirect mode, and the real-time light is enabled. Only GI is baked. Bottom: Bakery is set to Full mode, and the real-time light is disabled. Both GI and shadows are baked, but there is no shadow from the dynamic character.
A more complete render mode comparison, now with Shadowmask:
As one can conclude, Distance Shadowmask is the highest quality mode available so far, with the only problem of unshadowed dynamic objects outside of the dynamic shadow range, while regular Shadowmask mode also being relatively cheap to render.
Here is also a comparison of different light configurations using Shadowmask mode. Little cubes are static, while capsules are dynamic:
Left: completely baked light. Center: dynamic light with baked GI. Right: capsule shadow, bump and specular are dynamic, but cube shadow and GI are baked.
When camera gets far away enough or if dynamic shadows are disabled, the same scene will look like this:
Due to old Unity limitations, rendering Shadowmask lightmaps on versions prior to 2017.3 may clear the light probes. They will need to be re-rendered again after bake. It shouldn’t happen on
2017.3 and newer versions.
- 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. The available modes are:
- 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 Shader
Compatibility section.
- Dominant Direction: this mode is similar to what Enlighten and Progressive bake in Unity. It is compatible will most shaders, only generates 1 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.
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 pixels per world unit. Affects the amount and resolution of generated lightmaps.
If object has a manually assigned lightmap (via Bakery Lightmap Group Selector component), it will ignore this parameter.
Left: 5 texels per unit, right: 20 texels per unit.
Example values to get you started:
- Large outdoor area: 1 - 5
- Medium outdoor area: 10-20
- High quality interior: 100
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”.
- Bounces: 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).
Note how more bounces bring more light to closed spaces.
Loading...
+ 17 hidden pages