[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

相关推荐
Duo1J2 天前
【UE】Slate 编辑器工具开发01 - Slate语法 & 常用控件
ue5·编辑器·游戏引擎·ue4
朗迹 - 张伟3 天前
UE5.7 PCG从入门到精通系列课程【第五课:PCG沿一条样条线生成物体】
ue5·pcg
AA陈超3 天前
003 XiYou 西游 — P0 阶段实施计划
c++·笔记·学习·ue5
朗迹 - 张伟4 天前
UE5.7 PCG从入门到精通系列课程【第三课:程序化生成森林】
ue5·pcg
朗迹 - 张伟5 天前
UE5.7 PCG从入门到精通系列课程【第二课:使用PCG制作草地系统】
ue5·pcg
im长街5 天前
UE 课程介绍 - 1. 3DMax软件建模基础
ue5·3dsmax
directx3d_beginner7 天前
25,怪物受伤害和受力
ue5
directx3d_beginner7 天前
23,怪物血量改为C++
ue5
远离UE48 天前
UE5 compute shader 原子加
开发语言·c++·ue5
朗迹 - 张伟8 天前
UE5.7 PCG从入门到精通系列课程【第一课:基础介绍】
ue5·pcg