I’m working on a textbook PBR shader implementation using Metal.
While porting existing GLSL code, my goal was to pass a 3×3 matrix calculated in the vertex shader to the fragment shader. Doing so seems to not be supported by Metal given the following compiler error message:
field of illegal type 'metal::float3x3' (aka 'matrix<float, 3, 3>')
Vertex shader code sample:
typedef struct
{
float4 position [[position]];
float3 worldPosition;
float2 texCoord;
float3x3 tangentBasis; // <-- field of illegal type 'metal::float3x3' (aka 'matrix<float, 3, 3>')
} ColorInOut;
vertex ColorInOut vertexShader(Vertex in [[stage_in]])
{
ColorInOut out;
// [...] omitted shader code for simplicity
out.tangentBasis = float3x3(/* ... */);
return out;
}
Is this an actual limitation in the Metal Shading Language? Do I need to explicitly deconstruct my matrix into 3 vectors?
Thank you!
1