Ios 对';dot';和';反映';

Ios 对';dot';和';反映';,ios,swift,shader,arkit,metal,Ios,Swift,Shader,Arkit,Metal,我正在尝试运行Arbios ARKit应用程序,该应用程序在中可用。这是一个非常酷的3D绘图应用程序!不幸的是,我有两个错误。我不知道为什么会出现这些错误,以及如何解决它们。 对于shaders.metal中的第104行,第一个错误是“没有调用'dot'的匹配函数”: float diffuseFactor = max(0.0,dot(interpolated.normal, light.direction)); // 1 第二个是同一文件(shaders.metal)第109行中的“无匹配

我正在尝试运行Arbios ARKit应用程序,该应用程序在中可用。这是一个非常酷的3D绘图应用程序!不幸的是,我有两个错误。我不知道为什么会出现这些错误,以及如何解决它们。 对于shaders.metal中的第104行,第一个错误是“没有调用'dot'的匹配函数”:

 float diffuseFactor = max(0.0,dot(interpolated.normal, light.direction)); // 1
第二个是同一文件(shaders.metal)第109行中的“无匹配函数用于调用‘reflect’”

下面是我完整的错误报告

CompileMetalFile /Users/Myname/Documents/Xcode/ARBrush/ARBrush/Shaders.metal (in target: ARBrush)
    cd /Users/Myname/Documents/Xcode/ARBrush
    export SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk
    /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metal -arch air64 -emit-llvm -c -gline-tables-only -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk -ffast-math -serialize-diagnostics /Users/Myname/Library/Developer/Xcode/DerivedData/ARBrush-amgfmkvulxeadccjphanytgyilwe/Build/Intermediates.noindex/ARBrush.build/Debug-iphoneos/ARBrush.build/Metal/Shaders.dia -o /Users/Myname/Library/Developer/Xcode/DerivedData/ARBrush-amgfmkvulxeadccjphanytgyilwe/Build/Intermediates.noindex/ARBrush.build/Debug-iphoneos/ARBrush.build/Metal/Shaders.air -mios-version-min=11.0 "" -MMD -MT dependencies -MF /Users/Myname/Library/Developer/Xcode/DerivedData/ARBrush-amgfmkvulxeadccjphanytgyilwe/Build/Intermediates.noindex/ARBrush.build/Debug-iphoneos/ARBrush.build/Metal/Shaders.dat /Users/Myname/Documents/Xcode/ARBrush/ARBrush/Shaders.metal

/Users/Myname/Documents/Xcode/ARBrush/ARBrush/Shaders.metal:104:35: error: no matching function for call to 'dot'
    float diffuseFactor = max(0.0,dot(interpolated.normal, light.direction)); // 1
                                  ^~~
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/lib/clang/902.1/include/metal/metal_geometric:171:30: note: candidate template ignored: requirement '_geometric_binary_func_enable<float __attribute__((ext_vector_type(3))), float __attribute__((packed_vector_type(3)))>::value' was not satisfied [with T = float __attribute__((ext_vector_type(3))), U = float __attribute__((packed_vector_type(3)))]
METAL_FUNC make_scalar_t<_O> dot(T x, U y)
                             ^
/Users/Myname/Documents/Xcode/ARBrush/ARBrush/Shaders.metal:109:25: error: no matching function for call to 'reflect'
    float3 reflection = reflect(light.direction, interpolated.normal); // 2
                        ^~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/lib/clang/902.1/include/metal/metal_geometric:354:15: note: candidate template ignored: requirement '_geometric_binary_func_enable<float __attribute__((packed_vector_type(3))), float __attribute__((ext_vector_type(3)))>::value' was not satisfied [with T = float __attribute__((packed_vector_type(3))), U = float __attribute__((ext_vector_type(3)))]
METAL_FUNC _O reflect(T i, U n)
              ^
2 errors generated.
CompileMetalFile/Users/Myname/Documents/Xcode/ARBrush/ARBrush/Shaders.metal(目标:ARBrush)
cd/Users/Myname/Documents/Xcode/ARBrush
导出SDKROOT=/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/metal-arch air64-emit llvm-c-gline tables only-isysroot/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS12.1.sdk-ffast math-序列化诊断/Users/Myname/Library/Developer/Xcode/DerivedData/ARBrush amgfmkvulxeadccjphanytgyilwe/Build/Intermediates.noindex/ARBrush.Build/Debug-iphoneos/ARBrush.Build/Metal/Shaders.dia-o/Users/Myname/Library/Developer/Xcode/DerivedData/ARBrush-amgfmkvulxeadccjphanytgyilwe/Build/Intermediates.noindex/ARBrush.Build/Debug-iphoneos/ARBrush.Build/Metal/Shaders.air-mios-version min=11.0“”-MMD-MT依赖项-MF/Users/Myname/Library/Developer/Xcode/DerivedData/ARBrush amgfmkvulxeadccjphanytgyilwe/Build/Intermediates.noindex/ARBrush.Build/Debug-iphoneos/ARBrush.Build/Metal/Shaders.dat/Users/Myname/Documents/Xcode/ARBrush/ARBrush/ARBrush/Shaders.Metal
/Users/Myname/Documents/Xcode/ARBrush/ARBrush/Shaders.metal:104:35:错误:没有用于调用“dot”的匹配函数
浮动扩散因子=最大值(0.0,点(插值.法线,光照.方向));//1.
^~~
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/lib/clang/902.1/include/metal/metal\U geometric:171:30:注:忽略候选模板:要求“\U geometric\U binary\U func\U enable::value”不满足[T=float\U属性(ext\U向量类型(3)),U=float\U属性(压缩向量类型(3))]
金属功能制造标量点(tx,uy)
^
/Users/Myname/Documents/Xcode/ARBrush/ARBrush/Shaders.metal:109:25:错误:调用“reflect”时没有匹配的函数
float3反射=反射(光.方向,插值.法线);//2.
^~~~~~~
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/usr/lib/clang/902.1/include/metal/metal\U geometric:354:15:注意:忽略候选模板:要求“\U geometric\U binary\U func\U enable::value”不满足[T=float\U属性(压缩向量类型(3)),U=float\U属性(外部向量类型(3))]
金属功能反射(ti,U n)
^
产生2个错误。
我在Xcode 10.1上使用swift 4运行这个应用程序,我的开发目标是iOS 11。如果有人能解决我的问题,我将非常感激


谢谢

我认为出现此问题是因为金属标准库中的函数不接受压缩向量类型。您应该能够通过调用站点上的内联类型转换来解决此问题:

float diffuseFactor = max(0.0,dot(interpolated.normal, float3(light.direction))); // 1

float3 reflection = reflect(float3(light.direction), interpolated.normal); // 2
或者简单地创建一个非压缩类型的局部变量

float3 lightDir(light.direction);

并在每次调用中使用它,而不是直接传递结构成员。

请逐字显示整个着色器编译器输出。您可能需要从构建日志中复制它。@Kenthomass我更新了我的问题,谢谢
float3 lightDir(light.direction);