[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

相关推荐
gshh__5 小时前
SuperMap Hi-Fi 3D SDK for Unreal 如何修改模型选中高亮颜色
ue5·游戏引擎·supermap
AI视觉网奇15 小时前
ue5 随机数学习笔记
ue5
曼巴UE516 小时前
UE GamePlayTag
c++·ue5·ue
AI视觉网奇2 天前
ue安装插件方法笔记
笔记·ue5
AI视觉网奇2 天前
ue 动作 动画学习笔记
笔记·ue5
吴梓穆2 天前
UE5 时间轴调整播放速度
ue5
会思考的猴子2 天前
UE5 笔记二 GameplayAbilitySystem Attributes & Effects
笔记·ue5
UTwelve2 天前
【UE】材质与半透明 - 01.将半透明作为后期材质
ue5·材质·着色器
AI视觉网奇2 天前
ue重定向学习笔记
笔记·ue5
AI视觉网奇3 天前
Audio2Face 实时推理
笔记·ue5