-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshader.frag
43 lines (31 loc) · 879 Bytes
/
shader.frag
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
#version 130
#define CRT_CASE_BORDR 0.0125
#define SCAN_LINE_MULT 1250.0
uniform float CRT_CURVE_AMNTx; // curve amount on x
uniform float CRT_CURVE_AMNTy; // curve amount on y
uniform sampler2D texture;
in vec4 color;
in vec2 texCoord;
void main() {
vec2 tc = texCoord.xy;
// Distance from the center
float dx = abs(0.5-tc.x);
float dy = abs(0.5-tc.y);
// Square it to smooth the edges
dx *= dx;
dy *= dy;
tc.x -= 0.5;
tc.x *= 1.0 + (dy * CRT_CURVE_AMNTx);
tc.x += 0.5;
tc.y -= 0.5;
tc.y *= 1.0 + (dx * CRT_CURVE_AMNTy);
tc.y += 0.5;
// Get texel, and add in scanline if need be
vec4 cta = texture2D(texture, tc);
cta.rgb += sin(tc.y * SCAN_LINE_MULT) * 0.03;
// Cutoff
if(tc.y > 1.0 || tc.x < 0.0 || tc.x > 1.0 || tc.y < 0.0)
cta = vec4(0.0);
// Apply
gl_FragColor = cta * color;
}