Material Dot product error on Mac with Metal

I’m using the Dot product node in a material but receive the following error on a Mac:

Error [SM4] …/…/…/Engine/Intermediate/ShaderIn7A8D346B4A4515152116A5ADFC94D605.metal(0): …/…/…/Engine/Intermediate/ShaderIn7A8D346B4A4515152116A5ADFC94D605.metal:273:8: error: call to ‘dot’ is ambiguous
f15 = dot(f14,v13.z);
^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:14:18: note: candidate function
METAL_ASM half dot(vec x, vec y) __asm(“air.dot.v2f16”);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:54:18: note: candidate function
METAL_ASM half dot(vec x, vec y) __asm(“air.dot.v3f16”);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:94:18: note: candidate function
METAL_ASM half dot(vec x, vec y) __asm(“air.dot.v4f16”);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:142:19: note: candidate function
METAL_ASM float dot(vec x, vec y) __asm(“air.dot.v2f32”);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:257:19: note: candidate function
METAL_ASM float dot(vec x, vec y) __asm(“air.dot.v3f32”);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:372:19: note: candidate function
METAL_ASM float dot(vec x, vec y) __asm(“air.dot.v4f32”);
^
…/…/…/Engine/Intermediate/ShaderIn7A8D346B4A4515152116A5ADFC94D605.metal:307:8: error: call to ‘dot’ is ambiguous
f29 = dot(f28,v27.z);
^~~
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:14:18: note: candidate function
METAL_ASM half dot(vec x, vec y) __asm(“air.dot.v2f16”);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:54:18: note: candidate function
METAL_ASM half dot(vec x, vec y) __asm(“air.dot.v3f16”);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:94:18: note: candidate function
METAL_ASM half dot(vec x, vec y) __asm(“air.dot.v4f16”);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:142:19: note: candidate function
METAL_ASM float dot(vec x, vec y) __asm(“air.dot.v2f32”);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:257:19: note: candidate function
METAL_ASM float dot(vec x, vec y) __asm(“air.dot.v3f32”);
^
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/usr/bin/…/lib/clang/3.5/include/metal/metal_geometric:372:19: note: candidate function
METAL_ASM float dot(vec x, vec y) __asm(“air.dot.v4f32”);
^
2 errors generated.

You’ve found an inconsistency here between the material’s generated HLSL and the resulting Metal shader we generate from it: you are passing scalar floats into the dot product intrinsic but in Metal that intrinsic only accepts vectors.

You’ll need to use a ‘multiply’ op in your material when the input values are floats to avoid this (at least for now).

Oh right. Thanks, I’ll try that!