环境和后处理

Godot 3 provides a redesigned Environment resource, as well as a new post-processing system with many available effects right out of the box.

环境

Environment资源存储控制渲染环境所需的所有信息。 这包括天空,环境照明,色调映射,效果和调整。 它本身什么都不做,但是一旦在以下位置之一中按优先级顺序使用它就会启用:

摄像机节点

环境可以设置为相机。 它将优先于任何其他设置。

../../_images/environment_camera.png

这在想要覆盖现有环境时非常有用,但通常使用下面的选项更好。

世界环境节点

WorldEnvironment节点可以添加到任何场景,但每个活动场景树只能存在一个。 添加多个将导致警告。

../../_images/environment_world.png

添加的任何环境都具有比默认环境更高的优先级(如下所述)。 这意味着它可以在每个场景的基础上被覆盖,这使它非常有用。

默认环境

可以设置默认环境,当没有将环境设置为Camera或WorldEnvironment时,该环境可用作后备环境。 只需前往项目设置 ->渲染 ->环境:

../../_images/environment_default.png

从项目管理器创建的新项目带有默认环境(default_env.tres)。 如果需要创建一个,请将其保存到磁盘,然后再在此处引用它。

环境可选项

以下是所有环境选项的详细说明以及如何使用它们。

背景

The Background section contains settings on how to fill the background (parts of the screen where objects were not drawn). In Godot 3.0, the background not only serves the purpose of displaying an image or color, it can also change how objects are affected by ambient and reflected light.

../../_images/environment_background1.png

设置背景的方法有很多种:

  • ** Clear Color **使用项目定义的默认清晰颜色。 背景将是恒定的颜色。
  • Custom Color is like Clear Color, but with a custom color value.
  • ** Sky **可让您定义全景天空(360度球体纹理)或程序天空(具有渐变和可选太阳的简单天空)。 物体将反射它并从中吸收环境光。
  • Color+Sky lets you define a sky (as above), but uses a constant color value for drawing the background. The sky will only be used for reflection and ambient light.

环境光

环境(如此处定义)是一种光,它影响具有相同强度的每个几何体。 它是全局的,独立于可能添加到场景中的灯光。

有两种类型的环境光: 环境色 (恒定颜色乘以材质反照率),然后从 天空 获得一个(如前所述,但天空需要设置为背景) 启用)。

../../_images/environment_ambient.png

When a Sky is set as background, it’s possible to blend between ambient color and sky using the Sky Contribution setting (this value is 1.0 by default for convenience, so only the sky affects objects).

以下是不同环境光对场景的影响比较:

../../_images/environment_ambient2.png

Finally, there is an Energy setting, which is a multiplier. It’s useful when working with HDR.

In general, ambient light should only be used for simple scenes, large exteriors, or for performance reasons (ambient light is cheap), as it does not provide the best lighting quality. It’s better to generate ambient light from ReflectionProbe or GIProbe, which will more faithfully simulate how indirect light propagates. Below is a comparison, in terms of quality, between using a flat ambient color and a GIProbe:

../../_images/environment_ambient_comparison.png

使用上述方法之一,物体获得恒定的环境照明,由来自探头的环境光代替。

雾,就像在现实生活中一样,使远处的物体逐渐消失成均匀的颜色。 物理效果实际上非常复杂,但Godot提供了一个很好的近似。 Godot有两种雾:

  • 深度雾: 这个基于距相机的距离来应用。
  • 高度雾: 此高度应用于任何低于(或高于)某个高度的物体,无论距离相机的距离如何。

../../_images/environment_fog_depth_height.png

这两种雾类型都可以调整它们的曲线,使它们的过渡或多或少变得清晰。

可以调整两个属性以使雾效果更有趣:

第一个是 太阳量 ,它利用雾的太阳颜色属性。 当朝向定向光(通常是太阳)时,雾的颜色将会改变,模拟穿过雾的阳光。

第二个是** Transmit Enabled **,模拟更逼真的透光率。 在实践中,它使光线在雾中更加突出。

../../_images/environment_fog_transmission.png

品质图

此选项仅在使用GLES3后端时适用。

从电影和游戏行业中使用的标准曲线的简短列表中选择将应用于场景的色调映射曲线。 色调映射可以使亮区和暗区更均匀,即使结果不那么强。 色调映射选项包括:

  • 模式: 色调映射模式,可以是线性,Reindhart,Filmic或Aces。
  • 曝光: 色调映射曝光,模拟随时间接收的光量。
  • White: Tone mapping white, which simulates where in the scale white is located (by default 1.0).

自动曝光(HDR)

此选项仅在使用GLES3后端时适用。

尽管在大多数情况下,照明和纹理都受到艺术家的严格控制,但Godot通过自动曝光机制支持简单的高动态范围实现。 当将内部区域与低光和户外相结合时,这通常用于真实性。 自动曝光模拟相机(或眼睛),以适应明暗位置和不同光量。

../../_images/environment_hdr_autoexp.gif

The simplest way to use auto exposure is to make sure outdoor lights (or other strong lights) have energy beyond 1.0. This is done by tweaking their Energy multiplier (on the Light itself). To make it consistent, the Sky usually needs to use the energy multiplier too, to match with the directional light. Normally, values between 3.0 and 6.0 are enough to simulate indoor-outdoor conditions.

通过将自动曝光与* Glow 后期处理相结合(更多内容如下),超过色调图** [\*](#id1)的像素将会流向发光缓冲区,从而在摄影中创造典型的绽放效果。

../../_images/environment_hdr_bloom.png

The user-controllable values in the Auto Exposure section come with sensible defaults, but you can still tweak them:

../../_images/environment_hdr.png

  • 比例: 用于缩放照明的值。 较亮的值会产生较亮的图像,较小的值会产生较暗的图像。
  • ** Min Luma:** 自动曝光旨在调整的最小亮度。 亮度是屏幕所有像素中光线的平均值。
  • ** Max Luma:** 自动曝光旨在调整的最大亮度。
  • 速度: 亮度校正的速度。 值越高,发生的校正越快。

Mid- and post-processing effects

A large amount of widely-used mid- and post-processing effects are supported in the Environment.

屏幕空间反射(SSR)

此选项仅在使用GLES3后端时适用。

虽然Godot支持三种反射数据源(Sky,ReflectionProbe和GIProbe),但它们可能无法为所有情况提供足够的细节。 屏幕空间反射最有意义的场景是物体彼此接触(地板上的物体,桌子上的物体,漂浮在水面上等)。

../../_images/environment_ssr.png

The other advantage (even if only enabled to a minimum), is that it works in real-time (while the other types of reflections are pre-computed). This can be used to make characters, cars, etc. reflect on surrounding surfaces when moving around.

一些用户控制的参数可用于更好地调整技术:

  • **最大步数**确定反射的长度。 这个数字越大,计算成本就越高。
  • **淡入**允许调整淡入曲线,这有助于使接触区域更柔和。
  • **淡出**允许调整淡出曲线,因此步长限制会轻微淡出。
  • ** Depth Tolerance **可用于屏幕空间射线对间隙的容差。 值越大,忽略的差距就越大。
  • **粗糙度**将应用屏幕空间模糊来近似具有此材质特征的对象的粗糙度。

请记住,屏幕空间反射仅适用于反射不透明几何体。 透明对象无法反映。

屏幕空间环境遮挡(SSAO)

此选项仅在使用GLES3后端时适用。

As mentioned in the Ambient section, areas where light from light nodes does not reach (either because it’s outside the radius or shadowed) are lit with ambient light. Godot can simulate this using GIProbe, ReflectionProbe, the Sky, or a constant ambient color. The problem, however, is that all the methods proposed previously act more on a larger scale (large regions) than at the smaller geometry level.

Constant ambient color and Sky are the same everywhere, while GI and Reflection probes have more local detail, but not enough to simulate situations where light is not able to fill inside hollow or concave features.

This can be simulated with Screen Space Ambient Occlusion. As you can see in the image below, its purpose is to make sure concave areas are darker, simulating a narrower path for the light to enter:

../../_images/environment_ssao.png

启用此效果,打开灯光并且无法欣赏它是一个常见的错误。 这是因为SSAO仅作用于* ambient * light,而不是直接光。

This is why, in the image above, the effect is less noticeable under the direct light (on the left). If you want to force SSAO to work with direct light too, use the Light Affect parameter (even though this is not correct, some artists like how it looks).

当与真正的间接光源结合时,SSAO看起来最好,比如GIProbe:

../../_images/environment_ssao2.png

可以使用以下几个参数调整SSAO:

../../_images/environment_ssao_parameters.png

  • 半径/强度: 要控制遮挡的半径或强度,可以使用这两个参数。 半径是世界(公制)单位。
  • ** Radius2 / Intensity2:** 可以使用辅助半径/强度。 结合大半径和小半径AO通常效果很好。
  • 偏差: 这可以通过调整来解决自我遮挡问题,但默认情况下通常效果不错。
  • Light Affect: SSAO only affects ambient light, but increasing this slider can make it also affect direct light. Some artists prefer this effect.
  • ** Ao通道影响:**如果使用零值,则仅将材质的AO纹理用于环境光遮挡; SSAO将不适用。大于0的值会在不同程度上将AO纹理乘以SSAO效果。这不会影响没有AO纹理的材料。
  • Quality: Depending on quality, SSAO will take more samples over a sphere for every pixel. High quality only works well on modern GPUs.
  • Blur: Type of blur kernel used. The 1x1 kernel is a simple blur that preserves local detail better, but is not as efficient (generally works better with the high quality setting above), while 3x3 will soften the image better (with a bit of dithering-like effect), but does not preserve local detail as well.
  • 边缘清晰度:这可用于保持边缘的清晰度(避免折痕处没有AO的区域)。

景深/远模糊

此效果可模拟高端相机的焦距。 它模糊了给定范围后面的物体。 它有一个** 距离过渡 区域(世界单位):

../../_images/environment_dof_far.png

** Amount 参数控制模糊量。 对于较大的模糊,可能需要调整 **质量 以避免伪影。

景深/近模糊

此效果可模拟高端相机的焦距。 它使靠近相机的物体模糊(在远处模糊的相反方向上作用)。 它有一个** 距离过渡 区域(世界单位):

../../_images/environment_dof_near.png

** Amount 参数控制模糊量。 对于较大的模糊,可能需要调整 **质量 以避免伪影。

通常使用两种模糊将观众的注意力集中在给定对象上:

../../_images/environment_mixed_blur.png

辉光

在摄影和胶片中,当光量超过介质支持的最大值(无论是模拟还是数字)时,它通常会向外渗出到图像的较暗区域。 这是在Godot中用** Glow **效果模拟的。

../../_images/environment_glow1.png

默认情况下,即使启用了效果,它也会变弱或不可见。 实际显示它需要发生的两个条件之一:

    1. The light in a pixel surpasses the HDR Threshold (where 0 is all light surpasses it, and 1.0 is light over the tonemapper White value). Normally, this value is expected to be at 1.0, but it can be lowered to allow more light to bleed. There is also an extra parameter, HDR Scale, that allows scaling (making brighter or darker) the light surpassing the threshold.

../../_images/environment_glow_threshold.png

    1. Bloom效果的值设置大于0.随着它的增加,它会以更高的数量将整个屏幕发送到辉光处理器。

../../_images/environment_glow_bloom.png

两者都会导致光从较亮的区域开始流血。

一旦看到发光,就可以通过一些额外的参数来控制它:

  • **强度**是效果的整体比例,可以更强或更弱(0.0将其移除)。
  • Strength is how strong the gaussian filter kernel is processed. Greater values make the filter saturate and expand outwards. In general, changing this is not needed, as the size can be more efficiently adjusted with the Levels.

效果的 混合模式 也可以改变:

  • Additive is the strongest one, as it just adds the glow effect over the image with no blending involved. In general, it’s too strong to be used, but can look good with low intensity Bloom (produces a dream-like effect).
  • **屏幕**是默认值。 它确保发光永远不会比自身更亮,并且可以很好地作为一个整体。
  • ** Softlight **是最弱的一种,只会在物体周围产生微妙的色彩干扰。 此模式在黑暗场景中效果最佳。
  • **替换**可用于模糊整个屏幕或调试效果。 它只显示没有下图的发光效果。

To change the glow effect size and shape, Godot provides Levels. Smaller levels are strong glows that appear around objects, while large levels are hazy glows covering the whole screen:

../../_images/environment_glow_layers.png

然而,这个系统的真正优势在于结合水平来创造更有趣的发光模式:

../../_images/environment_glow_layers2.png

最后,随着最高的图层在对微小模糊图像的拉伸中被创建,我们可能会看到一些块状模糊。 启用**Bicubic Upscaling**可以以最低的性能成本拜托它。注意这只有在使用GLES3时才有效。

../../_images/environment_glow_bicubic.png

调整

在处理结束时,Godot提供了进行一些标准图像调整的可能性。

../../_images/environment_adjustments.png

第一个是能够改变典型的亮度,对比度和饱和度:

../../_images/environment_adjustments_bcs.png

第二种是通过提供颜色校正梯度。 如下所示的常规黑色到白色渐变将不起作用:

../../_images/environment_adjusments_default_gradient.png

但是创建自定义的会允许将每个通道映射到不同的颜色:

../../_images/environment_adjusments_custom_gradient.png