From df81a840a5276c35df5f35d55610f1bf31487153 Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Fri, 18 Oct 2024 00:18:50 +1100 Subject: port a few more math functions --- assets/shaders/cube.metal | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'assets/shaders/cube.metal') diff --git a/assets/shaders/cube.metal b/assets/shaders/cube.metal index e69de29..dc7ace1 100644 --- a/assets/shaders/cube.metal +++ b/assets/shaders/cube.metal @@ -0,0 +1,29 @@ +#include +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 -- cgit v1.2.3-70-g09d2