In GLSL, I would simply use out vec3 array[10];
, to pass an array from the vertex shader to the fragment shader. In Metal, however, I thought to do it this way:
struct FragmentIn {
float4 position [[position]];
float3 array[10];
};
This produces the following error:
Type 'FragmentIn' is not valid for attribute 'stage_in' because field 'array' has invalid type 'float3 [10]'
How can I solve this issue? I need to do certain calculations with per-vertex data that the fragment shader will use.
You need to "unroll" the array:
struct FragmentIn {
float4 position [[position]];
float3 thing0;
float3 thing1;
float3 thing2;
float3 thing3;
float3 thing4;
float3 thing5;
float3 thing6;
float3 thing7;
float3 thing8;
float3 thing9;
};
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With