summaryrefslogtreecommitdiff
path: root/assets
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-06-09 01:43:02 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-06-09 01:43:02 +1000
commit859ea7e23d2bbbc4b32b43727ae50aebe399e720 (patch)
tree868b5d938cec7846637cf403cde3723829822305 /assets
parent19a5fae08d7f1f85cb5448a5f2b19f0f9d342a0e (diff)
metal is back, baby
Diffstat (limited to 'assets')
-rw-r--r--assets/shaders/blinn_phong.vert2
-rw-r--r--assets/shaders/cube.frag2
-rw-r--r--assets/shaders/cube.vert2
-rw-r--r--assets/shaders/triangle.metal33
-rw-r--r--assets/shaders/triangle.vert2
5 files changed, 37 insertions, 4 deletions
diff --git a/assets/shaders/blinn_phong.vert b/assets/shaders/blinn_phong.vert
index 1d2a53e..18609b7 100644
--- a/assets/shaders/blinn_phong.vert
+++ b/assets/shaders/blinn_phong.vert
@@ -1,4 +1,4 @@
-#version 430 core
+#version 410 core
struct Uniforms {
mat4 model;
diff --git a/assets/shaders/cube.frag b/assets/shaders/cube.frag
index 292578f..88ba822 100644
--- a/assets/shaders/cube.frag
+++ b/assets/shaders/cube.frag
@@ -1,4 +1,4 @@
-#version 450
+#version 430
layout(location = 0) in vec3 fragColor;
layout(location = 1) in vec2 fragTexCoord;
diff --git a/assets/shaders/cube.vert b/assets/shaders/cube.vert
index fa9f85b..2f1d76d 100644
--- a/assets/shaders/cube.vert
+++ b/assets/shaders/cube.vert
@@ -1,4 +1,4 @@
-#version 450
+#version 430
layout(binding = 0) uniform UniformBufferObject {
mat4 model;
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
diff --git a/assets/shaders/triangle.vert b/assets/shaders/triangle.vert
index 8030561..f98696c 100644
--- a/assets/shaders/triangle.vert
+++ b/assets/shaders/triangle.vert
@@ -1,4 +1,4 @@
-#version 450
+#version 430
layout(location = 0) in vec2 inPos;
layout(location = 1) in vec3 inColor;