https://docs.unity3d.com/Manual/LightingInUnity.html
lighting overview
in order to calculate the shading of a 3D object, unity needs to know the intensity, direction and color of the light that falls on it.
these properties are provided by Light objects in the scene. different types of light emit their assigned color in different ways;
some lights may diminish with distance from the source, and have different rules about the angle of light received from the source.
the different types of light source available in unity are detailed in Types of light.
unity can calcualte complex, advanced lighting effects in various different ways, each suited to different use cases.
choosing a lighting technique.
broadly speaking, lighting in unity can be considered as either “realtime” or “precomputed” in some way and both techniques can be used in combination to create immersive scene lighting.
in this section, we will give a brief overview of what opportunities the different techniques offer, their relative advantages and individual performance characeristics.
realtime lighting
by default, lights in unity – directional, spot and point, are realtime. this means that they contribute direct light to the scene and update every frame.
as lights and GameObejcts are moved within the scene, lighting will be updated immediately. this can be observed in both the scene and game views.
the effect of realtime light alone. note that shadows are completely black as there is no bounced light. only surfaces falling within the cone of the spot light are affected.
realtime lighting is the most basic way of lighting obejcts within the scene and is useful for illuminating characters or other geometry.
unfortunately, the light rays from unity’s realtime lights do not bounce when they are used by themselves. in order to create more realistic scenes using techniques such as global illumination we need to enable unity’s precomputed lighting solutions.
baked lightmaps
unity can calcualte complex static lighting effects (using a technique called global illumination, or gi) and store them in a reference texture map called a lightmap. this calculation process is referred to as baking.
when baking a lightmap, the effects of light sources on static objects in the scene are calcualted and the results are written to textures which are overlaid on top of scene geometry to create the effect of lighting.
these lightmaps can include both the light which strikes a surface and also the indirect light that bounces from other objects or surfaces within the scene. this lighting texture can be used together with surface infomation like color (albedo) and relief (normals) by the shader associated with an object’s material.
with baked lighting, these lighmaps can not change during gameplay and so are referred to as ‘static’. realtime lights can be overlaid and used additively on top of a lightmapped scene but can not interatively change the lightmaps themselves.
with this approach, we trade the ability to move our lights at gameplay for potential increase in performance, suiting less powerful hardward such as mobile platforms.
precomputed realtime global illumination
while static ligjtmaps are unable to react to changes in lighting conditions within the scene, precomputed realtime gi does offer use a technique for updating complex scene lighting interatively.
with this approach it is possible to create lit environments featuring rich global illumination with bounced light which responds, in realtime, to lighting changes. a good example of this would be a time of day system-- where the position and coloir of the light source changes over time. with traditional baked lighting, this is not possible.
in order to deliever these effects at playable framerates, we need to shift some of the lengthy number-crunching from being a realtime process to one which is precomputed.
precomputing shifts the burden of calculating complex light behaviour from sth. that happens during gameplay, to sth. which can be calcualted when time is no longer so critical. we refer to this as an ‘offline’ process.
benefits and costs
although it is possible to simultaneously use baked gi lighting and precomputed realtime gi, be wary that the perfomance cost of rendering both systems simultaneously is exactly the sum of them both. not only do we have to store both sets of lightmaps in video memory, but we also pay the processing cost of decoding both in shaders.
the cases in which u may wish to choose one lighting method over another depend on the nature of your project and the perfomance capabilities of our intended hardward. for example, on mobile where video memory and processing 显存和处理能力power is more limited, it is likely that a baked gi lighting approach would be more performant. on standalone computers with dedicated graphics hardware, or recent games consoles, it is quite possible to use precomputed realtime gi or event use both systems simutaneously.
the decision on which approach to take will have to be evaluated based on the nature of your particular project and desired target platform. remember that when targeting a range of different hardward, that often it is the least performant which will determine which approach is needed.
选择能支持最低硬件的方案。