[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

相关推荐
远离UE41 天前
UE5 母材质 编写笔记
笔记·ue5·材质
远离UE41 天前
UE5 HLSLTranslator 与 ShaderCompiler
ue5
1204157137 肖哥2 天前
UE5.7 场景打光管线流程_【雪山】
ue5
weixin_404679312 天前
虚幻5 替代小白人角色的完整逻辑
ue5
1204157137 肖哥5 天前
UE5.7 灯光详解
ue5
狂云歌6 天前
AI写UE的3Dgame
人工智能·3d·ue5·游戏程序
日月云棠10 天前
UE5源码分析之Editor——Blutility模块全面分析
ue5
日月云棠10 天前
UE5源码分析之Editor——BehaviorTreeEditor模块全面分析
ue5
日月云棠10 天前
UE5源码分析之Editor——AssetTagsEditor模块全面分析
ue5
远离UE411 天前
UE5 显存 虚拟内存 深入学习笔记
笔记·学习·ue5