From 859ea7e23d2bbbc4b32b43727ae50aebe399e720 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Sun, 9 Jun 2024 01:43:02 +1000 Subject: metal is back, baby --- assets/shaders/triangle.metal | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 assets/shaders/triangle.metal (limited to 'assets/shaders/triangle.metal') diff --git a/assets/shaders/triangle.metal b/assets/shaders/triangle.metal new file mode 100644 index 0000000..6055705 --- /dev/null +++ b/assets/shaders/triangle.metal @@ -0,0 +1,33 @@ +#include + +using namespace metal; + +struct VertexIn { + float2 position; + float3 color; +}; + +struct VertexOut { + float4 computedPosition [[position]]; + float3 fragColor; +}; + +// Vertex shader +vertex VertexOut basic_vertex( + const device VertexIn* vertex_array [[ buffer(0) ]], + unsigned int vid [[ vertex_id ]] + ) { + VertexIn v = vertex_array[vid]; + + VertexOut outVertex = VertexOut(); + outVertex.computedPosition = float4(v.position.xy, 0.0, 1.0); + outVertex.fragColor = v.color; + return outVertex; +} + +// Fragment shader +fragment float4 basic_fragment( + VertexOut interpolated [[stage_in]] +) { + return float4(interpolated.fragColor, 1.0); +} \ No newline at end of file -- cgit v1.2.3-70-g09d2