延迟渲染 (或延迟着色/延迟光照)

From Valve Developer Community
< Zh
Revision as of 23:10, 13 June 2025 by BlueMicro (talk | contribs)
Jump to navigation Jump to search
Under construction.png
This page is actively undergoing a major edit.
As a courtesy, please do not edit this while this message is displayed.
If this page has not been edited for at least several hours to a few days, please remove this template. This message is intended to help reduce edit conflicts; please remove it between editing sessions to allow others to edit the page.

The person who added this notice will be listed in its edit history should you wish to contact them.

Info content.png
This page is being translated.
You can help by finishing the translation.
If this page cannot be translated for some reason, or is left untranslated for an extended period of time after this notice is posted, the page should be requested to be deleted.
Also, please make sure the article complies with the alternate languages guide.(en)
English (en)中文 (zh)Translate (Translate)

延迟着色 是一种在顶点与像素着色器完成操作后进行的屏幕空间的着色技术。顾名思义“延迟”,即将着色计算延迟到 geometry pass 之后的第二个 lighting pass。

延迟光照 (也被称作 Light Prepass) 是延迟着色的一个变体,与传统延迟渲染的 2 个 pass 不同的是,延迟光照的管线有 3 个 pass。延迟光照的管线里只有光照的着色是被延迟的,而整个着色操作本身并未被延迟。

延迟渲染使得高性能大量光源渲染得以可能。

不过,延迟光照要比延迟着色的要求更高,因为它创建了一个多的 pass。但是延迟光照只有光照着色信息会在最后的 pass 得到处理,所以它的内存开销比延迟着色低,并且延迟光照管线对半透明以及 MSAA 的支持也更好。

尽管如此, 这和起源 起源默认的辐射度( radiosity )光照(静态的)有巨大的不同(它用的是 前向渲染)。延迟渲染使用大量的 lighting pass 生成更高质量的光照,并且伴随实时阴影。

起源2 起源2 的游戏也通常使用前向渲染管线, 例如 半衰期:爱莉克斯 半衰期:爱莉克斯, 但如 Dota 2 Dota 2Deadlock Deadlock 则使用了延迟渲染。

与原版光照的区别

当编译 Valve Valve's 游戏的地图时, 每张地图必须通过 VRAD (它花费大量时间,视硬件性能和 optimizations 参数而定), VRAD 使用所有光源有关的数据并将最终光照结果覆写到 光照贴图上, 即使 VRAD 能提供高质量且多种形状的光照,然而它是完全静态的,只能提供 stationary 的光照切换,而不能提供实时变化的光照。radiosity和延迟管线的区别就在于延迟管线实时计算所有光照,并且开销低。游戏使用物体的法线、几何、Albedo 以及高光反射的信息(都来自 G-Buffer)来实时生成高质量光照。

前向管线的动态光照

前向渲染性能在过多动态光源实体(可投射阴影的 env_projectedtexture,本质上是手电筒阴影,从起源2007开始就有)。 别的类型的动态光源,例如light_dynamic,当光照贴图的分辨率很高或是光源有自己的 custom appearance 时,也会降低性能表现。另外, env_projectedtexture 也被起源 本身的默认配置所限制,也就是只有 1 个env_projectedtexture实体时才能正常工作,除非对引擎进行大幅改动。

延迟光照 (以及延迟着色) 就没有以上的问题或限制,它支持很多光照,并且性能远高于前向管道。不过,也有很多别的渲染管线,例如"Forward+/Tile-Based Forward" 或 Clustered Forward ,也可以使多动态光源渲染的性能与传统方法相比大幅降低。(例如 传送门 2:社区特供版 传送门 2:社区特供版 ,它是目前唯一一个使用 Clustered Forward 管线的起源游戏;并且还有 Operation: Black Mesa Operation: Black Mesa 正在逐步实现这个技术)。

特性

Drawbacks

  • Traditional anti-aliasing methods like MSAA might not work with deferred lighting and deferred shading, like in Apex Legends Apex Legends and 黑山 黑山 (the latter title replaced it with FXAA because MSAA caused certain models to have a glowing outline),[1] but it depends how it's implemented in the game, as 异形丛生 延迟, and Lambda Wars still support it, though it's recommended that you use post-processing anti-aliasing methods instead as they work best with deferred lighting, and have a smaller performance hit. MSAA is also more demanding with deferred lighting, and even more demanding on deferred shading compared to forward rendering, and MSAA is harder to implement on deferred shading, while it was easier to implement on deferred lighting.
  • All lightmaps are disabled and only deferred lighting lights the world. (存在于 异形丛生 延迟 之中)
  • Can be more taxing on older systems.
  • DX9 SM3 or later only, older DirectX compatibility versions are not supported.

Media

Deferred phong ref.png

Usage

Source

Few 起源引擎 games utilize this technique, as it's complicated to implement, the games that do use this are:

Deferred shading

Deferred lighting

Source 2

Deferred shading

Tutorials

See also

Entities

External links

参考文献

参考文献
1. Xen Technical Beta and Screenshot by [TC]Ciaиєz ITA:

Known Issues - Haloing Around Props/Object
MSAA is causing outlines around certain objects. MSSA is a performance killer and we hope to have a better solution for anti-aliasing with the Xen release. To remove the haloing/outline, simply turn off MSAA.. Retrieved on May 10, 2024.

2. Several commands related to deferred rendering such as r_deferred_ can be seen in Dota 2. Additionally, enabling MSAA via console commands in the original (Source 1) release of Dota 2 will breaks the renderer. Since April 27, 2012, it is confirmed that Dota 2 uses deferred shading, and use FXAA (referred as Screen-space Anti-aliasing when the Dota 2 page on VDC was edited in 2012)..