正向渲染路径细节 Forward Rendering Path Details

Forward Rendering path renders each object in one or more passes, depending on lights that affect the object. Lights themselves are also treated differently by Forward Rendering, depending on their settings and intensity.

根据影响物体的光源的不同,正向渲染路径用单个或多个通道来渲染物体。在正向渲染中,光源本身也会根据他们的设置和强度受到不同的对待。

Implementation Details 实现细节

In Forward Rendering, some number of brightest lights that affect each object are rendered in fully per-pixel lit mode. Then, up to 4 point lights are calculated per-vertex. The other lights are computed as Spherical Harmonics (SH), which is much faster but is only an approximation. Whether a light will be per-pixel light or not is dependent on this:

在正向渲染中,影响物体的最亮的几个光源使用逐像素光照模式。接下来,最多有4个点光源会以逐顶点渲染的方式被计算。其他光源将以球面调和(Spherical Harmonics)的方式进行计算,球面调和技术计算很快但只能得到近似值。根据以下的规则判断一个光源是否为逐像素光源:

  • Lights that have their Render Mode set to Not Important are always per-vertex or SH. 
    渲染模式被设置为不重要(Not Important)的光源以逐顶点或球面调和的方式进行计算
  • Brightest directional light is always per-pixel. 
    最亮的方向光源为像素光源
  • Lights that have their Render Mode set to Important are always per-pixel. 
    渲染模式被设置重要(Important)的光源为像素光源
  • If the above results in less lights than current Pixel Light Count Quality Setting, then more lights are rendered per-pixel, in order of decreasing brightness. 
    如根据以上规则得到的像素光源数量小于质量设置中的像素光源数量(Pixel Light Count),为了减少亮度,会有更多的光源以逐像素的方式进行渲染

Rendering of each object happens as follows:

用以下的方法渲染每个物体:

  • Base Pass applies one per-pixel directional light and all per-vertex/SH lights. 
    基础通道渲染一个逐像素方向光和所有的逐顶点/球面调和光。
  • Other per-pixel lights are rendered in additional passes, one pass for each light. 
    其他逐像素光在附加的通道中进行渲染,每个光源都需要一个通道

For example, if there is some object that's affected by a number of lights (a circle in a picture below, affected by lights A to H):

例如,如果有一个物体受到若干光源的影响(下图中的圆圈,受到光源A到H的影响)

Let's assume lights A to H have the same color & intensity, all all of them have Auto rendering mode, so they would be sorted in exactly this order for this object. The brightest lights will be rendered in per-pixel lit mode (A to D), then up to 4 lights in per-vertex lit mode (D to G), and finally the rest of lights in SH (G to H):

假设光源A到H都有相同的颜色和强度,且它们的渲染模式都为自动的(Auto),那么它们严格的按照其名字排序。最亮的光源以逐像素光照模式的方式进行渲染(A到D),然后最多有4个光源以逐顶点光照模式进行渲染(D到G),其他光源以球面调和的方式进行渲染(G到H)。

Note that light groups overlap; for example last per-pixel light blends into per-vertex lit mode so there are less "light popping" as objects and lights move around.

注意不同的光照组间有重叠,如,最后一个逐像素光源也以逐顶点光照模式的方式渲染,这样能减少当物体和灯光移动时可能出现的"光照跳跃"现象。

Base Pass 基本通道

Base pass renders object with one per-pixel directional light and all SH lights. This pass also adds any lightmaps, ambient and emissive lighting from the shader. Directional light rendered in this pass can have Shadows. Note that Lightmapped objects do not get illumination from SH lights.

基础通道用一个逐像素方向光和所有球面调和光渲染物体。此通道还负责渲染着色器中的光照贴图,环境光和自发光。在此通道中渲染的方向光可以产生阴影。需要注意的是,使用了光照贴图的物体不会得到球面调和光的光照。

Additional Passes 附加通道

Additional passes are rendered for each additional per-pixel light that affect this object. Lights in these passes can't have shadows (so in result, Forward Rendering supports one directional light with shadows).

附加通道用于渲染影响物体的其他逐像素光源。这些通道中渲染的光源无法产生阴影(因此,前向渲染支持一个能产生阴影的方向光)。

Performance Considerations 性能注意事项

Spherical Harmonics lights are very fast to render. They have a tiny cost on the CPU, and are actually free for the GPU to apply (that is, base pass always computes SH lighting; but due to the way SH lights work, the cost is exactly the same no matter how many SH lights are there).

渲染球面调和光很快。它们只花费很少的CPU计算时间,并且实际上无需花费任何GPU计算时间(换言之,基础通道会计算球面调和光照,但由于球面调和光的计算方式,无论有多少球面调和光源,计算它们所花费的时间都是相同的)。

The downsides of SH lights are:

球面调和光源的缺点有:

  • They are computed at object's vertices, not pixels. This means they do not support light Cookies or normal maps. 
    它们计算的是物体的顶点而不是像素。这意味着它们不支持投影遮罩和发现贴图。
  • SH lighting is very low frequency. You can't have sharp lighting transitions with SH lights. They are also only affecting the diffuse lighting (too low frequency for specular highlights). 
    球面调和光只有很低的频率。球面调和光不能产生锋利的照明过渡。它们也只会影响散射光照(对高光来说,球面调和光的频率太低了)。
  • SH lighting is is not local; point or spot SH lights close to some surface will "look wrong". 
    球面调和不是局部的,靠近曲面的球面调和点光和聚光可能会"看起来不正确"。

In summary, SH lights are often good enough for small dynamic objects.

总的来说,球面调和光的效果对小的动态物体来说已经足够好了。

前向渲染路径细节 Forward Rendering Path Details的更多相关文章

  1. 正向渲染路径细节 Forward Rendering Path Details

    http://www.ceeger.com/Components/RenderTech-ForwardRendering.html This page describes details of For ...

  2. Unity shader学习之Forward Rendering Path

    Forward rendering path shader如下: // Upgrade NOTE: replaced 'mul(UNITY_MATRIX_MVP,*)' with 'UnityObje ...

  3. Thinking in Unity3D:渲染管线中的Rendering Path

      关于<Thinking in Unity3D> 笔者在研究和使用Unity3D的过程中,获得了一些Unity3D方面的信息,同时也感叹Unity3D设计之精妙.不得不说,笔者最近几年的 ...

  4. Unity3D光照前置知识——Rendering Paths(渲染路径)及LightMode(光照模式)译解

    简述 Unity supports different Rendering Paths. You should choose which one you use depending on your g ...

  5. Rendering Path

    Rendering Path:渲染路径 设置:1.Player Setting,2.Camera(会覆盖PlayerSetting中的设置) 选择:根据渲染内容和目标平台来选择合适的Rendering ...

  6. Deferred shading rendering path翻译

    Overview 概述 When using deferred shading, there is no limit on the number of lights that can affect a ...

  7. 渲染路径-Deferred Lighting 延时光照

    http://blog.csdn.net/heyuchang666/article/details/51564954 注意: 最后3个步骤注意下 延时光照是有着最高保真度的光照和阴影的渲染路径.如果你 ...

  8. shader 3 rendering path

    渲染通道, rendering path. vertexlit, forward 和 Deferred lighting 旧有的非统一架构下: 分为顶点着色引擎和像素渲染通道 渲染通道是GPU负责给图 ...

  9. Unity Lighting - Choosing a Rendering Path 选择渲染路径(三)

      Choosing a Rendering Path 选择渲染路径 Unity supports a number of rendering techniques, or ‘paths’. An i ...

随机推荐

  1. jstl_core标签库

    先导入这个 <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 1 & ...

  2. PHP设置脚本最大执行时间的三种方法

    php.ini 中缺省的最长执行时间是 30 秒,这是由 php.ini 中的 max_execution_time 变量指定,如果脚本需要跑很长时间,例如要大量发送电子邮件,或者分析统计大量数据,服 ...

  3. GNU Radio: 自定义 block 实例

    综述 本文通过在GNU Radio 中编写一个block的例子,系统介绍创建一个block的过程.该 block 的功能是可以在GRC中通过滑块(WX GUI Slider)来实时改变信号源(Sign ...

  4. erlang里面中文相关处理

    在控制台输出的话 Name = "测试数据", io:format("~ts~n",[Name]). 如果是和客户端通信,假如都是utf8编码 服务器获取的时候 ...

  5. JVM内存管理之杂谈(借此也论一论obj=null)

    作为一个程序猿,修炼的过程就犹如玄幻小说中的主角,不仅需要练习各种武技,内气的修炼的一样重要.虽然武技可以迅速的提升主角的实力,但是在内气太差的情况下,根本发挥不出武技的十之一二. 因此,在介绍过设计 ...

  6. linux命令之awk

    简介 awk命令的名称是取自三位创始人Alfred Aho .Peter Weinberger 和 Brian Kernighan姓名的首字母,awk有自己的程序设计语言,设计简短的程序,读入文件,数 ...

  7. mybatis 面试

    1.接口绑定有几种实现方式,分别是怎么实现的? 接口绑定有两种实现方式,一种是通过注解绑定,就是在接口的方法上面加上 @Select@Update等注解里面包含Sql语句来绑定, 另外一种就是通过xm ...

  8. Zookeeper--分布式锁和消息队列

    在java并发包中提供了若干锁的实现,它们是用于单个java虚拟机进程中的:而分布式锁能够在一组进程之间提供互斥机制,保证在任何时刻只有一个进程可以持有锁. 分布式环境中多个进程的锁则可以使用Zook ...

  9. 【BZOJ】1913: [Apio2010]signaling 信号覆盖(计算几何+计数)

    题目 传送门:QWQ 分析 人类智慧题,不会做...... 详细题解1      详细题解2 总体思路是考虑四边形 讨论凹四边形凸四边形,最后加一个单调性优化省掉个$ O(n) $ 代码 代码感觉好短 ...

  10. Futures

    Futures is a framework for expressing asynchronous code in C++ using the Promise/Future pattern. Ove ...