[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陈超14 小时前
虚幻引擎UE5专用服务器游戏开发-32 使用Gameplay Tags阻止连招触发
c++·游戏·ue5·游戏引擎·虚幻
努力的小钟15 小时前
UE5 GAS GameAbility源码解析 CanActivateAbility
ue5
危险库19 小时前
【UE4/UE5】在虚幻引擎中创建控制台指令的几种方法
c++·ue5·游戏引擎·ue4·虚幻
m0_552200822 天前
《UE5_C++多人TPS完整教程》学习笔记60 ——《P61 开火蒙太奇(Fire Montage)》
c++·游戏·ue5
avi91113 天前
Unreal虚幻粒子系统二三事
ue5·虚幻引擎·unreal
一梦、んんん3 天前
UE 雷达干扰效果模拟
ue5
玉龙20253 天前
虚幻引擎|UE5制作DeepSeek插件并打包发布
ue5·游戏引擎·虚幻·虚幻引擎基础入门·=学习·虚幻引擎插件
努力的小钟3 天前
Unreal Engine GameplayTag匹配功能详解
ue5
司徒法克4 天前
ue编辑器视口鼠标消失的问题
ue5
CandyU24 天前
UE5 小知识点 —— 09 - 旋转小问题
ue5