https://learn.unity.com/tutorial/introduction-to-lighting-and-rendering#
2.Choosing a Lighting Technique
- Precomputed Realtime GI Lighting
- 预先计算反弹的柔和光线 + realtime 清晰锐利的阴影
- 通过集群简化的模型来计算间接光照,与其他光线和纹理混合
- To speed up the precompute further Unity doesn’t directly work on lightmaps texels, but instead creates a low resolution approximation of the static geometry in the world, called ‘clusters’.
- Unity uses ray tracing to calculate the relationships between these surface clusters beforehand - during the 'Light Transport' stage of the precompute.
- By simplifying the world into a network of relationships - The resulting output from our lighting model can then be turned into lightmap textures for rendering on the GPU, blended with other lighting and surface maps, processed for effects and finally output to the screen.
- 开销
- 同时使用两套系统(baked GI & Precomputed GI)双倍计算开销、lightmap vram占用、与shader混合计算的时间
- 缺省启用,可以在 lighting 面板中设置调节;在灯光的设置中也需要独立指定;
4.Choosing a Rendering Path
- Forward Rendering
- can be very fast - meaning hardware requirements are lower than alternatives.
- offers us a wide range of custom ‘shading models’ and can handle transparency quickly
- allows for the use of hardware techniques like ‘multi-sample anti-aliasing’ (MSAA) which are not available in other alternatives
- pay a render cost on a per-light basis.
- Deferred Rendering
- This approach has the principle advantage that the render cost of lighting is proportional to the number of pixels that the light illuminates, instead of the number of lights themselves.
5.Choosing a Color Space
- This can be selected using the ‘Color Space’ property from (Edit>Project Settings>Player).
- 使用 Linear space 而非 ‘Gamma’ Color Space
- Another main benefit of Linear is that shaders can also sample textures without Gamma (midtone) compensation. This helps to ensure that color values remain consistent throughout their journey through the render pipeline. The result is increased accuracy in color calculations with improved overall realism in the eventual screen output.(管线中能进行重复采样,以确保
- 但可能线性色彩空间在有些地方存在兼容性问题(旧设备环境)
6.High Dynamic Range (HDR)
- 可在相机组件中勾选HDR选项以替换缺省的8bit范围,最好与线性色彩空间一起使用
- extreme color values also need to be handled somehow to prevent them being ‘clamped’ to white.
7.Reflections
- Unity’s ‘Standard Shader’:This attempts to accurately represent the behavior of light on materials by mimicking physical properties such as reflectivity and the principles of ‘energy conservation’ which exist in the real world.(反射率 & 能量守恒)
- We do this with a cubemap - a 6-sided image of the world derived either from the sky, or from a ‘Reflection Probe’ which renders the environment from a specific point in space, writing the results to a texture.(skybox or probe)
- By default, objects in a Unity scene will reflect the Skybox. However, this behaviour can be changed globally in the Lighting window using the ‘Reflection Source’ property. The Skybox, or alternatively, a custom cubemap may be used. This ‘Reflection Source’ can be thought of as a scene-wide cubemap used by all objects in the scene, unless overridden - by adding a Reflection Probe.(默认使用skybox作为反射来源,可以在lighting中指定单独的反射cubemap)
- reflection probes are not meant to give physically accurate results, but instead give the impression of reflections in the game world. A few well placed probes throughout your scene will be sufficient in most cases.(不是为了精确的反射结果,而是给可信服的反射印象;放置探针会增大开销)
- probe - ‘Baked’, ‘Custom’ or ‘Realtime’
- Note that GameObjects are only visible to Baked Reflection Probes if marked as ‘Reflection Probe Static’ from the ‘Static’ drop-down at the top of the Inspector panel. Conversely, ‘Realtime’ probes render all visible GameObjects in the world unless a culling mask is applied.(烘焙范围同static;realtime下取决于layer的剔除)
8.Ambient Lighting
- A significant advantage of using ambient light is that it is cheap to render and so particularly useful for mobile applications where perhaps it is desirable to minimize the number of lights in your scene.
- Ambient Lighting can be controlled in the Lighting window from the ‘Environment Lighting’ section (Lighting>Scene>Ambient Source)
- // Note that changing the color of the ambient source does not affect the visible Skybox, instead it only affects the color of lighting within the scene.
9.Light Types
- Directional Lights
- 通常作为skybox附带产生的阳光/天光
- 平行,阴影不受光源距离影响
- Point Lights
- Enabling shadows for Point Lights can be expensive and so must be used sparingly. Point Lights require that shadows have to be rendered six times for the six world directions and on slower hardware this can be an unacceptable performance cost.
- 在realtime下需要注意光源范围以防漏光
- Spotlights
- Like Point Lights, Spotlights do not presently support indirect shadowing when using Precomputed Realtime GI. This means that light produced by Spotlights will travel through geometry and will bounce on the other side. Placement therefore needs to be carefully considered.(realtime下需要注意边缘范围漏光问题,Precomputed Realtime GI 和点光一样不支持间接光照)
- Area Lights
- Presently only available in Baked GI
- In order to achieve this, we must fire a number of rays from each lightmap texel in the world, back towards the light in order to determine whether the light can be seen. This means that Area Lights can be quite computationally expensive and can increase bake times.(会增加烘焙时间,也因此不影响实时性能)
10.Emissive Materials
- Whilst Area Lights are not supported by Precomputed Realtime GI, similar soft lighting effects are still possible using ‘Emissive Materials.’ Like Area Lights, emissive materials emit light across their surface area. They contribute to bounced light in your scene and associated properties such as color and intensity can be changed during gameplay.(自发光材质可以产生实时的类似 area light 效果)
- There is no range value for emissive materials but light emitted will again falloff at a quadratic rate. Emission will only be received by objects marked as ‘Static’ or “Lightmap Static’ from the Inspector. Similarly, emissive materials applied to non-static, or dynamic geometry such as characters will not contribute to scene lighting.(没有范围值,而是强度根据平方反比漫射;但对环境的影响仍然只能作用于 static 的烘焙物体……)
- If you need dynamic, or non-static geometry - such as characters, to pick up light from emissive materials, Light Probes must be used.(要影响动态物件的光照着色,还是需要放置光照探针)
11.Light Probes
- Light Probes allow moving objects to respond to the same complex bounced lighting which is affecting our lightmaps regardless of whether Baked GI or Precomputed Realtime GI is used. An object’s mesh renderer will look for the Light Probes around its position and blend between their values. This is done by looking for tetrahedrons made up by the position of Light Probes, and then deciding which tetrahedron the object’s pivot falls into. This allows us to place moving characters in scenes and have them appear properly integrated. Without Light Probes, dynamic objects would not receive any global illumination and would appear darker than surrounding, lightmapped geometry.