#lightmapping troubleshooting guide
Explore tagged Tumblr posts
being-mughal · 4 months ago
Text
Blog Post 9: Unexpected Setbacks and Reality Checks
The testing of lightmaps produced a significant problem during my work today. The combination of static lighting with baked shadows to optimize VR revealed shadow failings at the spots where walls connected to the ceiling. The shadows produced strange shapes in addition to jittering light seams.
One research session helped me understand that UV overlap issues and unsatisfactory lightmap resolution were behind this problem. My return to Blender required me to handle various meshes, redo UV mapping before enlarging the lightmap dimensions in Unreal.
My speed became lower while I discovered that improper geometry will never receive forgiveness from virtual reality systems.
Reference: Unreal Engine Docs (2024) Lighting Troubleshooting Guide. Available at: https://docs.unrealengine.com (Accessed: 3 March 2025)
0 notes
kristijonasjalnionis · 3 years ago
Text
Chapter 24: Optimize lighting settings for bake performance
24.1 Realtime Global Illumination
Impact: high. Enabling this checkbox enables Enlighten realtime global illumination. Not only does it increase baking times, but also incurs a runtime cost.
Do not enable this checkbox unless you need realtime global illumination in your scene or have a specific use case necessitating both realtime and baked global illumination.
24.2 Baked Global Illumination
Impact: high. Enabling this checkbox enables baked global illumination using the Progressive Lightmapper. It increases baking times but incurs minimal runtime cost.
Do not enable this checkbox if you are already using realtime global illumination.
24.3 Lighting Mode
Impact: low. This dropdown contains three properties: Baked Indirect, Subtractive, and Shadowmask. None of which have a major impact on baking performance. All three incur a runtime cost, Shadowmask being the least performant, Subtractive being the most performant, and Baked Indirect being somewhere in-between.
When selecting Shadowmask, Unity will generate an extra texture known as shadow mask. This will not increase bake times but will increase memory requirements.
24.4 Progressive Updates
Impact: medium. When you enable the Progressive Updates, Progressive Lightmapper will process all lightmaps that are currently in view. Scenes containing many lightmaps will bake slower as a result.
Enable this checkbox while iterating on your lighting. Disable it for final quality bakes.
24.5 Importance Sampling
Impact: low. Reduces noise when using high contrast HDRIs. Disable this checkbox if you use low contrast environment lighting.
24.6 Direct Samples
Impact: high. Controls how many rays the lightmapper shoots towards light sources. Keep this value low, unless soft shadows in your scene are noisy.
24.7 Indirect Samples
Impact: high. Controls how many paths a texel can spawn. The Max Bounces value acts as a modifier. Keep this value low, unless indirectly lit areas are noisy, and emissive objects produce a lot of noise.
24.8 Environment Samples
Impact: medium. Controls how many rays the lightmapper shoots towards the environment. Keep this value low, unless areas lit by the environment are noisy.
24.9 Light Probe Sample Multiplier
Impact: low. Improves the quality of lighting data stored within light probes. Stop increasing this value once the adjacent probes are somewhat homogenous in color.
24.10 Max Bounces
Impact: high. Determines the maximum number of steps (bounces) each path can take. Will increase bake times linearly.
24.11 Filtering
Impact: medium. Enables users to reduce noise using discrete filters or AI-powered denoisers. Impact on baking performance varies depending on the filtering and denoising combination used.
Set this dropdown to None for the fastest iteration speed and troubleshooting. Enable filtering for production quality bakes.
24.12 Lightmap Resolution
Impact: high. Increases bake times in a quadratic fashion. In other words, increasing the resolution from 1 to 2 will increase the bake times by four times. It is important to keep this value as low as possible.
The Occupied Texels string at the bottom of the Lighting window reports the number of texels Progressive Lightmapper needs to process. One million texels should still be very fast, but iteration times will suffer at eight million and higher.
24.13 Anti-aliasing Samples
Impact: high. This value is accessible via the Lightmap Parameters Asset. It impacts the memory used during the bake, as well as the bake preparation time, and the total bake time.
Keep this value low - or disable it - unless your baked shadows suffer from stair-stepping artifacts (aliasing).
0 notes
kristijonasjalnionis · 3 years ago
Text
Chapter 19: Compression artifacts
Tumblr media
Figure 46. Banding artifacts introduced by low quality compression on Android platform (left). You can fix banding artifacts by using high quality compression (right).
19.1 Why does this happen?
Color banding and blocky artifacts are often associated with low quality texture compression. Unity attempts to automatically select the best compression format for the target platform. Due to compatibility concerns, texture formats intended for mobile platforms are often more affected by compression artifacts.
19.2 How to fix it?
19.2.1 Change Lightmap Encoding setting
Tumblr media
Figure 47. Project Settings window. We have highlighted the Lightmap Encoding dropdown in blue. You can find the HDR Cubemap Encoding setting underneath.
Lightmap Encoding setting determines how Unity encodes High Dynamic Range (HDR) lightmaps. You can access it in Project Settings > Player > Other Settings. Higher quality tiers provide better results. You need to adjust this setting for each platform.
19.2.2 Change HDR Cubemap Encoding setting
In the 2022.1 release, we introduced a HDR Cubemap Encoding setting in the Project Settings window. This property is almost identical to the Lightmap Encoding setting, but it controls the encoding of the cubemaps instead of lightmaps.
If reflective objects in your scene exhibit artifacts, switch to a higher quality preset for the affected target platform.
19.2.3 Change Lightmap Compression property
Tumblr media
Figure 48. Lightmap Compression property in the Lighting window.
Lightmap Encoding influences how Unity encodes lightmaps. Lightmap Compression dropdown in the Lighting window determines the actual compression quality. There are four options: None, Low Quality, Normal Quality, High Quality. Higher quality presets will result in less compression artifacts post-bake.
Tumblr media
Figure 49. Texture Importer window allows users to manually override texture compression format.
It is possible to override lightmap compression format manually via the Texture Importer. To do this, follow these steps:
In the Project window, navigate to the folder which contains the lightmap textures.
Select one of the lightmap textures.
In the Inspector window, scroll all the way to the bottom, and click on one of the tabs representing each installed platform.
Enable the checkbox to override the texture format for the platform of your choice.
Select the desired format and click Apply.
It is worth noting that your customizations will be overwritten every time you generate lighting. Follow the above-mentioned steps again after baking.
0 notes
kristijonasjalnionis · 3 years ago
Text
Chapter 11: Blurry lightmaps
Tumblr media
Figure 22. Cornell Box scene baked at 8 texels per unit resolution (left). Same scene baked at 32 texels per unit resolution (right). Notice the increased shadow fidelity in the statue, and the lack of light leaking in the tall box.
11.1 Why does this happen?
To ensure high fidelity output, Unity needs a high resolution lightmap to capture lighting information. Too few texels and the result will be blurry.
Also, lightmap texels must be uniform, square in shape. Non-uniformly scaled lightmap UVs will appear stretched post-bake.
11.2 How to fix it?
11.2.1 Adjust lightmap resolution
There are two ways to adjust lightmap resolution:
Globally. Use the Lightmap Resolution property in the Lighting window to adjust lightmap resolution for all objects in the scene.
Per-object. Adjust the Scale In Lightmap parameter found in the Mesh Renderer component. This parameter is a multiplier of the Lightmap Resolution property found in the Lighting window.
Note that a two times increase in lightmap resolution will result in four times increase in baking times. High resolution lightmaps will also lead to higher memory usage.
Keep a low lightmap resolution for:
Surfaces that receive uniform lighting
Surfaces that receive indirect lighting only
Small objects
Surfaces that are not visible to the player
Reserve high lightmap resolution for:
Areas of high importance
Surfaces which receive baked direct lighting and shadows
11.2.2 Adjust Max Lightmap Size property
Max Lightmap Size will be the limiting factor to the final lightmap resolution. This is especially true for large objects, such as terrains. Increase Max Lightmap Size property in the Lighting window if:
Objects start to exceed maximum space in the lightmap atlas
The number of low resolution lightmaps after baking is high, even after increasing lightmap resolution
11.2.3 Maintain uniform lightmap UV scale
Tumblr media
Figure 23. Lightmap texels stretched horizontally resulting in distorted output (left). Uniformly scaled lightmap texels (right). Both lightmaps have the same 80 texels per unit resolution.
Lightmap texels should remain in a uniform scale. This will prevent lightmap distortions. To ensure this, keep in mind the following:
When authoring custom lightmap UVs, do not scale UV shells in one axis only. If you need to scale UV shells, do so uniformly, across all axes.
When scaling UV shells, scale an entire atlas. Avoid scaling single shells unless it is necessary.
Same logic applies to GameObjects in the editor. Try to keep them uniformly scaled. Scaling objects in one axis will stretch lightmap UVs as well.
Use Baked Lightmap scene view draw mode to inspect lightmap uniformity. Remember to enable the Show Lightmap Resolution checkbox to see lightmap texels.
0 notes
kristijonasjalnionis · 3 years ago
Text
Chapter 10: Lightmap UV seams
Tumblr media
Figure 20. Lightmap UV split visible across the hand after baking (left). Unity fixes seams after enabling the Stitch Seams option and baking again (right).
10.1 Why does this happen?
By default, GPUs cannot blend color values between separate UV shells. Without the extra post processing step, this limitation can cause visible seams to appear in a lightmap. Aggressive filtering and low lightmap resolution can exacerbate this problem by bleeding texel color values into neighboring UV shells.
10.2 How to fix it
Disclaimer: fixing lightmap seams in a single object can be trivial. It is more difficult to address this problem when working with modular meshes. This is a common issue that most lightmapping backends face, and it is a hard problem to solve.
10.2.1 Enable Stitch Seams option
Stitch Seams option is available in the Mesh Renderer component, under the Lightmapping header. By enabling it, Unity will attempt to fix seams by blending color values between UV shells that share a stitchable common edge in the model.
Note that this option only works with single GameObjects. Multiple GameObjects are not supported.
10.2.2 Combine meshes in a DCC tool
Tumblr media
Figure 21. Cornell Box scene assembled using modular meshes with visible seams after lightmap baking (left). Meshes combined in a DCC tool prior to exporting with no lightmap seams visible (right). You can achieve the result on the right by disabling filtering and baking with high sample counts.
The easiest way to mitigate seams is to combine meshes in a 3D modeling package. Make sure to weld overlapping vertices before exporting. Or, you can weld vertices in in the Model Import Settings window. Skipping this step might impede automatic lightmap unwrapping in Unity.
10.2.3 Combine meshes via an API
Mesh.CombineMeshes method combines meshes into one, achieving the same result as merging them in a DCC package.
10.2.4 Combine meshes using ProBuilder
When working with ProBuilder meshes it is possible to merge multiple objects by using the Merge Objects option.
You can make this option available for regular meshes by converting them into ProBuilder meshes using the ProBuilderize option.
10.2.5 Disable filtering and denoising
By disabling filtering, it is possible to avoid blurring and dilation issues described earlier. The main drawback of this approach is long bake times, as you would need to increase the number of samples to achieve clean results.
10.2.6 Increase lightmap padding
If disabling filtering does not solve the issue, try increasing Lightmap Padding value. When working with modular meshes, each mesh has its own UV atlas. Lightmap Padding property allows you to change the distance between UV atlases – but not between UV shells within the atlas - to prevent leaking.
10.2.7 Use light probes
Light probes are often used to provide indirect illumination for dynamic objects. Consider utilizing light probes for difficult to lightmap objects.
It is worth mentioning that probe-lit objects receive lighting information from a single probe. It can be detrimental when illuminating large objects. Light Probe Proxy Volume (LPPV) component can mitigate this problem, by creating a grid of light probes within a bounding volume. As a result, probe-lit objects that make use of LPPVs have a spatial gradient improving their look.
Adaptive probe volumes allow for per-pixel lighting and streamlined placement when compared to light probe groups, and LPPVs.
10.2.8 Hide seams using meshes or textures
If the art direction allows for it, try using trim meshes to hide seams between objects. This is a commonly used technique in game development.
0 notes
kristijonasjalnionis · 3 years ago
Text
Lightmapping Troubleshooting Guide - Introduction
Back in 2022, when I still worked at Unity, I wrote a lightmapping guide in order to help developers get the most out of Baked Global Illumination (GI) in the Unity. In it, I unpack some of the most common lightmapping issues and provide solutions, supported by images and links to relevant pages in the Unity Manual.
You can read the announcement blog post by clicking this link. You can also read this guide on Unity Discussions page.
Although this guide was intended for Unity, many of the concepts still apply to other engines and even offline renderers.
I wanted to post this guide here in case Unity removes it from their forums.
Since this guide has 25 chapters, this post serves as a table of contents to help you find your way around.
Table of Contents
Chapter 1: No baked global illumination in the scene
Chapter 2: Objects are missing lighting
Chapter 3: Emissive materials not rendering
Chapter 4: Flat normal maps
Chapter 5: Missing specular response
Chapter 6: Lights flicker or disappear
Chapter 7: Mixed lights render as baked
Chapter 8: Unexpected environment lighting
Chapter 9: Lightmap UV artifacts
Chapter 10: Lightmap UV seams
Chapter 11: Blurry lightmaps
Chapter 12: Lightmap aliasing
Chapter 13: Direct, indirect, and environment noise
Chapter 14: Fireflies
Chapter 15: Invalid texel artifacts
Chapter 16: Denoising artifacts
Chapter 17: Filtering artifacts
Chapter 18: Lightmap leaking
Chapter 19: Compression artifacts
Chapter 20: Light probe ringing artifacts
Chapter 21: Light probe leaking
Chapter 22: Light probe noise
Chapter 23: Redundant light probes
Chapter 24: Optimize lighting settings for bake performance
Chapter 25: Optimize scene setup for bake performance
0 notes