Unity Lighting - Light Types 燈光型別(八)
Light Types 燈光型別
We have now covered some of the project settings which need to be considered before beginning work on lighting your scenes in Unity. Hopefully at this point you should have your project configured appropriately for your target platform (generally Baked GI and Gamma Color Space for mobile, Precomputed Realtime GI and Linear Color Space for Standalone PC or recent games consoles).
現在我們已經介紹了在Unity開始渲染場景之前需要考慮的一些專案設定。 希望在這一點上,您應該為您的目標平臺(通常是烘焙GI和Gamma顏色空間用於移動裝置,預計算實時GI以及線性顏色空間用於獨立PC或最近遊戲機的)配置您的專案。
Let’s move on to looking at the tools available for achieving the lighting you want in your game.
讓我們繼續看看可用於實現遊戲中想要的照明的工具。
Directional Lights 方向光
‘Directional Lights’ are very 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.
'方向光'對於在場景中建立諸如陽光等效果非常有用。在許多方面像太陽一樣,方向光可以被認為是無限遠的遠距離光源。
Light rays emitted from Directional Lights are parallel to one another and do not diverge like those from other light types. As a result, shadows cast by Directional Lights look the same, regardless of their position relative to the source. This is useful to us, especially when lighting outdoor scenes.
方向光發出的光線相互平行,不像其他光源那樣發散。因此,方向光投射的陰影看起來是相同的,不管它們相對於源的位置如何。這對我們很有用,特別是在室外場景照明時。
As Directional Lights do not have a source position, they can be placed anywhere in your scene without changing the effect of the light. Rotating the light however does greatly affect the visual result.
由於方向光源沒有光源位置,因此它們可以放置在場景中的任何位置,而不會改變光源的效果。然而,旋轉燈光會大大影響視覺效果。
With other light types where there is an obvious source position, such as Spotlights, character shadows will change as the character moves closer to the light source. This can be a problem when trying to generate character shadows in interior levels. Directional lights are advantageous in these situations as shadows remain consistent regardless of proximity to the light source.
對於具有明顯源位置的其他燈光型別(例如聚光燈),角色陰影將隨著角色靠近光源而改變。嘗試在關卡內部生成角色陰影時,這可能是一個問題。方向燈在這些情況下是有利的,因為陰影保持一致而與光源無關。
Directional Lights do not diminish over distance. As they affect all surfaces in your scene (unless culled), they pose a performance cost when using the Deferred Rendering path. Remember that when using this rendering technique, the performance cost of a light is relative to the number of pixels it illuminates. However, despite the cost, performance will at least be consistent and as such, easier to balance.
方向光不會隨著距離而減少。由於它們會影響場景中的所有表面(除非被捨棄),它們在使用延遲渲染路徑時會產生效能成本。請記住,使用這種渲染技術時,燈的效能成本與其照射的畫素數有關。但是,儘管成本高昂,效能至少會保持一致,因此更易於平衡。
By default, every new Unity scene contains a Directional Light. In Unity 5, 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).
預設情況下,每個新的Unity場景都包含一個方向光。在Unity 5中,這與Lighting面板的環境照明部分(Lighting> Scene> Skybox)中定義的程式天空系統相關聯。您可以通過刪除預設方向燈並建立新燈光或僅通過從“Sun”引數(Lighting> Scene> Sun)中指定不同的GameObject來更改此行為。
Rotating the default Directional Light (or ‘Sun’) causes the ‘Skybox’ to update. With the light angled to the side, parallel to the ground, sunset effects can be achieved. Additionally, pointing the light upwards causes the sky to turn black, as if it’s nighttime. With the light angled from above, the sky will resemble daylight.
旋轉預設的方向燈(或'太陽')會導致'天空盒'更新。通過與地面平行的光線,可以實現夕陽效果。另外,將光線向上指向會使天空變黑,就像夜晚一樣。隨著從上方傾斜的光線,天空將像日光。
If the Skybox is selected as the ambient source, Ambient Lighting will change in relation to these colors.
如果選擇Skybox作為環境光源,Ambient Lighting將根據這些顏色進行更改。
Point Lights 點光
A Point Light can be thought of as a point in 3D space from which light is emitted in all directions. These are useful for creating effects like light bulbs, weapon glow or explosions where you expect light to radiate out from an object.
點光源可以被認為是三維空間中從所有方向發射光線的一個點。 這些對於建立燈泡,武器發光或爆炸等效果非常有用,因為您希望光線能夠從物體中散發出來。
The intensity of of Point Lights in Unity diminishes quadratically from full intensity at the centre of the light, to zero at the limit of the light’s reach defined by the ‘Range’ property of the component in the Inspector. 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.
點光源在Unity中的強度從光源中心的全部強度按照二次方減小到在檢測器中的元件的“Range(範圍)”屬性定義的光線範圍內為零。 光強度與距光源距離的平方成反比。 這被稱為“反平方律”,與光在現實世界中的表現類似。
Point Lights emit light in all directions from their position in the world. The spherical gizmo represents the ‘Range’ of the Light. Direct Light will ‘Falloff’ to zero when it reaches this limit, however bounced - or indirect light can continue much further.
點光源從它們在世界上的位置向各個方向發射光線。 球形Gizmo代表了光的'範圍'。 當光線達到此限制時,直射光會“衰減”到零,但是反射 - 或間接光線可以繼續更進一步。
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.
為點光源啟用陰影可能非常消耗效能,因此必須謹慎使用。 點光源要求六個世界方向上的陰影故必須渲染六次,而在較慢的硬體上,這可能是不可接受的效能成本。
When adding Point Lights to a scene it’s worth noting that currently they do not support indirect bounce light shadowing.This means that the light created by Point Lights will continue through objects and bounce on the other side unless attenuated by range. This can lead to light ‘leaks’ through walls and floors and therefore lights must be carefully placed to avoid such problems. This however is not a problem when using Baked GI.
將點光線新增到場景時,值得注意的是,目前它們不支援間接反彈光線投影。這意味著由點光源建立的光線將繼續穿過物體並在另一側反射,除非被範圍衰減。 這可能會導致牆壁和地板發出“漏光”,因此燈必須小心放置以避免出現此類問題。 然而,這在使用烘焙GI時不是問題。
Spotlights 聚光燈
Spotlights project a cone of light in their forward (+Z) direction. The width of this cone is defined by the light’s ‘Spot Angle’ parameter. Light will ‘falloff’ from the source position towards the extent of the light’s range, where it will eventually diminish to zero. Light also diminishes at the edges of the Spotlight’s cone. Widening the Spot Angle increases the width of the cone and with it, increases the size of this fade, known as the ‘penumbra’.
投光燈向前(+ Z)方向投射光錐。 該錐體的寬度由燈的“Spot Angle”引數定義。 光線將從光源位置向光線範圍內“衰減”,最終會減小到零。 聚光燈錐體邊緣的光線也會減少。 加寬光斑角度會增加圓錐體的寬度並隨之增加這種漸變的大小,稱為“半影”。
Spotlights have many useful applications for scene lighting. They can be used to great effect as street lights, wall downlights or used dynamically, for creating effects like a flashlight. As their area of influence can be precisely controlled, Spotlights are extremely useful for creating focus on a character or for creating dramatic stage lighting effects
聚光燈有許多有用的場景照明應用。 它們可以用作路燈,壁燈或動態使用,用於建立手電筒等效果。 由於它們的影響範圍可以精確控制,因此聚光燈對於創造角色焦點或創造戲劇性的舞臺燈光效果非常有用
Light will diminish as distance increases from the source. Notice how light also fades towards the edges of the cone. We call this the Light’s penumbra and this increases as the angle of the cone increases.
隨著距離距離的增加,光線會減弱。 注意光線也向錐體邊緣消失。 我們稱之為光線的半影,半影衰減隨著錐體角度的增加而增加。
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.
與點光源一樣,使用預計算實時GI時,聚光燈目前不支援間接投影。 這意味著聚光燈產生的光線將穿過幾何體並在另一側反彈。 因此需要仔細考慮安置。
Area Lights 區域燈
Area Lights can be thought of as similar to a photographer’s softbox. In Unity they are defined as rectangles from which light is emitted in all directions, from one side only - the object’s +Z direction. Presently only available in Baked GI, these Area Lights illuminate uniformly across their surface area. There is no manual control for the range of an Area Light, however intensity will diminish at inverse square of the distance as it travels away from the source.
區域燈可以被認為與攝影師的柔光盒相似。 在Unity中,它們被定義為從所有方向發射光的矩形,僅從一側 - 物件的+ Z方向。 目前僅在烘焙GI中可用,這些區域燈在其表面區域均勻照射。 區域光的範圍沒有手動控制,但強度在距離光源遠處的反平方時會減小。
Light is emitted across the surface of an Area Light producing a diffuse light with soft shadowing.
光線通過面光源的表面發射,產生柔和陰影的漫射光線。
Area Lights are useful in situations where you wish to create soft lighting effects. As light is emitted in all directions across the surface of the light, the rays produced travel in many directions - creating a diffuse lighting effect across a subject. A common use for this might be a ceiling striplight or a backlit panel.
面光源在您希望建立柔和光照效果的情況下非常有用。 隨著光線在光線的各個方向上發射,產生的光線將沿多個方向傳播 - 在物體之間產生漫射照明效果。 常見的用途可能是天花板燈條或背光面板。
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. However, used well, they can add a great depth of realism to your scene lighting and this extra precomputation may be justified. Note that as they are baked only, gameplay performance is not affected.
為了達到這個目的,我們必須從世界上每個光照貼圖紋理中發射出一些光線,然後回到光線,以確定光線是否可以被看到。 這意味著區域燈可能在計算上相當昂貴,並且會增加烘烤時間。 但是,如果使用得當,它們可以為您的場景照明新增深度的真實感,並且這種額外的預計算可能是合理的。 請注意,由於它們僅被烘焙,所以遊戲效能不受影響。
來源: https://unity3d.com/cn/learn/tutorials/topics/graphics/light-types?playlist=17102