forked from LukasBanana/LLGL
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExample.metal
55 lines (41 loc) · 934 Bytes
/
Example.metal
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Metal shader
#include <metal_stdlib>
#include <simd/simd.h>
using namespace metal;
// VERTEX SHADER
typedef struct
{
float4x4 wvpMatrix;
int useTexture2DMS;
}
Settings;
typedef struct
{
float3 position [[attribute(0)]];
float2 texCoord [[attribute(1)]];
}
VertexIn;
typedef struct
{
float4 position [[position]];
float2 texCoord;
}
VertexOut;
vertex VertexOut VS(
VertexIn inp [[stage_in]],
constant Settings& settings [[buffer(3)]])
{
VertexOut outp;
outp.position = settings.wvpMatrix * float4(inp.position, 1);
outp.texCoord = inp.texCoord;
return outp;
}
// PIXEL SHADER
fragment float4 PS(
VertexOut inp [[stage_in]],
texture2d<float> colorMap [[texture(2)]],
sampler smpl [[sampler(1)]])
{
// Sample texel from standard texture
return colorMap.sample(smpl, inp.texCoord);
}