-
Notifications
You must be signed in to change notification settings - Fork 0
/
shader_display.go
55 lines (44 loc) · 897 Bytes
/
shader_display.go
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
53
54
55
package main
// DisplayShader defines shader sources for the simulation display.
var DisplayShader = ShaderSource{
Vertex: `
#version 420
$INCLUDE_SHARED$
uniform mat4 Model;
in vec2 vertPos;
in vec2 vertUV;
out vec2 fragUV;
void main() {
gl_Position = Projection * View * Model * vec4(vertPos, 0, 1);
fragUV = vertUV;
}
`,
Fragment: `
#version 420
$INCLUDE_SHARED$
layout (binding = 0) uniform sampler2D input;
uniform vec4 PalEmpty;
uniform vec4 PalWire;
uniform vec4 PalHead;
uniform vec4 PalTail;
in vec2 fragUV;
out vec4 output;
void main() {
uint cell = uint(texture2D(input, fragUV).r * 255);
switch (cell) {
case CellWire:
output = PalWire;
break;
case CellHead:
output = PalHead;
break;
case CellTail:
output = PalTail;
break;
default:
output = PalEmpty;
break;
}
}
`,
}