1. 程式人生 > >Unity Lighting - Reflections 反射(六)

Unity Lighting - Reflections 反射(六)

 

Reflections 反射

 

Reflection Source 反射源

By default, objects in a scene are rendered using Unity’s ‘Standard Shader’. The Standard Shader is a 'physically based shader' (PBS). 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.

預設情況下,場景中的物件使用Unity的“標準著色器”渲染。 標準著色器是一個“基於物理的著色器”(PBS)。 這試圖通過模仿物理特性(如反射率和現實世界中存在的“能量守恆”原則)來準確地表示光在材質上的行為。

When using the Standard Shader, every material has a degree of reflectivity based on its ‘specularity’, or ‘metalness’. Without hardware powerful enough to ray trace reflections in realtime we have to rely on pre-rendering reflections. 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. This is then blended with other lighting and surface data by a material’s shader in order to approximate the effects of reflectivity, like we see in the real world.

使用標準著色器時,每種材質都會根據其“鏡面反射率”或“金屬感”具有一定程度的反射率。 沒有足夠強大的硬體來實時追蹤反射,我們必須依靠預渲染反射。 我們用一個立方體貼圖來實現這個功能 - 這是一張來自天空的6面影像,也可以是一個從空間特定點渲染環境的“反射探測器”,將結果寫入紋理。 然後通過材質的著色器將其與其他照明和表面資料混合,以便近似反射率的影響,就像我們在現實世界中看到的那樣。

Reflection SourceBy default, highly Specular/Metal materials in your scene will reflect the Skybox, defined by the Reflection Source property of the Environment Lighting Panel. This behaviour can be changed by choosing a different source, or by adding a Reflection Probe to your scene.

預設情況下,場景中的高度鏡面/金屬材質將反映由環境照明面板的反射源屬性定義的Skybox。這種行為可以通過選擇不同的來源或通過向場景新增反射探針來改變。

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.

預設情況下,Unity場景中的物件將反映Skybox。但是,這種行為可以在照明視窗中使用“反射源”屬性進行全域性更改。可以使用Skybox或者自定義立方體貼圖。這個“反射源”可以被認為是場景中所有物件使用的場景範圍的立方體貼圖,除非通過新增反射探測器覆蓋這個反射源。

Reflection Probes 反射探針

Often it is undesirable for objects to simply reflect the Skybox in a Unity scene. In many instances, objects may be blocked or ‘occluded’ from the sky. They may be indoors or underneath an architectural feature like a bridge or tunnel . To create more accurate reflections we need to sample what objects ‘see’ using a ‘Reflection Probe’. These probes render the world from their position in 3D space and write the results to a cubemap. This can then be used by nearby objects to give the impression that they are reflecting the world around them.

通常情況下,物件只能在Unity場景中反射Skybox是不可取的。在很多情況下,物體可能被遮擋或從天空“遮擋”。它們可能在室內或建築特徵如橋或隧道下。為了建立更精確的反射,我們需要使用“反射探針”來對什麼物體進行“觀察”。這些探測器從3D空間中的位置渲染世界,並將結果寫入立方體貼圖。這可以被附近的物體使用,給人的感覺是他們正在反射周圍的世界。

A reflection probe can be added via (GameObject>Light>Reflection Probe).

反射探針可以通過(GameObject>Light>Reflection Probe)新增。

The position of a Reflection Probe will determine what the generated cubemap looks like, and therefore what is ‘seen’ in the reflections. Generally, for performance reasons it is better to use as few probes as possible. Remember, 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.

反射探針的位置將決定生成的立方體貼圖的外觀,以及反射中“看到”的內容。一般來說,出於效能原因,最好儘可能少地使用探針。請記住,反射探測器並不是為了給出物理上準確的結果,而是給遊戲世界帶來反思的印象。在大多數情況下,整個場景中的幾個放置好的探頭就足夠了。

Reflection ProbesLeft: Our scene with default reflections. Right: With a Reflection Probe added.

左:我們的場景具有預設反射。右圖:添加了反射探針。

 

In the Inspector panel for a Reflection Probe we can set the ‘Type’ property of the probe to choose between ‘Baked’, ‘Custom’ or ‘Realtime’. It should be noted that Realtime Reflection Probes are extremely detrimental to performance as we are effectively rendering the scene an additional 6 times for each probe. There are specific cases where a realtime reflection probe is required and this expense is justified, but as a general rule, Baked Reflection Probes are preferable as they are considerably more performant.

在用於反射探針的Inspector面板中,我們可以設定探針的'Type'屬性以在'烘焙','自定義'或'實時'之間進行選擇。應該注意的是,實時反射探頭對效能極其不利,因為我們有效地為每個探頭再現了6次場景。有些特殊情況需要實時反射探頭,而且這種費用是合理的,但作為一般規則,烘烤反射探頭是更可取的,因為它們效能更高。

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”下拉列表中標記為“Reflection Probe Static(反射探針靜態)”時,GameObjects才會對“Baked Reflection Probes(烘烤反射探針)可見。相反,除非應用了剔除掩碼,否則“實時”探針將呈現世界上所有可見的GameObjects。


來源: https://unity3d.com/cn/learn/tutorials/topics/graphics/reflections?playlist=17102

<wiz_tmp_tag id="wiz-table-range-border" contenteditable="false" style="display: none;">