[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

相关推荐
AA陈超2 小时前
ASC学习笔记0020:用于定义角色或Actor的默认属性值
c++·笔记·学习·ue5·虚幻引擎
平行云3 小时前
World Labs & Paraverse:统一3D世界的创造与访问
3d·unity·ai·ue5·aigc·实时云渲染·云xr
AA陈超10 小时前
使用UnrealEngine引擎,实现鼠标点击移动
c++·笔记·学习·ue5·虚幻引擎
AA陈超12 小时前
Lyra源码分析:LyraCharacterMovementComponent
c++·笔记·学习·ue5·虚幻引擎·lyra
电子云与长程纠缠1 天前
UE5打光技巧02(新手向)
ue5
AA陈超1 天前
UE5笔记:GetWorld()->SpawnActorDeferred()
c++·笔记·学习·ue5·虚幻引擎
AA陈超1 天前
ASC学习笔记0025:移除所有属性集
c++·笔记·学习·ue5·虚幻引擎
AA陈超2 天前
ASC学习笔记0007:用于与GameplayAbilities系统交互的核心ActorComponent
c++·笔记·学习·ue5·虚幻引擎
AA陈超3 天前
UE5笔记:OnComponentBeginOverlap
c++·笔记·学习·ue5·虚幻引擎
AA陈超3 天前
ASC学习笔记0014:手动添加一个新的属性集
c++·笔记·学习·ue5