[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

相关推荐
Bluesonli8 小时前
第 9 天:UE5 物理系统 & 碰撞检测全解析!
开发语言·学习·游戏·ue5·虚幻·unreal engine
Bluesonli8 小时前
第 10 天:UE5 交互系统,拾取物品 & 触发机关!
学习·游戏·ue5·虚幻·unreal engine
带帯大师兄8 小时前
UE5.5 PCGFrameWork--GPU CustomHLSL
ue5·ue5 pcg
清泓y9 小时前
UE5--浅析委托原理(Delegate)
c++·ue5·ue4
阿运河11 小时前
UE5 如何通过命令行启动游戏工程
游戏·ue5
▍ 小太阳 ☼2 天前
UE5导入模型报错:多边形退化
ue5
灵境引路人2 天前
【虚幻引擎UE】UE4.23到UE5.5的核心功能变化
ue5·ue4·虚幻
我的巨剑能轻松搅动潮汐5 天前
UE5.1蓝图节点禁用编译
ue5
我命由我123456 天前
游戏引擎 Unity - Unity 打开项目、Unity Editor 添加简体中文语言包模块、Unity 项目设置为简体中文
c语言·开发语言·c++·unity·ue5·c#·游戏引擎