gpt4 book ai didi

ios - 为什么在 SceneKit 着色器修改器中使用 glsl 或定义函数只会产生错误?

转载 作者:行者123 更新时间:2023-11-28 23:28:28 30 4
gpt4 key购买 nike

每次我尝试编写 SceneKit 着色器修改器时,我都会看到一个粉红色的屏幕和一个充满错误的调试屏幕。根据documents ,我应该能够在 glsl 中编写 SceneKit 着色器修改器,但我得到的只是这些错误,如

error: use of undeclared identifier 'vec3'; did you mean 'vec'?

嗯?为什么我不能使用 vec3?

我试过像这样手动将所有 vec3 转换为 float3

#pragma arguments

float3 myFunction()
{
return float3(1,1,1);
}

#pragma transparent
#pragma body

float3 myVar = myFunction();

但是我只是得到一个错误

[SceneKit] Error: FATAL ERROR : failed compiling shader:
Error Domain=MTLLibraryErrorDomain Code=3 "Compilation failed:

program_source:2847:41: error: expected parameter declarator
, constant return& float3
^
program_source:2847:50: error: expected ')'
, constant return& float3
^
program_source:2732:38: note: to match this '('
fragment SCNOutput commonprofile_frag(commonprofile_io in [[ stage_in ]]
^
program_source:3340:2: error: expected function body after function declarator
}
^
" UserInfo={NSLocalizedDescription=Compilation failed:

program_source:2847:41: error: expected parameter declarator
, constant return& float3
^
program_source:2847:50: error: expected ')'
, constant return& float3
^
program_source:2732:38: note: to match this '('
fragment SCNOutput commonprofile_frag(commonprofile_io in [[ stage_in ]]
^
program_source:3340:2: error: expected function body after function declarator
}
^
}
2019-08-31 20:30:28.724039-0700 zLab[3725:903320] [SceneKit] Error: FATAL ERROR : failed compiling shader:
Error Domain=MTLLibraryErrorDomain Code=3 "Compilation failed:

program_source:2847:41: error: expected parameter declarator
, constant return& float3
^
program_source:2847:50: error: expected ')'
, constant return& float3
^
program_source:2732:38: note: to match this '('
fragment SCNOutput commonprofile_frag(commonprofile_io in [[ stage_in ]]
^
program_source:3340:2: error: expected function body after function declarator
}
^
" UserInfo={NSLocalizedDescription=Compilation failed:

program_source:2847:41: error: expected parameter declarator
, constant return& float3
^
program_source:2847:50: error: expected ')'
, constant return& float3
^
program_source:2732:38: note: to match this '('
fragment SCNOutput commonprofile_frag(commonprofile_io in [[ stage_in ]]
^
program_source:3340:2: error: expected function body after function declarator
}
^
}

这一切意味着什么?我做错了什么?

最佳答案

#pragma arguments 指令应用于声明从 CPU 客户端代码设置的着色器修改器的参数。

对于自定义函数和帮助程序,您可以使用#pragma statements 指令(另请参阅 Custom Variable Declarations Using Metal With Scene Kit Shader Modifiers )

关于ios - 为什么在 SceneKit 着色器修改器中使用 glsl 或定义函数只会产生错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57743037/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com