-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShaders.metal
More file actions
40 lines (34 loc) · 1.14 KB
/
Shaders.metal
File metadata and controls
40 lines (34 loc) · 1.14 KB
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
//
// Shaders.metal
// HelloTriangle
//
// Created by Soham Manoli on 11/26/21.
//
#include <metal_stdlib>
#include "ShaderDefs.h"
using namespace metal;
struct VertexOutput{
float4 pos [[position]];
float4 color;
};
vertex VertexOutput vertexShader( constant VertexData* vertices [[buffer(0)]], uint id [[vertex_id]], constant float& time [[buffer(1)]]){
float brightness = float((0.5 * cos(time)) + 0.5);
float scale = float((0.5 * cos(time)) + 0.5);
return {
.pos = float4(
scale * vertices[id].pos.x,
scale * vertices[id].pos.y,
scale * vertices[id].pos.z,
vertices[id].pos.w
),
.color = float4(
brightness * vertices[id].color.x,
brightness * vertices[id].color.y,
brightness * vertices[id].color.z,
vertices[id].color.z
)
};
}
fragment float4 fragmentShader(VertexOutput vert [[stage_in]]){
return float4(vert.color.x, vert.color.y, vert.color.z, vert.color.z);
}