unity5.6里Baked Lighting下面几个Lighting Mode的解释

这个似乎是新增的功能,目前在官方文档里还没有解释,但有一个链接指向『草案』,

可是链接在被墙的google doc上,为了方便阅读和备忘,全部贴过来整在一起:

因为原文太长,把总结写在前面吧:

1、四种模式,主要区别在于烘焙出的光照图、阴影图内容,也就影响到动、静态物件在运行时的受光、投影效果,效果越好越丰富的,开销自然也越大。

2、效果最单纯的substrative:所有颜色和阴影都烘死在光照图上,运行时静态物件不参与阴影图渲染,结果是不管光源怎么变,静态物件的受光和阴影都不变。

3、好一点的是shadowmask:静态物件的阴影不变,但是受光情况可以随光源变化而变

4、再好一点的是distance shadowmask:静态物件的阴影和受光都可以变

5、跟4差不多好的baked indirect:仅烘焙间接光照(也就是物体之间漫反射导致的表面明暗效果),其它东西(如阴影)全部在运行时计算,跟实时差不多了。

当然这里总结的只是一些肉眼可见的明显差别,具体区分,尤其是动静物件互投影情况,还是看下面原文里的表格吧。

 

--------------------------------------------------- 

5.6 DRAFT DOCUMENTATION: This is first draft documentation for a feature that is new in Unity 5.6. As such, the information in this document may be subject to change before final release.

 

 

 

Mixed lighting

Summary

Mixed lights are lights whose transform and light properties only change within strong limitations at run time (see “Advanced Usage”), or don’t change at all. They illuminate both static and dynamic objects, always provide direct lighting and can also provide indirect lighting. Dynamic objects always cast realtime shadows on other dynamic objects.

The available mode mappings are:

 

Usage

Mixed lights should be considered the workhorse for lighting a static scene. All lights that are not part of any gameplay, but simply light up the static environment, are good candidates for mixed lights. As direct lighting is still calculated at run time, materials on static meshes will retain their visual fidelity including full physically based shading support. If the target platform allows it, the Distance Shadowmask yields the best results, with high quality shadows within the shadow distance, and baked high quality shadows beyond. It is now possible to have large landscapes with nice shadows up to the horizon, provided that the sun does not travel across the sky.

The subtractive mode is on the other end of the quality spectrum, it renders realtime shadows for only one light and composites them with baked direct and indirect lighting. This is the fallback solution for all target platforms that are so computationally challenged that they cannot afford choosing any of the other modes. This mode might be chosen when the title needs to run on the absolute low-end of mobile phones and memory constraints prevent the use of the shadowmask mode.

The Reference Card shows a condensed comparison of the various modes.

 

All light modes are supported on all platforms. However :

  • Subtractive mode will fallback to forward rendering (no deferred or lightprepass support).
  • “Shadowmask” and “Distance shadowmask” modes will fallback to forward rendering (no deferred or lightprepass support) on platforms supporting only four rendertargets. DirectX9 is such a target.

 

 

An example for mixed lights.

Technical Details

In the case of mixed lights the last segment of a light path, the path from the light to the surface, becomes part of the precomputation as well. However, direct lighting and indirect lighting are still handled separately. Indirect lighting is baked into lightmaps and Light Probes that are sampled at run time. Indirect lighting is generally low frequency, i.e. smooth, and doesn’t contain any sharp shadows. Therefore shadows are handled via direct lighting where they have the most visible impact. The difference in how shadows are precomputed and stored is reflected in the various submodes for mixed lights. For example shadow information can be precomputed and stored in a shadowmask. The shadowmask is a texture which shares the same UV layout and resolution with its corresponding lightmap. It stores occlusion information for up to 4 lights per texel, as textures are limited to up to 4 channels on current GPUs. The values range from 0 to 1, with values in between marking soft shadow areas. If shadowmasks are enabled, Light Probes will also store occlusion information for up to 4 lights. If more than 4 light volumes intersect, all additional lights will fall back to static lights. This behavior can be inspected by using the new shadowmask overlap visualization mode. As this information is precomputed, only shadows from static objects cast on other static objects are stored in the shadowmask. These shadows can have smoother edges providing better quality than realtime shadow maps, depending on the lightmap resolution. As each mixed shadow casting light retains its shadowmask channel mapping at run time, shadows cast by dynamic objects via shadow maps can be correctly composited with precomputed shadows from static objects avoiding artefacts like double shadowing. The only discernible differences between shadows from static objects and dynamic objects stem from the difference in resolution and filtering of the precomputed shadowmask and the run time shadow map, and that precomputed shadows support various forms of area lights, so soft shadows can have nicer penumbras.

 

In this image the baked shadowmask resolution is similar to the realtime shadow resolution

 

In this image the baked shadowmask resolution is much lower than the realtime shadow resolution.


What all mixed modes except for the subtractive mode have in common is that direct lighting is always computed in realtime and added to the indirect lighting stored in the lightmap for any given surface point, so all material effects that require a light direction, like normal maps for example, will continue to work just fine. Dynamic objects will always cast shadows on other dynamic objects via shadow maps within the shadow distance, if shadows are enabled for that light.

 

 

Baked Indirect mode: Only indirect lighting is precomputed

 

Shadowmask and Distance Shadowmask modes: Indirect lighting and direct occlusion are precomputed

 

Subtractive mode: All light paths are precomputed

Advanced usage

The mixed lights have been introduced as lights whose transforms and properties can only change within strong limitations at run time. In fact, as some lighting is precomputed, changing any parameters at run time will lead to inconsistent results when combining realtime and precomputed lighting. 

In the cases of the three mixed modes “Baked Indirect”, “Shadowmask” and “Distance Shadowmask”, the direct lighting contribution behaves just like a dynamic light, so Unity does allow changing parameters like the color, intensity and even the transform of the light. However, precomputed values still cannot change. For example, if a red mixed light was baked into the lightmap, but changes its color to green at run time, all direct lighting will use the green color, but the lightmaps will still contain baked red color, so indirect lighting on static objects will still be red and look obviously wrong. The same applies to moving a mixed light at run time - direct lighting will follow the light, but indirect lighting will remain at the position the light was baked at.

However, if only subtle changes are introduced to direct lighting, for example by only slightly modifying the hue or intensity of a light, it is possible to get the benefits of indirect lighting and still appear somewhat dynamic, without having to pay the cost of a dynamic light. Indirect lighting will still be wrong, but the error may be subtle enough not to be objectionable. This works especially well for lights without precomputed shadow information, either by having shadows disabled, or in the Baked Indirect mode where shadows are realtime. As shadowmasks are basically part of the direct lighting computation, moving such lights will cause artefacts with shadows not lining up correctly, anymore.

The following video shows an example of what happens when a mixed light is moved too far away from the spot it was baked. Note how the indirect reddish light on the walls remain in place despite the object moving far away:

https://youtu.be/o6pVBqrj8-s 

 

The following video shows an example of how to slightly modify a mixed light without causing noticeable artefacts with the indirect lighting:

https://youtu.be/XN6ya31gm1I 

5.6 BETA DOCUMENTATION: This is first draft documentation for a feature and its associated changes to the Unity Editor that is currently in beta in Unity 5.6. As such, the information in this document may be subject to change before final release.  

Pages in [grey] are not yet available. Pages highlighted in [pink] are available.

 

 

 

[5.6 Beta] Light Modes

 

Graphics

Graphics Overview

Lighting

Lighting Overview

Lighting Window [page moved] [UPDATE TO PAGE: VERSION 2] 

Lighting Explorer [NEW PAGE] 

Light Sources

The light inspector [UPDATE TO PAGE] 

Shadows

Light Modes (High Level) [NEW PAGE: VERSION 2] 

Technical Terms and notation [NEW PAGE: VERSION 2] 

Realtime Lighting [NEW PAGE: VERSION 2] 

Mixed Lighting [NEW PAGE: VERSION 2] 

Baked indirect light mode [NEW PAGE: VERSION 2] 

Distance shadowmask light mode [NEW PAGE: VERSION 2] 

Shadowmask light mode [NEW PAGE: VERSION 2] 

Subtractive light mode [NEW PAGE: VERSION 2] 

Baked Lighting [NEW PAGE: VERSION 2] 

Global Illumination

Using precomputed lighting  [UPDATE TO PAGE] 

LOD for Baked Lightmaps (GI) [NEW PAGE]

Baked Ambient Occlusion [No updates]

Light Probes [UPDATE TO PAGE] 

Lightmapping modes [page rename] [UPDATE TO PAGE] 

GI Visualisation in the scene view  [No 5.6 BETA updates]
                 (See current documentation in the Unity User Manual, updated in DRAFT)

Light troubleshooting and performance [UPDATE TO PAGE] 

Terrain engine

Terrain Settings [UPDATE TO PAGE] 

 

Graphics reference

Rendering pipeline details

Deferred shading rendering path [UPDATE TO PAGE] 

Shader reference

Writing surface shader [UPDATE TO PAGE] 

Mesh components

Mesh Renderer [UPDATE TO PAGE] 

Skinned Mesh Renderer [UPDATE TO PAGE] 

Working in Unity

Editor Features

Settings Managers 

Graphics Settings [UPDATE 1. TO PAGE] [UPDATE 2. TO PAGE]

Upgrade Guides

Upgrading to Unity 5.6 [UPDATE TO PAGE]

 

 

 

5.6 DRAFT DOCUMENTATION: This is first draft documentation for a feature that is new in Unity 5.6. As such, the information in this document may be subject to change before final release.

 

 

 

Subtractive mode

The subtractive mode is the only stationary mode where direct lighting is baked into the lightmap, discarding necessary information for correct compositing of dynamic and static shadows. As the direct lighting component is already baked into the lightmap, no direct lighting calculations can be performed at run time. This means that static objects will not show any specular or glossy highlights at all from stationary lights. They also cannot receive any shadows from dynamic objects except for the main directional light as explained below.

Dynamic objects are still lit in realtime supporting glossy reflections. They can only receive shadow information from static objects via Light Probes.

In subtractive mode, only the main directional light, which is usually the sun, will cast realtime shadows from dynamic objects on static objects. As shadows from static objects on other static objects are baked into the lightmap, even for the main light, correct composition of baked and realtime shadows cannot be guaranteed anymore by the engine. Unity therefore exposes a user controllable parameter called Realtime Shadow Color in case the subtractive submode is selected. This color is then used in the shader to composite realtime shadows with baked shadows by attenuating the lightmap in areas shadowed by dynamics objects. As there is no correct value that the engine can predetermine, it is the responsibility of a title’s art direction to choose a value that works for the given scene. This mode is an improvement over the “Mixed” Mode of Unity versions 5.0 to 5.5.

Shadows

 

Dynamic receiver

Static receiver

 

Within shadow dist.

Beyond shadow dist.

Within shadow dist.

Beyond shadow dist.

Dynamic caster

Shadow map

-

Main light shadow map

-

Static caster

Light Probes

Light Probes

Lightmap

Lightmap

Pros & Cons

  • High quality shadows from statics on statics in lightmap at no additional cost
  • Indirect lighting
  • All lighting for static objects is just one texture fetch in the shader
  • No realtime direct lighting, i.e. no specular
  • No dynamic shadows on static objects except for 1 directional light (the main light)
  • Low resolution shadows from statics on dynamics only via light probes
  • Inaccurate composition of dynamic and static shadows
  • Increased memory requirements for lightmap texture set

Target platforms

  • Low-end mobile

Example

  • A toon shaded game with an outside level and very few dynamic objects.

 

 

 

5.6 DRAFT DOCUMENTATION: This is first draft documentation for a feature that is new in Unity 5.6. As such, the information in this document may be subject to change before final release.

 

 

 

Shadowmask mode

Shadows cast from static objects on other static objects are precomputed and stored in a separate shadowmask texture for up to 4 overlapping lights. Light Probes also receive the same information for up to 4 lights.
Static objects receive shadows from other static objects via the shadowmask, regardless of the shadow distance. Shadows from dynamic objects are received via shadow maps only within the shadow distance. Overlapping shadows from static and dynamic objects are correctly composited, as both shadow maps and shadowmasks only encode occlusion information.
Dynamic objects receive shadows from other dynamic objects via shadow maps within the shadow distance. Shadows from static objects can only be received via Light Probes, so the shadow fidelity heavily depends on the probe density in the scene and the Light Probe mode selected for the Mesh Renderer. 

Shadows

 

Dynamic receiver

Static receiver

 

Within shadow dist.

Beyond shadow dist.

Within shadow dist.

Beyond shadow dist.

Dynamic caster

Shadow map

-

Shadow map

-

Static caster

Light Probes

Light Probes

Shadowmask

Shadowmask

Pros & Cons

  • Same visual fidelity as realtime lights, specular effects and normal maps just work
  • Realtime shadows from dynamic objects on static objects
  • High quality shadows from statics on statics everywhere at cost of only one texture fetch
  • Correct composition of dynamic and static shadows
  • Reduced performance cost as statics are not rendered into shadow maps
  • Indirect lighting
  • Low resolution shadows from statics on dynamics only via light probes
  • Only up to 4 overlapping light volumes (refer to the Technical Details section)
  • Increased memory requirements for lightmap texture set
  • Increased memory requirements for shadowmask texture

Target platforms

  • Low-end to mid-range PCs
  • Low-range to high-end mobile

Examples

    • An almost fully static scene with nice specular materials, soft baked shadows and a dynamic shadow caster not too close to the camera so shadow maps and shadowmasks merge nicely
    • An open world scene without dynamic time of day with baked shadows up to the horizon

 

 

 

 

5.6 DRAFT DOCUMENTATION: This is first draft documentation for a feature that is new in Unity 5.6. As such, the information in this document may be subject to change before final release.

 

 

 

 

 

 

 

Distance shadowmask mode

 

The Distance shadowmask mode is a hybrid that addresses the shortcomings of the shadowmask mode of missing high quality shadows on dynamic objects from static objects. Within the shadow distance, both dynamic and static objects are rendered into the shadow map allowing static objects to cast sharp shadows onto dynamic objects. The tradeoff is the performance hit taken by rendering all static objects into the shadow maps.
Beyond the shadow distance, static objects receive high quality shadows from other static objects via the precomputed shadowmask, and dynamic objects receive low resolution shadows from static objects via Light Probes.

 

Shadows

 

 

Dynamic receiver

Static receiver

 

Within shadow dist.

Beyond shadow dist.

Within shadow dist.

Beyond shadow dist.

Dynamic caster

Shadow map

-

Shadow map

-

Static caster

Shadow map

Light Probes

Shadow map

Shadowmask

 

Pros & Cons

 

  • Same visual fidelity as realtime lights, specular effects and normal maps just work
  • Realtime shadows from dynamic objects on static objects
  • Realtime shadows from static objects on dynamic objects
  • High quality shadows from statics on statics everywhere at cost of only one texture fetch
  • Correct composition of dynamic and static shadows
  • Indirect lighting

 

 

  • Increased memory requirements for lightmap texture set
  • Increased memory requirements for shadowmask texture
  • Increased performance cost as statics are rendered into shadow maps

 

Target platforms

 

  • Playstation 4
  • Xbox One
  • High-end PCs

 

Example

 

    • An open world scene with shadows up to the horizon and complex static meshes casting realtime shadows on characters walking around

 

 

 

 

5.6 DRAFT DOCUMENTATION: This is first draft documentation for a feature that is currently in new in Unity 5.6. As such, the information in this document may be subject to change before final release.

 

 

 

Baked Indirect mode

For Baked Indirect lights only indirect lighting is precomputed, no shadow precomputations are performed. Shadows are thus fully realtime within the shadow distance. In other words, Baked Indirects lights behave exactly the same as fully realtime dynamic lights with additional indirect lighting sampled from a precomputed lightmap and no shadows beyond the shadow distance. Effects like fog can be used to obscure the missing shadows past that distance.

Shadows

 

Dynamic receiver

Static receiver

 

Within shadow dist.

Beyond shadow dist.

Within shadow dist.

Beyond shadow dist.

Dynamic caster

Shadow map

-

Shadow map

-

Static caster

Shadow map

-

Shadow map

-

Pros & Cons

  • Same visual fidelity as realtime lights
  • Realtime shadows for all combinations of static and dynamic objects
  • Indirect lighting
  • Increased performance cost as shadow casting static objects need to be rendered into shadow maps, which is not necessary for some of the other stationary modes
  • No shadows beyond shadow distance
  • Increased memory requirements for lightmap texture set

Target platforms

  • Mid-range PCs
  • High-end mobile

Examples

  • An indoor shooter or adventure game set in rooms connected via corridors. As the viewing distance is limited, everything that is visible will fit within the shadow distance, so missing shadows beyond it are not an issue.
  • An outdoor scene where fog can be used to hide the missing shadows in the distance.

 

posted on 2017-05-26 11:30  冷欺花  阅读(9243)  评论(0编辑  收藏  举报

导航