[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

相关推荐
avi911112 小时前
UE4-UE5虚幻引擎,前置学习二--------UI反射器,略屌
ue5·ue4·虚幻·editor代码反射
书鸢123618 小时前
UE5中 Character、PlayerController、PlayerState、GameMode和GameState核心类之间的联动和分工·
ue5
金米kk1 天前
Unreal Engine 5(虚幻引擎)动画制作快捷键大全
ue5·游戏引擎·虚幻
avi91112 天前
UE4-UE5虚幻引擎,前置学习一--Console日志输出经常崩溃,有什么好的解决办法
ue5·ue4·虚幻·日志
远离UE42 天前
UE5 RVT 制作场景交互 - 遮罩
ue5
lcw_lance3 天前
UE5与U3D引擎对比分析
ue5·数字孪生
妙为4 天前
要在Unreal Engine 5(UE5)中实现角色打击怪物并让怪物做出受击反应,
ue5·敌人受击效果·打击感
爱编程的鱼4 天前
UE5.4分层渲染设置
前端·ue5
Dawn·张5 天前
UE小:UE5.5 PixelStreamingInfrastructure 使用时注意事项
ue5
Maya动画技术8 天前
ue5.5崩溃报gpu错误快速修复注册表命令方法
ue5·ue5.5崩溃报gpu错误