summaryrefslogtreecommitdiff
path: root/assets/shaders/cube.metal
diff options
context:
space:
mode:
Diffstat (limited to 'assets/shaders/cube.metal')
-rw-r--r--assets/shaders/cube.metal29
1 files changed, 29 insertions, 0 deletions
diff --git a/assets/shaders/cube.metal b/assets/shaders/cube.metal
new file mode 100644
index 0000000..dc7ace1
--- /dev/null
+++ b/assets/shaders/cube.metal
@@ -0,0 +1,29 @@
+#include <metal_stdlib>
+using namespace metal;
+
+struct VertexData {
+ float4 position;
+ float4 normal;
+ float2 texCoords;
+};
+
+struct VertexOut {
+ float4 position [[position]];
+ float2 textureCoordinate;
+};
+
+struct TransformationData {
+ float4x4 modelMatrix;
+ float4x4 viewMatrix;
+ float4x4 perspectiveMatrix;
+};
+
+vertex VertexOut cubeVertexShader(uint vertexID [[vertex_id]],
+ constant VertexData* vertexData,
+ constant TransformationData* transformationData)
+{
+ VertexOut out;
+ out.position = transformationData->perspectiveMatrix * transformationData->viewMatrix * transformationData->modelMatrix * vertexData[vertexID].position;
+ out.textureCoordinate = vertexData[vertexID].texCoords;
+ return out;
+} \ No newline at end of file