Version: 2022.3
光源
Using Lights

光源类型

本页介绍将 Light 组件上的 Type 属性的效果。

可以使用 Type 属性来选择光源的行为。可用值有:

  • Point Light, a Light that’s located at a point in the Scene and emits light in all directions equally
  • Spot Light, a Light that’s located at a point in the Scene and emits light in a cone shape
  • Directional Light, a Light that’s located infinitely far away and emits light in one direction only
  • Area Light, a Light that’s defined by a rectangle or disc in the Scene, and emits light in all directions uniformly across its surface area but only from one side of the rectangle or disc

Point Lights

A Point Light is located at a point in space and sends light out in all directions equally. The direction of light hitting a surface is the line from the point of contact back to the center of the light object. The intensity diminishes with distance from the light, reaching zero at a specified range. Light intensity is inversely proportional to the square of the distance from the source. This is known as ‘inverse square law’ and is similar to how light behaves in the real world.

点光源可用于模拟场景中的灯和其他局部光源。您还可以用点光源逼真地模拟火花或爆炸照亮周围环境。

场景中的点光源的效果
场景中的点光源的效果

Spot Lights

Like a Point Light, a Spot Light has a specified location and range over which the light falls off. However, a Spot Light is constrained to an angle, resulting in a cone-shaped region of illumination. The center of the cone points in the forward (Z) direction of the light object. Light also diminishes at the edges of a Spot Light’s cone. Widening the angle increases the width of the cone and with it increases the size of this fade, known as the ‘penumbra’.

聚光灯通常用于人造光源,例如手电筒、汽车前照灯和探照灯。通过脚本或动画控制方向,移动的聚光灯将照亮场景的一小块区域并产生舞台风格的光照效果。

场景中的聚光灯的效果
场景中的聚光灯的效果

Directional Lights

Directional Lights are useful for creating effects such as sunlight in your scenes. Behaving in many ways like the sun, directional lights can be thought of as distant light sources which exist infinitely far away. A Directional Light doesn’t have any identifiable source position and so the light object can be placed anywhere in the scene. All objects in the scene are illuminated as if the light is always from the same direction. The distance of the light from the target object isn’t defined and so the light doesn’t diminish.

方向光代表来自游戏世界范围之外位置的大型远处光源。在逼真的场景中,方向光可用于模拟太阳或月亮。在抽象的游戏世界中,要为对象添加令人信服的阴影,而无需精确指定光源的来源,方向光是一种很有用的方法。

场景中的方向光的效果
场景中的方向光的效果

By default, every new Unity scene contains a Directional Light. This is linked to the procedural sky system defined in the Environment Lighting section of the Lighting Panel (Lighting>Scene>Skybox). You can change this behaviour by deleting the default Directional Light and creating a new light or simply by specifying a different GameObject from the ‘Sun’ parameter (Lighting>Scene>Sun).

旋转默认方向光(或“太阳”)会导致“天空盒”更新。使光线与侧面成一定角度,与地面平行,便可以实现日落效果。此外,将光源指向上方会使天空变黑,就好像是夜晚一样。如果光线从上到下成一定角度,天空将像白昼。

如果选择天空盒作为环境光源,那么环境光照将根据这些颜色进行更改。

Area Lights

You can define an Area Light by one of two shapes in space: a rectangle or a disc. An Area Light emits light from one side of that shape. The emitted light spreads uniformly in all directions across that shape’s surface area. The Range property determines the size of that shape. The intensity of the illumination provided by an Area Light diminishes at a rate determined by the inverse square of the distance from the light source (see inverse square law). Because this lighting calculation is quite processor-intensive, Area Lights aren’t available at runtime and can only be baked into lightmaps.

由于面光源同时从几个不同方向照亮对象,因此阴影趋向于比其他光源类型更柔和、细腻。您可以使用这种光源来创建逼真的路灯或靠近玩家的一排灯光。小的面光源可以模拟较小的光源(例如室内光照),但效果比点光源更逼真。

光线在面光源的表面上发射,产生具有柔和阴影的漫射光。
光线在面光源的表面上发射,产生具有柔和阴影的漫射光。

=======

光源
Using Lights