#include using namespace metal; struct VertexOut { float4 position [[position]]; float4 color; }; vertex VertexOut triangle_vertex_main(uint vertexID [[vertex_id]]) { VertexOut out; // Triángulo simple en coordenadas normalized device coordinates float2 positions[3] = { float2( 0.0, 0.5), // Top float2(-0.5, -0.5), // Bottom left float2( 0.5, -0.5) // Bottom right }; float4 colors[3] = { float4(1, 0, 0, 1), // Red float4(0, 1, 0, 1), // Green float4(0, 0, 1, 1) // Blue }; out.position = float4(positions[vertexID], 0.0, 1.0); out.color = colors[vertexID]; return out; } fragment float4 triangle_fragment_main(VertexOut in [[stage_in]]) { return in.color; }