Posts

Post not yet marked as solved
2 Replies
I'm a bit late to the party, but the [[clip_distance]] is a vertex-only attribute and the fragment functions would produce undefined behavior if they read and use it, thus the compiler error. What you can do is define one structure for the output for the vertex shader and another for the input to the fragment shader. For example: // Structure used as the output of the vertex shader. struct VertexOut { float4 position [[position]]; float clipDistance [[clip_distance]] [2]; }; // Structure defined as the input of the fragment shader. struct FragmentIn { float4 position; }; You can find more about the matching vertex and fragment attributes in the Metal Shading Language specification, in section 5.7.1 "Vertex-Fragment Signature Matching".