summaryrefslogtreecommitdiff
path: root/assets/shaders/triangle.metal
diff options
context:
space:
mode:
authorJoshua Rowe <17525998+omnisci3nce@users.noreply.github.com>2024-06-09 14:59:01 +1000
committerGitHub <noreply@github.com>2024-06-09 14:59:01 +1000
commit9c79df522980eabdc5e52592cbd152e2a285c4cc (patch)
tree9082af194033e5e3e4a770456209d3bac7784943 /assets/shaders/triangle.metal
parent8d116bd23d9441e33cb3377e90c08169109b438a (diff)
parentd4ff15d9cd82a6e3bc71da9d04ee0f250460cef1 (diff)
Merge pull request #16 from omnisci3nce/port-opengl-ral
Bring back OpenGL (part 1)
Diffstat (limited to 'assets/shaders/triangle.metal')
-rw-r--r--assets/shaders/triangle.metal33
1 files changed, 33 insertions, 0 deletions
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 <metal_stdlib>
+
+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