前向渲染路径细节 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. 根据影响物体的光源的不同,正向渲染路径用单个或多个通道来渲染物体。

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

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

相关文章
|
SQL XML Java
MyBatis-Plus——代码生成器(3.5.1+版本)
MyBatis-Plus——代码生成器(3.5.1+版本)
2596 0
MyBatis-Plus——代码生成器(3.5.1+版本)
|
8月前
|
移动开发
NotePad++使用批量替换修改文件格式
NotePad++使用批量替换修改文件格式
199 12
NotePad++使用批量替换修改文件格式
|
8月前
|
机器学习/深度学习 C语言 计算机视觉
RT-DETR改进策略【Neck】| HS-FPN:高级筛选特征融合金字塔,加强细微特征的检测
RT-DETR改进策略【Neck】| HS-FPN:高级筛选特征融合金字塔,加强细微特征的检测
255 12
RT-DETR改进策略【Neck】| HS-FPN:高级筛选特征融合金字塔,加强细微特征的检测
|
9月前
|
人工智能 测试技术
陶哲轩联手60多位数学家出题,世界顶尖模型通过率仅2%!专家级数学基准,让AI再苦战数年
著名数学家陶哲轩联合60多位数学家推出FrontierMath基准测试,评估AI在高级数学推理方面的能力。该测试涵盖数论、实分析等多领域,采用新问题与自动化验证,结果显示最先进AI通过率仅2%。尽管存在争议,这一基准为AI数学能力发展提供了明确目标和评估工具,推动AI逐步接近人类数学家水平。
330 37
|
8月前
|
运维 自然语言处理 Ubuntu
OS Copilot-操作系统智能助手-Linux新手小白的福音
OS Copilot 是阿里云推出的一款操作系统智能助手,专为Linux新手设计,支持自然语言问答、辅助命令执行和系统运维调优等功能。通过简单的命令行操作,用户可以快速获取所需信息并执行任务,极大提升了Linux系统的使用效率。安装步骤简单,只需在阿里云服务器上运行几条命令即可完成部署。使用过程中,OS Copilot不仅能帮助查找命令,还能处理文件和复杂场景,显著节省了查找资料的时间。体验中发现,部分输出格式和偶尔出现的英文提示有待优化,但整体非常实用,特别适合Linux初学者。
396 10
|
10月前
|
机器学习/深度学习 人工智能 自然语言处理
Llama 3.3:Meta AI 开源新的纯文本语言模型,专注于多语言对话优化
Meta AI推出的Llama 3.3是一款70B参数的纯文本语言模型,支持多语言对话,具备高效、低成本的特点,适用于多种应用场景,如聊天机器人、客户服务自动化、语言翻译等。
385 13
Llama 3.3:Meta AI 开源新的纯文本语言模型,专注于多语言对话优化
|
运维 Shell Linux
运维专题.Docker功能权限(Capabilities)管理和查看
运维专题.Docker功能权限(Capabilities)管理和查看
612 1
|
10月前
|
监控 安全 网络安全
云计算与网络安全:技术挑战与解决方案
随着云计算技术的飞速发展,其在各行各业的应用越来越广泛。然而,随之而来的网络安全问题也日益凸显。本文将从云服务、网络安全和信息安全等技术领域出发,探讨云计算面临的安全挑战及相应的解决方案。通过实例分析和代码示例,旨在帮助读者更好地理解云计算与网络安全的关系,提高网络安全防护意识。
|
安全 测试技术 API
API 测试是什么?如何进行 API 测试?
在互联网时代,API已成为软件间交互的关键。API测试验证API是否按预期工作,通过检查响应来确保其正确性、可靠性和安全性。与UI测试不同,API测试聚焦底层功能,有助于早期发现并修复缺陷。它能验证软件质量、加速开发周期、促进微服务架构并支持持续集成/交付。常见的测试类型包括单元测试、功能测试、集成测试、性能测试、安全测试及回归测试。使用自动化工具如Apifox能提高测试效率,支持可视化编排、零代码配置流程条件、生成详细测试报告及快速性能测试,从而确保API质量并提升用户体验。
|
安全 存储 网络安全
信息安全管理与评估DCST-6000B-Pro神州数码堡垒机沙箱连接教程
信息安全管理与评估DCST-6000B-Pro神州数码堡垒机沙箱连接教程
信息安全管理与评估DCST-6000B-Pro神州数码堡垒机沙箱连接教程