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

简介:

正向渲染路径细节 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.

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

本文转自jiahuafu博客园博客,原文链接http://www.cnblogs.com/jiahuafu/p/6668116.html如需转载请自行联系原作者


jiahuafu

相关文章
|
人工智能 程序员
仅仅10秒,AI 能将你的静态图片转换成视频
仅仅10秒,AI 能将你的静态图片转换成视频
2106 0
仅仅10秒,AI 能将你的静态图片转换成视频
|
7月前
|
数据采集 Web App开发 API
B站高清视频爬取:Python爬虫技术详解
B站高清视频爬取:Python爬虫技术详解
|
机器学习/深度学习 人工智能 安全
GPT-4硬核揭秘:能力,操纵性,局限性,聊天GPT Plus等
OpenAI创建了 GPT-4,这是 OpenAI 扩大深度学习努力的最新里程碑...
644 0
|
10月前
|
编解码 人工智能 开发框架
《鸿蒙HarmonyOS应用开发从入门到精通(第2版)》学习笔记——HarmonyOS技术理念
HarmonyOS在万物智联时代提出了三大技术理念:一次开发,多端部署;可分可合,自由流转;统一生态,原生智能。通过多端开发环境、多端开发能力和多端分发机制,HarmonyOS显著降低了开发成本,提升了开发效率。开发者只需一套工程即可实现多设备应用的高效开发与部署。元服务作为轻量化程序实体,支持跨设备无缝流转,提供便捷服务。同时,HarmonyOS内置强大的AI能力,助力开发者快速实现应用智能化。
440 16
|
9月前
|
监控 安全 网络协议
计算机端口:网络通信的桥梁
计算机端口是网络通信的逻辑通道,支持数据传输和服务识别。本文介绍端口定义、分类(知名、注册、动态端口)、作用及管理方法,涵盖常用知名端口如HTTP(80)、HTTPS(443)等,并强调端口安全配置的重要性,帮助读者全面理解这一关键组件。
483 6
|
数据可视化 图形学 开发者
【实现100个unity特效之4】Unity ShaderGraph使用教程与各种特效案例(上)
【实现100个unity特效之4】Unity ShaderGraph使用教程与各种特效案例
2251 59
|
11月前
|
安全 网络安全 数据安全/隐私保护
如何识别和防范网络诈骗?
识别和防范网络诈骗需要我们时刻保持警惕,仔细核实信息,保护好个人信息和财产安全,遇到可疑情况及时与相关机构或警方联系,共同打击网络诈骗行为。
682 13
|
11月前
|
机器学习/深度学习 JSON API
Python编程实战:构建一个简单的天气预报应用
Python编程实战:构建一个简单的天气预报应用
496 1
|
12月前
|
消息中间件 数据采集 数据库
小说爬虫-03 爬取章节的详细内容并保存 将章节URL推送至RabbitMQ Scrapy消费MQ 对数据进行爬取后写入SQLite
小说爬虫-03 爬取章节的详细内容并保存 将章节URL推送至RabbitMQ Scrapy消费MQ 对数据进行爬取后写入SQLite
177 1
|
XML 监控 安全
Android App性能优化之卡顿监控和卡顿优化
本文探讨了Android应用的卡顿优化,重点在于布局优化。建议包括将耗时操作移到后台、使用ViewPager2实现懒加载、减少布局嵌套并利用merge标签、使用ViewStub减少资源消耗,以及通过Layout Inspector和GPU过度绘制检测来优化。推荐使用AsyncLayoutInflater异步加载布局,但需注意线程安全和不支持特性。卡顿监控方面,提到了通过Looper、ChoreographerHelper、adb命令及第三方工具如systrace和BlockCanary。总结了Choreographer基于掉帧计算和BlockCanary基于Looper监控的原理。
263 3