#include using namespace metal; typedef struct { float4 position; float4 texture_coords; } vertex_struct; struct ToFragStruct { float4 position [[position]]; float2 texture_coords; }; // vertex shader function vertex ToFragStruct vertex_shader(device vertex_struct* vertex_array [[ buffer(0) ]], unsigned int vid [[ vertex_id ]]) { ToFragStruct out; out.position = vertex_array[vid].position; out.texture_coords = vertex_array[vid].texture_coords.xy; return out; } // fragment shader function fragment float4 fragment_shader(ToFragStruct in [[stage_in]], texture2d texture [[texture(0)]], sampler sam [[sampler(0)]]) { return texture.sample(sam, in.texture_coords); }