Unity Post processing(Unity 后期处理 ) 官方手册笔记系列之Ambient Occlusion(环境光遮蔽)

时间:2024-04-12 11:02:35

Ambient Occlusion(环境光遮蔽)

本文档主要是对Unity官方手册的个人理解与总结(其实以翻译记录为主:>)
仅作为个人学习使用,不得作为商业用途,欢迎转载,并请注明出处。
文章中涉及到的操作都是基于Unity2018.1版本
参考链接:https://docs.unity3d.com/Manual/PostProcessing-AmbientOcclusion.html

The effect descriptions on this page refer to the default effects found within the post-processing stack.
这个页面的效果描述是指在后期处理堆栈中找到的默认效果。

The Ambient Occlusion post-processing effect approximates Ambient Occlusion in real time as a full-screen post-processing effect. It darkens creases, holes, intersections and surfaces that are close to each other. In real life, such areas tend to block out or occlude ambient light, hence they appear darker.
环境光遮蔽后期处理效果是一种类似实时环境光遮蔽的全屏幕后期处理效果。它会使彼此靠近的褶皱、孔洞、交叉点和表面变得更暗。在现实生活中,这些区域往往会阻挡或遮挡周围的光线,因此它们会显得更暗。

Note that the Ambient Occlusion effect is quite expensive in terms of processing time and generally should only be used on desktop or console hardware. Its cost depends purely on screen resolution and the effects parameters and does not depend on scene complexity as true Ambient Occlusion would.
请注意,在处理时间方面,环境遮挡效果非常昂贵,一般只能在桌面或控制台硬件上使用。它的成本完全依赖于屏幕分辨率和效果参数,而不像真正的环境遮挡一样依赖于场景的复杂性。
Unity Post processing(Unity 后期处理 ) 官方手册笔记系列之Ambient Occlusion(环境光遮蔽)
Scene with Ambient Occlusion. 拥有环境光遮蔽的场景
Unity Post processing(Unity 后期处理 ) 官方手册笔记系列之Ambient Occlusion(环境光遮蔽)
Scene without Ambient Occlusion. Note the differences at geometry intersections.
没有环境光遮蔽的场景。请注意几何体交叉处的差异。
Unity Post processing(Unity 后期处理 ) 官方手册笔记系列之Ambient Occlusion(环境光遮蔽)
UI for Ambient Occlusion 环境光遮蔽的UI

Property

Property(属性) Function(作用)
Intensity Degree of darkness produced by the effect(黑暗强度)
Radius Radius of sample points, which affects extent of darkened areas. (采样点的半径,影响黑暗区域的范围)
Sample Count Number of sample points, which affects quality and performance. (采样点的数量,影响效果质量和性能)
Downsampling Halves the resolution of the effect to increase performance at the cost of visual quality. (将效果的分辨率减半,以提高性能成本)
Force Forward Compatibility Forces compatibility with Forward rendered objects when working with the Deferred rendering path. (在处理延迟渲染时,强制兼容前向渲染对象)
High Precision (Forward) Toggles the use of a higher precision depth texture with the forward rendering path (may impact performances). Has no effect with the deferred rendering path. (是否使用前向渲染(可能影响性能)高精度深度纹理。对延迟呈现路径没有影响)
Ambient Only Enables the ambient-only mode in that the effect only affects ambient lighting. This mode is only available with the Deferred rendering path and HDR rendering. (是否只影响环境光照。这种模式只能在延迟渲染和HDR渲染中有效)

Optimisation(优化)

  • Reduce Radius size 减少半径
  • Reduce Radius size 减少采样点
  • Enable Downsampling 开启降采样
  • If using deferred rendering, disable Force Forward Compatibility (will cause forward rendered object to not be used when calculating Ambient Occlusion) 如果使用延迟渲染,禁用前向兼容性(将导致在计算环境光遮挡时前向渲染对象不会被使用)
  • If using forward rendering, disable High Precision (will cause the effect to use a lower precision depth texture, impacting visual quality) 如果使用前向渲染,禁用高精确度(将导致效果使用较低的精度深度纹理,影响视觉质量)

Details
Beware that this effect can be quite expensive, especially when viewed very close to the camera. For that reason it is recommended to always enable Downsampling and favor a low radius setting. With a low radius the Ambient Occlusion effect will only sample pixels that are close, in clip space, to the source pixel, which is good for performance as they can be cached efficiently. With higher radiuses, the generated samples will be further away from the source pixel and won’t benefit from caching thus slowing down the effect. Because of the camera’s perspective, objects near the front plane will use larger radiuses than those far away, so computing the Ambient Occlusion pass for an object close to the camera will be slower than for an object further away that only occupies a few pixels on screen.
要注意,这种效果可能相当昂贵,尤其是在非常接近相机的情况下。出于这个原因,建议总是启用降采样,并支持低半径设置。由于半径低,环境光遮蔽效果只会对接近的像素点进行采样,在剪辑空间中,对于源像素来说,这对性能有好处,因为它们可以被有效地缓存。对于比较高的半径,生成的样本将远离源像素,不会从缓存中受益,从而减慢了效果。由于照相机的视角,靠近前平面的物体将会使用比远处的更大的半径,所以计算靠近相机的物体的环境光遮蔽将会比远处的物体要慢,因为它在屏幕上只占据了几个像素。

When working with the Deferred rendering path, you have the possibility to render the ambient occlusion straight to the ambient G-Buffer so that it’s taken into account by Unity during the lighting pass. Note that this setting requires the camera to have HDR enabled.
当使用延迟渲染时,您可以将环境光遮蔽直接呈现给环境的G-缓冲区,以便在光照通道时将其考虑在内。注意,这个设置要求摄像机启用HDR。

When working with the Forward rendering path you may experience some quality issues in regards to depth precision. You can overcome these issues by toggling High Precision but only do it if you actually need it as it will lower performances.
当使用前向渲染路径时,您可能会遇到一些关于深度精度的质量问题。你可以通过高精度来克服这些问题,但只有在你确定真的需要它的时候才去做,因为它会降低你的表现。

Requirements

  • Depth & Normals texture 深度和法线贴图
  • Shader model 3 着色模型3 以上