[UE5] 在Custom 节点中自定义函数

在Custom节点中直接定义函数是会报错的

float MyFunction(float A, float B)

{

return A + B;

}

return MyFunction(Input0, Input1);

error: function definition is not allowed here.

原因是我们写的custom代码最终是被生成到一个临时的Material.ush文件中。

需要改成如下这样:

struct CustomFunctions // 任何名字都可以

{

float test(float x)

{

return x;

}

};

CustomFunctions CF;

float4 fragColor = CF.test(0);

return fragColor;

参考:

Can't define function in hlsl on custom shader node. - #2 by martinortiz - Programming & Scripting - Epic Developer Community Forums

相关推荐
Vince丶1 天前
UE DirectExcel使用笔记
笔记·ue5
AA陈超1 天前
Lyra学习004:GameFeatureData分析
c++·笔记·学习·ue5·虚幻引擎
平行云PVT1 天前
实时云渲染解决UE5 像素流插件迁移及传输数据受限问题
unity·ue5·xr·实时云渲染·云桌面·像素流·云推流
AA陈超2 天前
LyraRPG:001.创建RPGCore插件
c++·笔记·学习·ue5·虚幻引擎·lyra
AA陈超2 天前
Lyra学习6:GameFeatureAction_AddComponents分析
c++·笔记·学习·ue5
曼巴UE52 天前
UE5 C++ 多播绑定执行演示
c++·ue5
曼巴UE52 天前
UE5 C++ TSet 创建初始和迭代
java·c++·ue5
AA陈超2 天前
Lyra学习5:GameFeatureAction分析
c++·笔记·学习·ue5·lyra
zhangzhangkeji3 天前
UMG - 18:尺寸框里的按钮属性,按钮包含文本框,以此来了解按钮的尺寸属性与颜色属性
ue5
小宝哥Code3 天前
UE5在布局自定义上的UE4ClassicLayout.ini文件源码解读分析
java·ue5·ue4