2. SangYun Yi
Unity Technologies Korea Technical Artst/Evangelist
https://illu.tistory.com
sangyun@unity3d.com
15 Build on game environment art for mobile platform using the Light probes
16 Rooms2 mobile to VR
17 Implement quality unity shader on mobile hardware
18 Unity Pregressive Lightampper(2H)
19 Surface Shader for Artist(Training 4H)
4. Lighting in game or 3D Contents
• make users aware of the game design
• Describe and direct the game environment with Mood and Tone.
• Description of the shape and material of objects placed in a scene.
• Depth Representation.
6. Piazza San Pietro Colonnade
Gyeongbokgung
Chosun dynasty palace in Seoul
Jongmyo Shrine
7. Why using Lightmapping?
• Performance : low device(AR, VR do not using real time GI)
• Quality : Realtim GI does not perfect implement G.I
• More clearly reflected indirect light.
8. Vertex Color Lighting
• A simple solution for how to express light with vertex color.
• The number of vertices should be sufficient and the expression is limited because according
to direction of edge.
• A good way to assist in situations where lightmap textures are limited
10. Asset
Work process
3D props
Terrain or mesh
Lighting
Main lighting
(direction, color)
Sub lighting
(ambient color, sub light.. etc)
Budget check
Platform dependencies
game, animation, industries
pc, mobile, console..etc
Memory, hardware
spec
Rough & check
Texel size test
(most option set the lowest value)
Main scene mood
Level design
Lighting plan
work concept
(theme mood.. Etc)
Lightmap method
(baked indirect, shadowmask… etc)
Level design
Main bake
Sub option activation
Maximized option value
Add Detail lighting
Modifed and Polishing
Artifact check
running test on target
platform
Camera Technical plan
(LOD, Post Processing..etc)
12. Unity Lightmapping system change history
Unity 3.X, 4.X
Unity 5.X(deprecated)
Unity 2018.3(Preview)
Unity 5.6(Preview)
13. Lighting: Technical information and terminology
Emitted Light : This is light that is emitted directly onto
the surface of the Scene.
Direct Light : This is light that is emitted, hits the surface
of the Scene and is then reflected into a sensor (for
example, the eye’s retina or a camera). A Light’s direct
contribution is any direct light that arrives at a sensor
from that Light.
https://docs.unity3d.com/Manual/LightModes-TechnicalInformation.html
Indirect Light : This is light that is emitted, hits the surface of the Scene at least two times and is ultimately
reflected into a sensor. A Light’s indirect contribution is any indirect light that arrives at a sensor from that Light.
Light
Camera
object
object
Emissive object
15. Mixed Lighting
Mixed Lights are Light components which have their Mode property set to Mixed.
Mixed mode Legacy LWRP(ULRP) HDRP
Subtractive Supported Supported X
Baked Indirect Supported Supported Supported
Shadowmask supported X(2019.3 will be released) Supported
Lighting >> Mixed Lighting menu Light >> Mode set the mode
16. Subtractive
Traditional lightmapping method.
All the lighting information baked on texture
(Direct, indirect lights)
Discards the information that Unity uses to
composite dynamic and static shadows in other
Mixed lighting modes.
Do not show specular or glossy highlights.
Subtractive mode: All light paths are precomputed.
17. Mixed baked(subtractive) Non mixed baked(subtractive)
Shadow does not casting and light does not
working in the scene. But if add light it can work
in the scene but draw call increase.
Shadow can casting and light does not effected to
static object(dynamic object be effected). Also drawcall
increase for shadow casting(directional and point light)
18. Subtractive mode therefore has a
realtime shadow color field. Unity uses
this color in the shader.
Shadow transparent controlled by ‘realtme shadows
strength’ option in (main)directional light.
(It does not working on real time lighting only)
19. Advantage
• It provides high-quality shadows between static GameObjects in lightmaps at no additional performance
requirement.
• One Texture operation in the Shader handles all lighting and shadows between static GameObjects.
• It provides indirect lighting.
Disadvantage
• It does not provide real-time direct lighting, and therefore does not provide specular lighting.
• It does not provide dynamic shadows on static GameObjects, except for one Directional Light (the main
Light).
• It only provides low-resolution shadows from static GameObjects onto dynamic GameObjects, via Light
Probes.
• It provides inaccurate composition of dynamic and static shadows.(compared to no lightmaps)
20. LWRP(6.9.0)
(direction light x 1, point light x 4)
LWRP limitet max 4 light per object, but bake lightmap does not effected it
LWRP(6.9.0)
Real time point light x 20
LWRP(6.9.0)
Baked point light x 20
21. LWRP(6.9.0)
point light soft shadow
Legacy point light baked
(soft and hard shadow)
LWRP(6.9.0)
point light hard shadow
In LWRP point light does not supported real time shadow but shadow attenuation change to Physically Based Light Attenuation. Light intensity
decreases by the inverse-square law.
Legacy point light real time
(soft and hard shadow)
24. Baked Indirect
For Lights that are set to Baked Indirect mode, Unity
only precomputes indirect lighting, and does not
carry out shadow pre-computations.(Shadow are fully
real-time withing the shadow distance)
The performance requirements of Baked Indirect
mode make it a good option for building to mid-
range PC’s and high-end mobile devices.
Default rendering budget + baked indirect lightmap
textures
Baked Indirect mode: Only indirect lighting is precomputed
25. Baked in direct + Realtime lighting
(direction light x 1, point light x 4)
Batches : 30, Saved by batch : 9
Realtime lighting
(direction light x 1, point light x 4)
Batches : 30, Saved by batch : 9
Baked in direct + Realtime lighting
(direction light x 1)
Batches : 8, Saved by batch : 3
Baked in direct
Batches : 3, Saved by batch : 1
26. Baked in direct + Realtime lighting
(direction light x 1)
Batches : 8, Saved by batch : 3, SetPassCall : 6
Realtime light + SSAO
(direction light x 1)
Batches : 16, Saved by batch : 3, SetPassCall : 13
Compare Baked indirect and SSAO(Screen Space Ambient Occlusion)
27. Baked indirect Lit shader
HDRP Baked indirect
HDRP ambient color is affected from Static Lighting Sky in scene settings.
28. HDRP Baked Indirect
GPU Progressive lightmapper
Direct Samples : 32, Indirect Samples : 50
Environment Samples : 50, filter : Auto
HDRP Baked Indirect
GPU Progressive lightmapper
Direct Samples : 32, Indirect Samples : 500
Environment Samples : 100, filter : Auto
HDRP Baked Indirect
CPU Progressive lightmapper
Direct Samples : 32, Indirect Samples : 50
Environment Samples : 50, filter : Auto
29. HDRP Baked Indirect(GPU)
Direct Samples : 32, Indirect Samples : 50
Environment Samples : 50, filter : Auto
HDRP Baked Indirect(GPU)
Direct Samples : 32, Indirect Samples : 500
Environment Samples : 100, filter : Auto
Legacy Baked Indirect
Direct Samples : 32, Indirect Samples : 50
Environment Samples : 50, filter : Auto
30. Advantage
• It provides the same visual effect as Realtime Lighting.
• It provides indirect lighting.
Disadvantage
• It has higher performance requirements relative to other Mixed Light modes, because it renders shadow-
casting static GameObjects into shadow maps.
• Shadows do not render beyond the Shadow Distance.
31. Shadowmask
Shadowmask and Distance Shadowmask modes: Indirect lighting
and direct occlusion are precomputed
Precomputes shadows cast from static static
GameObjects.
Project Settings >> Quality >> shadowmask mode
select Shadowmask, Distance Shadowmask
32. Realtime, Baked Indirect
(direction light x 1, point light x 4)
Batches : 35, Saved by batch : 9, SetPassCall : 32
Shadowmask
(direction light x 1, point light x 4)
Batches : 16, Saved by batch : 1, SetPassCall : 15
Lightmap texture
Lightmap texture
Shadowmask texture
33. Precomputes shadows cast from static static
GameObjects.
if light over 4 count overlapping in per pixel ,
lightmapper bake the light into the lightmap texture.
Light Probes also receive the same information for up
to 4 lights.
Shadowmask texture sepearted each RGBA channel
34. Compare shadowmask and Distance shadowmask, Baked Indirect
Shadowmask
(mixed direction light x 1)
Batches : 259, Saveb by batch : 16, SetPassCall : 182
Distance Shadowmask
(mixed direction light x 1)
Batches : 456, Saveb by batch : 129, SetPassCall : 211
Baked Indirect
(mixed direction light x 1)
Batches : 508, Saveb by batch : 167, SetPassCall : 211
36. Shadow distance applied distance shadowmask mode
set a short shadow distance, see a border where the shadow texture and realtime shadow change as shown in
the image above.
37. Advantage
• It offers the same visual effect as Realtime Lighting.
• It provides real-time shadows from dynamic GameObjects onto static GameObjects.
• One Texture operation in the Shader handles all lighting and shadows between static GameObjects.
• It automatically composites overlapping shadows from static and dynamic GameObjects.
• It has mid-to-low performance requirements, because it does not render static GameObjects into shadow maps.
• It provides indirect lighting.
Disadvantage
• It only provides low-resolution shadows from static GameObjects onto dynamic GameObjects, via Light Probes.
• It only allows up to 4 overlapping light .
• It has increased memory requirements for the light map Texture / Shadow mask texture.
38. Lightmapping Settings
Lightmapper : CPU, GPU progressive lightmapper select
Prioritize view : Specifies whether the lightmapper should
prioritize baking texels within the scene view. When
Disabled, objects outside the scene view will have the
same priority as those in the scene view.
Multiple Importance Sampling : Enable this to use multiple importance sampling for sampling the
environment. This generally leads to faster convergence when generating lightmaps, but can lead to
noisier results in certain low frequency environments. This is disabled by default
40. Direct Samples : Number of rays shot
towards light sources
Indirect Samples : Number of paths
shot in the upper hemisphere
Bounces : Number of times a ray is
allowed to bounce of another surface
Direct Light(Local illumination)
Indirect Light(Global illumination)
Bounces
47. Lightmap Resoultion
Sets the resolution in texels that are used per unit for objects being lit by baked global
illumination. Larger value will result in increased time to calculate the baked lighting.
• Pixels in lightmap
• Mapped to units of space
• Texel count is proportional to resolution^2
• Each texel spawns:
• n direct rays towards k lights
• m indirect rays * j bounces
• one direct ray per bounce towards K
lights
• Texels are the amount of work to do
texel resolution could checked in the scene windows submenu “baked Lightmap”
48. Lightmap Resolution : 1 Lightmap Resolution : 5
Lightmap Resolution : 25.6(reach out maximize texel size in this scene)
49. Scale in Lightmap
Lightmap texture can controlled by each object scale in lightmap.
If your UVs are split into multiple chart, it's best not to reduce them when the lightmap texture
resolution is not sufficient.
Ensure that you use fewer non-important objects in your level design(in Camera view).
Objects that use lightmaps large enough can be adjusted accordingly.
50. Stitch seams
lightmap seam stitching is a technique that smooths unwanted hard edges in GameObjects
seam line appeared on mesh when texel size to too small.
https://docs.unity3d.com/Manual/Lightmapping-SeamStitching.html
52. Ambient Color
Environment Lighting : These settings affect light
coming from the distant environment.
ambient light is light that is present all around the Scene and
doesn’t come from any specific source object. Use this to
define a source color.
Intensity Multiplier : brightness of the diffuse environmental light in the Scene, defined as a value between 0
and 8. The default value is 1
53. How ambient color effect to scene’s mood and tone.
LowPoly environment Pack
https://assetstore.unity.com/packages/3d/environments/landscapes/lowpoly-environment-pack-99479
Environment Lighting : GradientEnvironment Lighting : Skybox
Environment Lighting : Color Environment Lighting : Color
54. Statics
The panel the Auto Generate and Generate Lighting options shows statistics about the lightmapping.
Occupied Texel : The number of texels that are occupied in lightmap UV space.
Bake Performance: The number of rays per second. If this is low (that is, less than 2) you should adjust your
settings or your hardware to process more light rays at a time.
56. GPU Progressive Lightmapper
The GPU version an order of magnitude faster than the CPU version
RadeonRays: an open source ray tracing library from AMD
Unity and AMD have collaborated on the GPU Lightmapper to implement several key features :
power sampling, rays compaction, and custom BVH(Bounding volume hierarchy) traversal.
• Unbiased interactive lightmapping
• Feature parity between CPU and GPU backends
• Compute based solution
• Wavefront path tracing for maximum performance
https://en.wikipedia.org/wiki/Bounding_volume_hierarchy
https://gpuopen.com/gaming-product/radeon-rays
57. Requirements and Limitations
To use the Progressive GPU Lightmapper, your computer must have:
• At least one GPU with OpenCL 1.2 support(RadeonRays based on OpenCL 1.2)
- Geforce 600 Series(Kepler), AMD HD5000 Series(Evergreen)
• At least 2GB of dedicated GPU memory
• A CPU that supports SSE4.1 instructions(at least Intel Penryn, AMD Bulldozer.. Etc)
- Recommended AMD graphics driver: 18.9.3. / Nvidia graphics driver: 416.34.
The Progressive GPU Lightmapper does not support:
• Baked LOD
• A-Trous filtering (it only uses Gaussian filtering)
• The custom bake API (experimental)
• Submeshes (the lightmapper uses Material properties on the first submesh)
58. Sponza 63 Refection Probes
GPU : Nvidia GTX 1080
Direct Sample : 24 / Indirect Sample : 50
Progressive bake : about 2min 10sec Progressive GPU bake : about 20sec
The goal of the GPU lightmapper is to provide the same feature set as the CPU progressive lightmapper,
with higher performance.
59. LOD Mesh Bake Lightmap
LOD0 : 3001 tris LOD1 : 2293 tris Scene Settings
60. LOD mesh baked CPU Progressive Lightmap
Baking time at least 10 min, CPU processor usage 99% during bake
61. LOD mesh baked GPU Progressive Lightmap
Baking time at least 30 sec, GPU Processor usage 99% during bake
62. LOD mesh using Light Probes
Baked lightmap
LOD0
no lightmap / no light
probes
LOD1
no lightmap / light probes
LOD1
no lightmap / light probes
proxy volume
LOD1
63. no lightmap / light probes
proxy volume
LOD1
Actual scale compare in scene
no lightmap / light probes
proxy volume
LOD1
no lightmap / light probes
proxy volume + vertex color
LOD1
3DS MAX view port
64. • Marking only LOD0 in an LOD Group as lightmap
static
• Only renderers in LOD0 get lightmap texels
• Lower LODs reuse those texels
• UVs need to match between LOD levels
• Same UV island outline, simpler topology inside
• Bakes are fast again
• All renderers processed in one go
• Raytracer’s acceleration structure is static
Projection LOD lightmapping
https://www.slideshare.net/unity3d/progressive-lightmapper-an-introduction-to-lightmapping-in-unity
65. Applied Batching Static
Objects using same material(Legacy Standard)
Checked Contribute Static(for lightmaps) and same lightmap texture index
Subtractive bake mode(non realtime lighting)
Batches : 2, Saved by batching : 3
Batches : 4, Saved by batching : 1
LOD1 using lightProbes
Batches : 3, Saved by batching : 2
LOD1 mesh separated batching statics
(if LOD1 do not use light probes it be a
static batching)
66. LOD Group Scale in lightmap
set the lightmap scale to match the LOD percentages.
LOD0 mesh scale in lightmap LOD1 mesh scale in lightmap
78. Generate Lightmap UVs
Unity can unwrap uv : Model option >> Generate Lightmap UVs
default UV(unwrap in 3DS MAX) Hard Angle : 88(default) Hard Angle : 178
Pack Margin : 16
if object shape close to cylinder, it’s better to work in DCC Tools and don't divide uv
seam line.
79. Pro Builder
Hard Angle : 178
Probuilder Generate UVs : Probuilder Object >> Probuilderize menu support check the UV visualized in editor.
83. Things to keep in mind
• 2019.2 and older releases will have sampling and noise patterns slightly different than what is
produced by the CPU lightmapper as the sampling algorithm used is different. 2019.3 and newer is
using the same sampling algorithm as the CPU lightmapper.
• If the baking process uses more than the available GPU memory the baking can fall back to the
CPU lightmapper. Some drivers with virtual memory support will start swapping to CPU memory
instead, making the bake much slower.
• GPU memory usage is very high in the preview version but we are optimizing this. In 2018.3 you
need more than 12GB of GPU memory if you want to bake a 4K lightmap.
https://forum.unity.com/threads/gpu-lightmapper-preview.561103/
84. Will be update features
• GPU lightmapper : Reduced memory usage when baking.
• Submesh support(2019.3.0a3)
• Match CPU lightmapper sampling algorithm (2019.3.0a8)
• AMD Radeon Pro Image Filters AI denoiser added. Currently Windows and AMD hardware only
(2019.3.0a10).
• Added support for baking box and pyramid shapes for SRP spotlights(2019.3.0a10).
Features added in 2020.1 (will not be backported)
• GPU backend can now export AOVs to train ML code for de-noising lightmaps. Only available in
developer mode(2020.1.0a1).
• Compressed transparency textures; 75% memory reduction by using rgba32 instead of floats
(2020.1.0a2).
• GPU lightmapper can now write out the filtered AO texture to disk, alongside the Lighting Data
Asset. Only available in On Demand mode. Only available through experimental API(2020.1.0a3).
85. Lightmaps : Technical Information
The Decode Lightmap shader function from the UnityCG.cginc shader include file handles the decoding of
lightmap values after the value is read from the lightmap texture in a shader.
encoding schemes and their texture compression formats per target platform
If the target is Android then you can override the default texture compression format from the Build Settings to
one of the following formats: DXT1, PVRTC, ETC2, ASTC. The default format is ETC for RGB textures and ETC2 for
RGBA textures.
https://docs.unity3d.com/Manual/Lightmaps-TechnicalInformation.html
86. Thank you!
Q & A
sangyun@unity3d.com
Reference
Bounding Volume Hierarchy : https://en.wikipedia.org/wiki/Bounding_volume_hierarchy
RadeonRays : https://gpuopen.com/gaming-product/radeon-rays
GPU Lightmapper: A Technical Deep Dive : https://blogs.unity3d.com/2019/05/20/gpu-lightmapper-a-technical-deep-dive/
SSE4 processor list : https://en.wikipedia.org/wiki/SSE4
Progressive Lightmapper : An introduction to Lightmapping in Unity : https://www.slideshare.net/unity3d/progressive-lightmapper-an-introduction-to-lightmapping-in-unity
Unity Progressive Lightmapper Unity forum : https://forum.unity.com/threads/gpu-lightmapper-preview.561103/
Lightmaps : Technical information : https://docs.unity3d.com/Manual/Lightmaps-TechnicalInformation.html
Unity3D ShaderLab, DecodeLightmap : https://zhuanlan.zhihu.com/p/35096536