前Forward / 延时Deferred

2023-12-16 11:38
文章标签 forward 延时 deferred

本文主要是介绍前Forward / 延时Deferred,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

前Forward / 延时Deferred

本章节描述了延时光照的渲染路径的细节,如果想了解延迟光照技术,请查阅Deferred Lighting Approaches article. 

Deferred Lighting is rendering path with the most lighting and shadow fidelity:

延迟光照是一种当前最高级的能实现光线和阴影保真的渲染路径

  • There's no limit how many lights can affect any object.
    对于能影响任何物体的光线数量没有上限
  • All lights are evaluated per-pixel. Which means that they all interact properly with normal maps etc.
    完全采用以每像素的方式评估光线,这等于意味着全部将以正常贴图的方式正确的和物体交互
  • All lights can have Cookies.
    所有光线都能拥有信息缓存
  • All lights can have Shadows.
    所有的光线都能产生阴影

Deferred Lighting's advantages 延迟光照的优点:

  • Lighting cost is proportional to light size on screen. Does not matter how many objects it shines on. Small lights = cheap!
    光照的开销与屏幕的光线尺寸成正比,不用担心光线所照射的物品的数量,少量光线 等价于 廉价的花费
  • Consistency. All lighting for all lights is computed per-pixel; there are no lighting computations that break down on large triangles etc.
    一致性,所有的光线的光照采用按像素为计算分割单位来计算。比如,不会有在大规模三角形情况下光照计算使计算性能发生崩溃的情况发生。

Disadvantages 缺点:

  • No real anti-aliasing support.
    没有实时抗锯齿支持
  • Deferred Lighting can't handle semi-transparent objects. Those are rendered using Forward Rendering.
    延迟光照不能处理半透明物体,也不能用在哪些使用前向渲染的物体之上
  • Limited lighting model support (Blinn-Phong). All lighting is computed the same way; you can't have drastically different lighting models on different objects.
    有限的光照模式支持(Blinn-Phong)。所有光照以同样的方式计算,你不能够在不同的物体上采用完全不同的光照模式
  • No support for "receive shadows" flag and limited support light Culling Masks.
    没有对接收阴影特征的支持和对光线遮罩剔除有限的支持

Requirements for Deferred Lighting 延时光照的需求

  • Requires Unity Pro.
    需要Unity专业版
  • Graphics card with Shader Model 3.0 (or later), support for Depth render textures and two-sided stencil buffer. Most graphics cards made after 2004 support it: GeForce FX and later, Radeon X1300 and later, Intel 965 / GMA X3100 and later.
    显示卡支持Shader Model 3.0(或更高),深度纹理渲染和双面模板缓冲特性。许多2004年后的显卡都支持:如Geforce Fx或更高,Radeon X1300或更高 Intel 965/ GMA X3100 或更高
  • Currently does not work on mobile platforms.
    目前在移动平台不支持。

Performance Considerations 性能注意事项

Cost of realtime lights in Deferred Lighting is proportional to number of pixels the light shines on; and not dependent on scene complexity. So small point or spot lights are very cheap to render. Point or spot lights that are fully or partially occluded by some scene objects get their pixels skipped on the GPU, so they are even cheaper.

延迟光照中实时光线的开销和光线照亮的像素值的数量成正比。而不取决于场景的复杂性。微小的点光源和聚光灯光源非常容易渲染。点光源或者完全或者部分被场景物体遮挡的聚光灯光源所照射的像素则被GPU所跳过,因此更加廉价。

Of course, lights with shadows are much more expensive than lights without shadows. In Deferred Lighting, shadow casters still need to be rendered once or more for each shadow-casting light. And the lighting shader that applies shadows is also more expensive than one without shadows.

当然,拥有阴影的光源比没有阴影的光源要昂贵许多。使用延迟光照,光影投射器仍然需要为每个阴影投射渲染一次或者多次。而且产生阴影的光线着色器也比不产生阴影的光线着色器要昂贵许多。

Implementation Details 实现细节

When Deferred Lighting is used, rendering process in Unity happens like this:

当延迟光照生效时,在Unity中发生的渲染过程如下:

  1. Base Pass: objects are rendered, producing screen-space buffers with depth, normals, and specular power.
    基本渲染:被渲染的对象产生带有深度,法线,和反射量的屏幕空间缓冲
  2. Lighting pass: lighting is computed using the previous buffers. Lighting is computed into another screen-space buffer.
    光照渲染:使用上一步的缓冲计算出光照。结果放入另一个屏幕空间缓存
  3. Final pass: objects are rendered again. They fetch computed lighting, combine it with color textures and add any ambient/emissive lighting.
    最后渲染:物体再次渲染。取来已经计算好的光线和颜色纹理混合在一起,然后再加上环境光以及散射光照。

Objects with shaders that can't handle Deferred Lighting are rendered after this process is done, using RenderTech-ForwardRendering path.

不能采用延迟光照技术的带阴影的物体在延迟光照渲染完后使用前向渲染路径处理。

Base Pass 基本渲染阶段

Base pass renders each object once. View space normals and specular power are rendered into single ARGB32 Render Texture (normals in RGB channels, specular power in A). If platform & hardware supports reading Z buffer as a texture, then depth is not explicitly rendered. If Z buffer can't be accessed as a texture, then depth is rendered in additional rendering pass, using shader replacement.

基本渲染将每个物体都渲染一次。视图空间法线和高光强度被渲染进单一的ARGB32渲染纹理(法线在RGB通道,高光强度在A通道)中。如果平台和硬件支持将Z缓冲按纹理读取,那么深度不会被明确的渲染。如果Z缓冲不能被以纹理的方式访问,那么深度将在额外的渲染处理中被使用着色器替代技术渲染。

Result of the base pass is Z buffer filled with scene contents and Render Texture with normals & specular power.

基本渲染的结果是被屏幕内容填满的Z缓冲和带有法线和高光强度的渲染纹理。

Lighting Pass 光照渲染阶段

Lighting pass computes lighting based on depth, normals and specular power. Lighting is computed in screen space, so it's independent of scene complexity. Lighting buffer is single ARGB32 Render Texture, with diffuse lighting in RGB channels and monochrome specular lighting in A channel. Lighting values are encoded using logarithmic encoding to provide extended dynamic range than usually possible with ARGB32 texture.

光照渲染基于深度,法线和高光强度计算光照。光照是被屏幕空间被计算的,因此和屏幕复杂性无关。光照缓冲是一个单一的ARGGB32渲染纹理,纹理的RGB通道带有漫反射的光照信息,在A通道带有单一特定颜色的光照。光照值采用对数值编码以产生比通常ARGB32纹理所能达到的动态扩展范围。

Lighting model is fixed to Blinn-Phong.

光照模式固定为Blinn-Phong。

Point and Spot lights that do not cross camera's near plane are rendered as 3D shapes, with Z buffer test against scene enabled. This makes partially or fully occluded Point and Spot lights very cheap to render. Directional lights and Point/Spot lights that cross the near plane are rendered as fullscreen quads.

不能跨越临近平面的点光源和聚光灯光源被作为带有开启测试场景的Z缓冲3D形状渲染,这部分和完全屏蔽的点光源和聚光灯光源可以非常廉价的渲染。 跨越临近区域的平行光或者点光源能作为全屏四边形。

If a light has shadows enabled, they are rendered and applies in this pass as well. Note that shadows are not "free"; shadow casters need to be rendered and a more complex light shader needs to be applied.

如果一个带有阴影的光源生效,在这个处理过程中会被很好的渲染。注意阴影并不免费,阴影投射器需要开销来渲染,同时一个更加复杂的光线着色器需要应用。

Final Pass 最后渲染阶段

Final pass produces final rendered image. Here all objects are rendered again; with shaders that fetch the lighting, combine it with textures and add any emissive lighting.

Lightmaps are also applied in the final pass. Close to the camera, realtime lighting is used, and only baked indirect lighting is added. This crossfades into fully baked lighting further away from the camera.

最终渲染阶段产生最后渲染后的图像,到这一步,所有的对象都将被再次渲染,其中着色器将混合前一步生成的光源和纹理以及所有自发光照明。

在最后渲染阶段光照贴图也被应用。靠近相机,使用实时光照,并仅烘焙间接光照。

posted on 2017-04-05 11:57 jiahuafu 阅读(...) 评论(...) 编辑 收藏

这篇关于前Forward / 延时Deferred的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/500328

相关文章

独立按键单击检测(延时消抖+定时器扫描)

目录 独立按键简介 按键抖动 模块接线 延时消抖 Key.h Key.c 定时器扫描按键代码 Key.h Key.c main.c 思考  MultiButton按键驱动 独立按键简介 ​ 轻触按键相当于一种电子开关,按下时开关接通,松开时开关断开,实现原理是通过轻触按键内部的金属弹片受力弹动来实现接通与断开。  ​ 按键抖动 由于按键内部使用的是机

Deferred shading技术简介

参考文章:http://blog.sina.com.cn/s/blog_458f871201017i06.html Deferred shading是这样一种技术:将光照/渲染计算推迟到第二步进行计算。我们这样做的目的是为了避免多次(超过1次)渲染同一个像素。 其基本思想如下: 1、在第一步中,我们渲染场景,但是与通常情况下应用反射模型计算片断颜色不同的是,我们只是简单的将几何信息(位置

前向保密(Forward Secrecy,也称为完美前向保密,Perfect Forward Secrecy,PFS)

前向保密(Forward Secrecy,也称为完美前向保密,Perfect Forward Secrecy,PFS)是一种加密通信协议的属性,它确保即使在未来某个时间点上长期使用的私钥(如服务器的私钥)被泄露,攻击者也无法解密之前已经捕获并记录的加密通信内容。这意味着每次通信会话都使用一个独立的、临时的会话密钥进行加密,即使主私钥被泄露,之前的通信记录也仍然保持安全。 工作原理 前向保密通常

ZET6程序换成VCT6程序,延时不对的解决办法

前言 已经写好了ZET6的程序,因为改板了,同一系列的芯片,程序也就改个芯片选项吗,可发现延时不准 提示:以下是本篇文章正文内容,下面案例可供参考 一、原因 启动文件注释了时钟初始化,ZET6使用是没有问题的,但是VCT6就会出错 二、解决办法 103VCT6是256K的FLASH所以,C++里还是用HD,所以其实大致不用改,就在Deveice选VCT6,程序基本能够编译通过

java ee之forward跳转中的那些坑

修正前: 修正后:‘ 还有一种错误,如下 修正前: 修正后: 或者 接下来的这个错误,与之前的雷同 修正前: 修正后: 完美解决。

SQL 注入之报错注入、延时注入、布尔盲注

在 SQL 注入攻击中,报错注入、延时注入和布尔盲注是常见的攻击手段。这些攻击方式利用了数据库系统在处理用户输入时的漏洞,从而获取敏感信息或者执行恶意操作。本文将详细介绍这三种 SQL 注入攻击方式的原理和实现方法。 一、报错注入 报错注入是利用数据库的错误信息来获取敏感信息的一种攻击方式。当数据库在处理用户输入时出现错误时,会返回详细的错误信息,攻击者可以通过分析这些错误信息来获取数据库

Linux中路由功能及ip_forward转发配置

操作系统中路由功能有着至关重要的作用,它决定了网络数据包如何在网络中传输,最终到达目的地。本文简要介绍Linux中的路由功能实现以及IP转发的配置,并验证在容器环境下配置net.ipv4.ip_forward的必要性,以加深理解。 1、Linux中路由功能 操作系统中路由功能有着至关重要的作用,它决定了网络数据包如何在网络中传输,最终到达目的地。当数据包从一个网络接口发送到另一个网络接口时

HAL库:轮询方式按键检测实现 抬起执行、按下执行、长按短按检测、延时执行

目录 注意事项 初始化部分: 按键检测部分: HAL库:轮询方式按键检测实现 抬起执行、按下执行、长按短按检测、延时执行 注意事项 按下执行一般与长按短按配合使用抬起执行一般与延时执行配合使用 初始化部分: 这里的按键为低电平有效。所以是上拉输入 void KEY_Init(void){__HAL_RCC_GPIOB_CLK_ENABLE();//开启GPIOB时钟GP

Deferred异步操作

首先再确定一下同步和异步的概念: 同步:同步不是指一起做!而是A完成后才能完成B!按部就班,顺序操作~ 异步:异步是可以同时执行~   了解Deferred的3个步骤 var dtd = $.Deferred();  //创建dtd.resolve();          //成功dtd.then()              //执行回调 实际例子: boy.walkTo(2