diff options
author | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-18 00:18:50 +1100 |
---|---|---|
committer | omniscient <17525998+omnisci3nce@users.noreply.github.com> | 2024-10-18 00:18:50 +1100 |
commit | df81a840a5276c35df5f35d55610f1bf31487153 (patch) | |
tree | 51b4fe8d90911e83ea3248481dc40b47a3b95083 /assets | |
parent | a9b750f003c711eb08cbc4b6b383de0ddab6ddcc (diff) |
port a few more math functions
Diffstat (limited to 'assets')
-rw-r--r-- | assets/shaders/cube.metal | 29 |
1 files changed, 29 insertions, 0 deletions
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 <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 |