-
Notifications
You must be signed in to change notification settings - Fork 3
/
ega.fs
47 lines (37 loc) · 802 Bytes
/
ega.fs
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
//EGA shader
//----------
//Based on https://www.shadertoy.com/view/4dXSzl
uniform sampler2D tex0;
varying vec2 v_texCoord;
#define colorDetail 16.
#define _ 0.0
#define o (1./3.)
#define b (2./3.)
#define B 1.0
#define check(r,g,b) color=vec4(r,g,b,0.); dist = distance(s,color); if (dist < bestDistance) {bestDistance = dist; bestColor = color;}
void main()
{
float dist;
float bestDistance = 1000.;
vec4 color;
vec4 bestColor;
vec4 s = texture2D(tex0, v_texCoord);
s = floor(s*colorDetail+0.5)/colorDetail;
check(_,_,_);
check(_,_,b);
check(_,b,_);
check(_,b,b);
check(b,_,_);
check(b,_,b);
check(b,o,_);
check(b,b,b);
check(o,o,o);
check(o,o,B);
check(o,B,o);
check(o,B,B);
check(B,o,o);
check(B,o,B);
check(B,B,o);
check(B,B,B);
gl_FragColor = bestColor;
}