《Unity着色器圣经》1.1.5 | 我该使用哪种渲染管线?

目录索引

译文

应该为我们的项目选择哪种渲染管线呢?这是一个非常常见的疑问。Unity的早期版本只有内置渲染管线(Built-in RP),因此无论是 2D 还是 3D 项目,我们都不需要思考太多。但如今,我们必须根据项目的实际需求来选择渲染管线。我们具体应该选择哪种渲染管线呢?要回答这个问题,我们必须考虑以下因素:

  1. 如果我们要开发 PC 游戏,我们可以使用 Unity 三个渲染管线中的任何一个,因为一般来说 PC 的计算能力比移动设备或掌机都要大。如果我们想要高清晰度的游戏画面,我们可以使用高清渲染管线(HDRP)或内置渲染管线进行创建。
  2. 如果我们只需要中等清晰度的游戏画面,我们可以使用通用渲染管线(URP)或内置渲染管线。

为什么在这两种情况下都可以选择内置渲染管线?内置渲染管线更加灵活、技术含量更高,并且没有经过预先优化。HDRP 和 URP 都已经过预先优化,前者可以生成高端图像效果,后者可以生成中端图像效果。

选择渲染管线的另一个重要因素是着色器。一般来说,在 HDRP 和 URP 中,着色器都是在 Shader Graph 中创建的。 Shader Graph 是一种图形化编辑器,允许我们通过节点创建着色器。我们可以通过节点直观地调整着色器效果,而无需使用 HLSL 编写代码。但需要注意的是,如果我们升级项目的 Unity 的版本(例如从 2019 版升级到 2020 版),Shader Graph 很可能无法编译,因为 Shader Graph 的版本和更新与 Unity 的版本有关。

在 Unity 中创建着色器的最佳方法是使用 HLSL 语言编写,因为这样可以确保我们的着色器程序能够在不同的渲染管线中编译,并且无论项目的 Unity 版本是否升级都能继续工作。在下一章节中,我们将详细介绍 HLSL 的程序结构。


原文对照

This is a very common and recurring question these days. In the past, there was only Built-in RP, so it was very easy to start a project, be it in 2D or 3D. However, nowadays, we must start our video game according to its needs, so we may wonder, how could we know what our project needs? To answer this question, we must consider the following factors:

  1. If we are going to develop a PC video game we can use any of the three Unity render pipelines available since generally, a PC has larger computing power than a mobile device or even a console. Then, if our video game is for PC, do we need it to be viewed graphically in a high or medium definition? In the case that we require our video game in high definition, we can create it in both High Definition RP and Built-in RP.
  2. If we want our video game graphically in medium definition, we can use Universal RP or, as in the previous case; Built-in RP too. Now, why is Built-in RP an option in both cases?

Unlike the previous ones, this rendering pipeline is much more flexible, hence, it is much more technical and does not have pre-optimization. High Definition RP has been pre-optimized to generate high-end graphics, and Universal RP has been pre-optimized for mid-range graphics.

Another important factor when choosing our render pipeline is the shaders. Generally, in both High Definition RP and Universal RP, the shaders are created in Shader Graph, which is a package that includes an interface that allows us to create a shader through nodes, which has a positive and negative side. On the one hand, we can create shaders visually through nodes without the need to write code in HLSL, however, on the other hand, if we update our version of Unity to a newer version in production (e.g. from 2019 to 2020), the shaders will most likely stop compiling because Shader Graph has versions and updates independent of the version of Unity.

The best way to create shaders in Unity is through the HLSL language, since this way we can ensure that our program compiles in the different rendering pipelines and continues to work regardless of any Unity upgrade. Later in this chapter, we will review in detail the structure of a program in HLSL.

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容