《Unity着色器圣经》9.0.3 | 界面分析

目录索引

译文

我们已经知道,Shader Graph 的界面的样子取决于我们使用了哪个版本。在本节中,我们将详细介绍 Unity 2020.3.1f1 中对应的 10.4.0 版本 Shader Graph 的界面。

开始介 Shader Graph 的界面之前,我们需要先创建一个属于 URP 或 HDRP(取决于你的项目使用了哪一个渲染管线)的着色器。完成后,我们可以通过双击文件或点击检查器中的“Open Shader Editor(打开着色器编辑器)”按钮打开着色器的 Shader Graph 界面。

图片[1]-《Unity着色器圣经》9.0.3 | 界面分析-软件开发学习笔记
Fig. 9.0.3a

在打开的界面中,我们可以在顶部找到四个按钮,分别是:保存资产(Save Asset)黑板(Blackboard)图形检查器(Graph Inspector)主预览(Main preview),如下图所示:

图片[2]-《Unity着色器圣经》9.0.3 | 界面分析-软件开发学习笔记
Fig. 9.0.3b

Save Asset 允许我们保存 Shader Graph,与 Windows 下的 Ctrl + S 命令或 Mac 下的 Cmd + S 命令相同。

Blackboard 相当于 ShaderLab 中的属性。

通过代码(ShaderLab)创建着色器属性时,我们需要在属性语义块中进行声明。在 Shader Graph 中,我们只需点击菜单右上方的“+”按钮,即可在黑板中添加这些属性。

Graph Inspector 可用于修改着色器的节点和一般配置。该面板有两个选项卡,分别是“节点设置(Node Settings)”和“图形设置(Graph Setting)”,两者具有不同的功能。

在节点设置中,我们可以设置节点的名称属性、引用、默认值、模式、精度等等;在图形设置中,我们可以定义通用着色器配置,例如着色器是透明、叠加还是不透明。

最后,主预览(Main Preview)可以查看当前 Shader Graph 的输出预览。主预览的一个有趣功能是,它允许您导入自定义对象,以查看材质在模型上的实际呈现。要导入自定义对象,只需右击预览区域并选择“自定义网格”即可。

图片[3]-《Unity着色器圣经》9.0.3 | 界面分析-软件开发学习笔记
Fig. 9.0.3c

原文对照

As we already know, the Shader Graph interface has structural changes depending on the version we are using. In this section, we will detail update number 10.4.0 that corresponds to the package included in Unity 2020.3.1f1. Now, regardless of its reference, the analogy between the different versions will be the same, therefore, if you have reached this point in the book, you will be able to clearly understand its interface and different properties.

To start in the Shader Graph interface, we must have previously created a shader belonging to Universal RP or High Definition RP, as appropriate. Once we have a shader in our Project, we can open it by double-clicking on it or by pressing the “Open Shader Editor” button found in the Inspector.

图片[1]-《Unity着色器圣经》9.0.3 | 界面分析-软件开发学习笔记
Fig. 9.0.3a

On its interface we can find four main buttons that define part of its functionalities, these buttons correspond to Save Asset, Blackboard, Graph Inspector and Main Preview.

图片[2]-《Unity着色器圣经》9.0.3 | 界面分析-软件开发学习笔记
Fig. 9.0.3b

The Shader Graph interface looks like the example above.

Save Asset allows us to save the internal configuration of the shader and works in the same way as the Ctrl+S command for Windows or Cmd+S in the case of a Mac.

Blackboard is the direct analogy of properties in ShaderLab.

As we already know, if we want to create a property in a shader via code, we must add it within the Properties in declarative language. In Shader Graph it is practically the same with the difference that they are added in the Blackboard by pressing the “plus” button located at the top right of the menu.

Graph Inspector is a small panel that allows you to modify the node and general configuration of the shader. This panel has two tabs which are: Node Settings and Graph Setting; both with different functionalities.

Node Settings allows you to name properties, references, default values, mode, precision, and others, while Graph Settings allows you to define the general shader configuration, e.g. if our shader will be transparent, additive or opaque.

Finally, Main Preview activates or deactivates the node configuration preview, ideal for previewing the effect (set of nodes) that are being developed. An interesting feature of the preview pane is that it allows you to import custom objects to see the actual representation of the effect on an element. To import a custom object, simply right-click on the preview area and select “Custom Mesh”.

图片[3]-《Unity着色器圣经》9.0.3 | 界面分析-软件开发学习笔记
Fig. 9.0.3c
© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容