#include using namespace metal; typedef struct { float4 position; float4 colour; } vertex_struct; struct ToFragStruct { float4 position [[position]]; float4 colour; }; struct Projection { float4x4 projection; }; struct Transformation { float4x4 transformation; }; // vertex shader function vertex ToFragStruct vertex_shader(device vertex_struct* vertex_array [[ buffer(0) ]], constant Projection &projection [[buffer(1)]], constant Transformation &transformation [[buffer(2)]], unsigned int vid [[ vertex_id ]]) { ToFragStruct out; out.position = projection.projection * transformation.transformation * vertex_array[vid].position; out.colour = vertex_array[vid].colour; return out; } // fragment shader function fragment float4 fragment_shader(ToFragStruct in [[stage_in]]) { return in.colour; }