码迷,mamicode.com
首页 > 其他好文 > 详细

Deferred shading rendering path翻译

时间:2020-01-14 09:20:52      阅读:122      评论:0      收藏:0      [点我收藏+]

标签:for   设置   大于   光照模型   you   min   multiple   rom   xxx   

Overview 概述

 

When using deferred shading, there is no limit on the number of lights that can affect a GameObject. All lights are evaluated per-pixel, which means that they all interact correctly with normal maps, etc. Additionally, all lights can have cookies and shadows.

使用延迟着色时,对游戏对象有影响的光源数量没有限制。所有光都被逐像素估算,这意味着他们都正确地与法线贴图等交互。另外所有光都有cookies(不知道怎么准确翻译,是类似剪影的贴图的东西)和阴影。

 

Deferred shading has the advantage that the processing overhead of lighting is proportional to the number of pixels the light shines on. This is determined by the size of the light volume in the Scene regardless of how many GameObjects it illuminates. Therefore, performance can be improved by keeping lights small. Deferred shading also has highly consistent and predictable behaviour. The effect of each light is computed per-pixel, so there are no lighting computations that break down on large triangles.

延迟着色的优点在于光照开销与光照亮的像素数量成正比。这取决于光的体积在场景中的大小而不是它照亮了多少游戏对象。因此保持小(体积)的光能够提升性能。延迟着色也拥有高度一致和可预测的行为。每个光的效果是逐像素计算的,因此光照计算在大的三角形时不会出现崩溃。

 

On the downside, deferred shading has no real support for anti-aliasing and can’t handle semi-transparent GameObjects (these are rendered using forward rendering). There is also no support for the Mesh
Renderer’s Receive Shadows flag and culling masks are only supported in a limited way. You can only use up to four culling masks. That is, your culling layer mask must at least contain all layers minus four arbitrary layers, so 28 of the 32 layers must be set. Otherwise you get graphical artifacts.

从缺点来看,延迟着色没有真正支持抗锯齿,并且无法处理半透明的游戏对象(他们是用前向渲染的)。也不支持网格渲染器的接受阴影标记(启用后可以显示投射在网格上的阴影)并且对culling mask的支持也是受限的。你最多使用4个剔除遮罩(是light的Culling Mask),即32个层最少勾选28个。 在unity上测试,当light.cullingMask不渲染的层超过4个时,就会出现不正确的图。

 

Requirements 要求

It requires a graphics card with Multiple Render Targets (MRT), Shader Model 3.0 (or later) and support for Depth render textures. Most PC graphics cards made after 2006 support deferred shading, starting with GeForce 8xxx, Radeon X2400, Intel G45.

pc上使用延迟着色需要一张有MRT(一帧里可以同时渲染多个渲染目标)功能和shader model3.0功能并且支持深度渲染纹理的显卡。从GeForce 8xxx, Radeon X2400, Intel G45开始,大部分06年以后的显卡支持延迟着色。

 

On mobile, deferred shading is supported on all devices running at least OpenGL ES 3.0.

在移动平台上,只有那些有OpenGL3.0的设备支持延迟着色。

 

Note: Deferred rendering is not supported when using Orthographic projection. If the Camera’s projection mode is set to Orthographic, the Camera falls back to Forward rendering.

注意:使用正交投影时延迟着色是不支持的。如果摄像机的投影模式是正交投影,摄像机会回退到前向渲染。

 

Performance considerations 性能注意事项

The rendering overhead of realtime lights in deferred shading is proportional to the number of pixels illuminated by the light and not dependent on Scene complexity. So small point or spot lights are very cheap to render and if they are fully or partially occluded by Scene GameObjects then they are even cheaper.

延迟着色的实时光渲染开销跟光照亮的像素成正比,并不取决于场景复杂度。所以渲染小的点光源或者聚光灯的开销非常小,如果他们被场景里的物体完全或者部分遮挡那么消耗将更小。

 

Of course, lights with shadows are much more expensive than lights without shadows. In deferred shading, shadow-casting GameObjects still need to be rendered once or more for each shadow-casting light. Furthermore, the lighting shader that applies shadows has a higher rendering overhead than the one used when shadows are disabled.

带阴影的光开销显然大于不带阴影的光。延迟着色中,依然需要为每个投影光渲染一次或更多次的投影物体。此外,应用阴影的光照着色器比不用的有更高的开销。

 

Implementation details 实现细节

Objects with Shaders that do not support deferred shading are rendered after deferred shading is complete, using the forward rendering path.

不支持延迟着色的带有着色器的物体将在延迟渲染完成后通过前向渲染路径进行渲染。

 

The default layout of the render targets (RT0 - RT4) in the geometry buffer (g-buffer) is listed below. Data types are placed in the various channels of each render target. The channels used are shown in parentheses.

在几何缓存中,渲染目标的默认布局如下所列。数据类型被存放在每个渲染目标的各个通道中。所用通道显示在在括号里。

  • RT0, ARGB32 format: Diffuse color (RGB), occlusion (A).  RT0 ARGB32(每个通道分别是8bit)格式:漫反射颜色 (RGB),遮挡(A)
  • RT1, ARGB32 format: Specular color(RGB), roughness (A).  RT1, ARGB32 格式:高光颜色(RGB),粗糙度(A)。
  • RT2, ARGB2101010 format: World space normal (RGB), unused (A).  RT2,ARGB2101010 (alpha通道为两位,其余通道均为10位)格式:世界坐标法线(RGB),未使用(A)。
  • RT3, ARGB2101010 (non-HDR) or ARGBHalf (HDR) format: Emission + lighting + lightmaps + reflection probes buffer.  RT3,ARGB2101010 (non-HDR非高动态范围) 或者ARGBHalf(每个通道分别是16位的浮点数)(HDR高动态范围):自发光+光照+光照贴图+反射探针缓冲。
  • Depth+Stencil buffer.  深度+模板缓冲。

So the default g-buffer layout is 160 bits/pixel (non-HDR) or 192 bits/pixel (HDR).

所以默认的几何缓冲布局是每像素160位 (non-HDR) 或者192位 (HDR) 。

 

If using the Shadowmask or Distance Shadowmask modes for Mixed lighting, a fifth target is used:

  • RT4, ARGB32 format: Light occlusion values (RGBA).

如果为混合光照使用Shadowmask或者Distance Shadowmask模式,第五个对象将会被使用:
RT4,ARGB32格式:光遮挡值(RGBA)

 

And thus the g-buffer layout is 192 bits/pixel (non-HDR) or 224 bits/pixel (HDR).

因此几何缓冲布局是每像素192位(non-HDR)或者224位(HDR)。

 

If the hardware does not support five concurrent rendertargets then objects using shadowmasks will fallback to the forward rendering path. Emission+lighting buffer (RT3) is logarithmically encoded to provide greater dynamic range than is usually possible with an ARGB32 texture, when the Camera is not using HDR.

如果硬件不支持五个并行的渲染目标,那么物体使用阴影蒙版时会回退到前向渲染路径。当相机没有使用HDR时,自发光+光照缓冲(RT3)是对数编码的以提供比通常ARGB32纹理更好的动态范围。

 

Note that when the Camera is using HDR rendering, there’s no separate rendertarget being created for Emission+lighting buffer (RT3); instead the rendertarget that the Camera renders into (that is, the one that is passed to the image effects) is used as RT3.

注意,当相机使用HDR渲染时,没有为自发光+光照缓冲生成单独的渲染目标;相反摄像机渲染的目标(传递给图像效果的那个)被用作RT3。

 

G-Buffer pass几何缓冲通道

The g-buffer pass renders each GameObject once. Diffuse and specular colors, surface smoothness, world space normal, and emission+ambient+reflections+lightmaps are rendered into g-buffer textures. The g-buffer textures are setup as global shader properties for later access by shaders (CameraGBufferTexture0 .. CameraGBufferTexture3 names).

几何缓冲通道渲染每个游戏对象一次。漫反射和镜面高光颜色,表面平滑度,世界空间法向量,和自发光+环境+反射光+光照贴图都被渲染进几何缓冲纹理。几何缓冲纹理被设置成全局着色器属性,为了着色器之后访问(命名为CameraGBufferTexture0 .. CameraGBufferTexture3)。

 

Lighting pass光照通道

The lighting pass computes lighting based on g-buffer and depth. Lighting is computed in screen space, so the time it takes to process is independent of Scene complexity. Lighting is added to the emission buffer.

光照通道基于几何缓冲和深度计算光照。光照是在屏幕空间被计算的,所以计算的时间与场景复杂度无关。光照被添加到自发光缓冲。

 

Point and spot lights that do not cross the Camera’s near plane are rendered as 3D shapes, with the Z buffer’s test against the 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.

没有与摄像机的近裁剪面交叉的点光源和聚光灯被当做3D图形渲染,并且针对场景的深度值测试是启用的。与近裁剪面相交的平行光和点光源/聚光灯被渲染成全屏四边形。

 

If a light has shadows enabled then they are also rendered and applied in this pass. Note that shadows do not come for “free”; shadow casters need to be rendered and a more complex light shader must be applied.

如果光的阴影是启用的,那么他们将会在这个通道里渲染和应用。注意阴影并不是“免费”的;阴影投射器需要被渲染并且需要应用一个更加复杂的光照着色器。

 

The only lighting model available is Standard. If a different model is wanted you can modify the lighting pass shader, by placing the modified version of the Internal-DeferredShading.shader file from the Built-in shaders into a folder named “Resources” in your “Assets” folder. Then open the Graphics settings (menu: Edit > Project Settings, then click the Graphics category). Change the “Deferred” dropdown to “Custom Shader”. Then change the Shader option which appears to the shader you are using.

唯一可用的光照模型是Standard。如果需要不同模型,你可以通过放置内置延迟着色的修改版本,用于修改光照通道着色器。着色器文件从内置着色器进入到Assets/Resources文件夹下。然后打开Graphics设置(菜单:Edit > Project Settings,然后点击Graphics类别)。修改“Deferred”下拉框为“Custom Shader”。然后将着色器选项改成你所使用的着色器。

Deferred shading rendering path翻译

标签:for   设置   大于   光照模型   you   min   multiple   rom   xxx   

原文地址:https://www.cnblogs.com/pj2933/p/12190225.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!