-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathvhs.gdshader
55 lines (45 loc) · 1.67 KB
/
vhs.gdshader
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
// adapted from:
// https://www.shadertoy.com/view/Ms3XWH
shader_type canvas_item;
uniform float shake: hint_range(0, 10) = 0.015;
uniform float noiseQuality: hint_range(0.1, 10,0.1) = 4.2;
uniform float noiseIntensity: hint_range(0, 0.01,0.001) = 0.001;
uniform float offsetIntensity: hint_range(0, 0.05,0.0001) = 0.05;
uniform float colorOffsetIntensity: hint_range(0.1, 1,0.001) = 0.5;
uniform sampler2D screen_texture : hint_screen_texture, repeat_disable, filter_nearest;
float rand(vec2 co)
{
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
float verticalBar(float pos, float uvY, float offset)
{
float edge0 = (pos - shake);
float edge1 = (pos + shake);
float x = smoothstep(edge0, pos, uvY) * offset;
x -= smoothstep(pos, edge1, uvY) * offset;
return x;
}
void fragment() {
vec2 iResolution = 1.0 / SCREEN_PIXEL_SIZE;
vec2 uv = FRAGCOORD.xy / iResolution.xy;
for (float i = 0.0; i < 1.0; i += 0.713)
{
float d = mod(TIME * i, 1.7);
float o = sin(1.0 - tan(TIME * 0.24 * i));
o *= offsetIntensity;
uv.x += verticalBar(d, uv.y, o);
}
float uvY = uv.y;
uvY *= noiseQuality;
uvY = float(int(uvY)) * (1.0 / noiseQuality);
float noise = rand(vec2(TIME* 0.00001, uvY));
uv.x += noise * noiseIntensity;
vec2 offsetR = vec2(0.006 * sin(TIME), 0.0) * colorOffsetIntensity;
vec2 offsetG = vec2(0.0073 * (cos(TIME * 0.97)), 0.0) * colorOffsetIntensity;
float r = texture(screen_texture, uv + offsetR).r;
float g = texture(screen_texture, uv + offsetG).g;
float b = texture(screen_texture, uv).b;
//vec4 tex = vec4(r, g, b, 1.0);
vec4 tex=vec4(r, g, b,1.0);
COLOR = tex;
}