summaryrefslogtreecommitdiff
path: root/assets/shaders/cube.metal
blob: dc7ace1036021dda71f582192cdbea4d700f8c8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
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;
}