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面影像,也可以是一个从空间特定点渲染环境的“反射探测器”,将结果写入纹理。 然后通过材质的着色器将其与其他照明和表面数据混合,以便近似反射率的影响,就像我们在现实世界中看到的那样。
By 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.
反射探针的位置将决定生成的立方体贴图的外观,以及反射中“看到”的内容。一般来说,出于性能原因,最好尽可能少地使用探针。请记住,反射探测器并不是为了给出物理上准确的结果,而是给游戏世界带来反思的印象。在大多数情况下,整个场景中的几个放置好的探头就足够了。
Left: 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。