[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

相关推荐
ue星空16 小时前
UE5音频技术
ue5
帅_shuai_11 天前
UE5 游戏模板 —— FirstShootGame
游戏·ue5
吴梓穆12 天前
UE5 手动停止Delay定时器
ue5
AgilityBaby14 天前
UE5蓝图按键输入绑定学习笔记
笔记·学习·ue5·蓝图
涟涟涟涟14 天前
UE5错误 Linux离线状态下错误 请求失败libcurl错误:6无法解析主机名
linux·ue5
蛋卷卷-14 天前
【UE5】如何开发安卓项目的udp客户端
android·ue5·udp
异次元的归来16 天前
UE5反射系统分析(一)generated.h
ue5·游戏引擎·unreal engine
道之所在16 天前
UE5.6源码安卓打包报错
android·ue5
AgilityBaby16 天前
UE5创建蒙太奇动画并播放和在动画蒙太奇中创建动画通知状态
笔记·学习·ue5·游戏引擎·蓝图·蒙太奇动画
北冥没有鱼啊16 天前
UE5 仿 鸣潮人物渲染
ue5·游戏开发·虚幻·材质