[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

相关推荐
CandyU210 小时前
UE5 基础应用 —— 10 - 控制台命令
ue5
平行云3 天前
Paraverse平行云实时云渲染助力第82届威尼斯电影节XR沉浸式体验
unity·云原生·ue5·xr·实时云渲染
一眼万里*e4 天前
用ai写了个UE5插件
c++·ue5
成都渲染101云渲染66664 天前
电脑配置不足怎么办,告别硬件束缚,川翔云电脑
ue5·电脑
m0_552200824 天前
《UE5_C++多人TPS完整教程》学习笔记47 ——《P48 瞄准行走(Aim Walking)》
c++·游戏·ue5
会思考的猴子8 天前
UE5 PCG 笔记(三) Normal To Density 节点
笔记·ue5
吴梓穆13 天前
UE5 UI遮罩
ue5
枯萎穿心攻击13 天前
Unity VS UE 性能工具与内存管理
开发语言·游戏·unity·ue5·游戏引擎·虚幻·虚幻引擎
黑客影儿13 天前
使用UE5开发2.5D开放世界战略养成类游戏的硬件配置指南
开发语言·c++·人工智能·游戏·智能手机·ue5·游戏引擎
幻雨様13 天前
UE5多人MOBA+GAS 54、用户登录和会话创建请求
android·ue5