[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

相关推荐
四代水门6 天前
UE5实现客户端与服务器时间同步
ue5
智海深蓝8 天前
海上平行战场:态势模拟三维可视化平台
3d·ue5
_守一9 天前
UE5 ListView记录
ue5
成都渲染101云渲染66669 天前
CR15新功能介绍以及CR15云渲染流程
ue5·图形渲染·blender·maya·corona
一锅炖出任易仙10 天前
创梦汤锅学习日记day30
学习·ai·ue5·游戏引擎
OSwich10 天前
【UE5学习笔记】UMG中控件命名规范
笔记·学习·ue5
一锅炖出任易仙11 天前
创梦汤锅学习日记day29
学习·ai·ue5·游戏引擎
吴梓穆11 天前
UE5 C++ 注册 开始重叠和结束重叠事件
开发语言·c++·ue5
妙为12 天前
unreal engine5(UE5)中使用Rider
ue5·游戏引擎·虚幻·rider
归真仙人14 天前
【UE】LineTraceByProfile
ue5·游戏引擎·ue4·unreal engine