Custom Code 示例
This material graph sample demonstrates how to create and use nodes containing a custom shader code.此材质图表示例演示了如何创建和使用包含自定义着色器代码的节点。
Albedo RGB value for the material of the Mesh Opaque PBR type is specified directly using a Float node (casting to float3 is performed automatically).Mesh Opaque PBR 类型材质的反照率RGB 值直接使用 Float 节点指定(自动转换为 float3)。
The Function node has two float input ports (A and B) and two float output ports (return value Out and C output). They are automatically added according to the function signature:Function 节点有两个 float 输入端口(A 和 B)和两个 float 输出端口(返回值 Out 和 C 输出)。它们是根据函数签名自动添加的:
float function_1(in float a, in float b, out float c)
{
c = lerp(a, b, 0.5f);
return a+b;
}
A and B values for the custom function node are provided by Slider parameter nodes (adjustable via the Parameters panel in UnigineEditor) connected to it.自定义函数节点的 A 和 B 值由与其相连的 Slider 参数节点(可通过 UnigineEditor 中的 Parameters 面板调整)提供。
The result of linear interpolation between A and B values is connected to the Roughness input port of the master material node, while the sum of A and B — to Metalness.A 和 B 值之间线性插值的结果连接到主材质节点的 Roughness 输入端口,而 A 和 B 之和 - 连接到 Metalness。
Finally, the data output is passed to the Final node.最后,将数据输出传递给 Final 节点。