[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

相关推荐
-FxYaM-1 天前
【UE】渲染框架学习路径-初次修改源码
服务器·网络·c++·windows·ue5·unreal engine
一锅炖出任易仙3 天前
创梦汤锅学习日记day23
学习·ai·ue5
妙为5 天前
unreal engine5.7.4,创建ThirdPerson第三人称模版,类型是c++崩溃
c++·ue5·虚幻·unreal engine5
weixin_404679318 天前
虚幻5电子书
ue5
directx3d_beginner9 天前
5,动画蓝图类接口转c++
ue5
RuiZN9 天前
UE5 蓝图 FPS 02 Event Beginplay
c++·ue5
RuiZN9 天前
UE5 蓝图 FPS 01 Event Tick
c++·ue5
directx3d_beginner9 天前
6,执行攻击改为c++
ue5
平行云9 天前
实时云渲染预启动技术解析:UE数字孪生应用的延迟优化机制(二)
linux·unity·ue5·webgl·实时云渲染·云桌面·像素流
RuiZN10 天前
UE5 UObject类详解
c++·ue5