-
Notifications
You must be signed in to change notification settings - Fork 2
/
vhs.tscn
84 lines (71 loc) · 2.45 KB
/
vhs.tscn
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
[gd_scene load_steps=3 format=3 uid="uid://1bso8epsanmx"]
[sub_resource type="Shader" id="Shader_rt5uu"]
code = "// 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, 250,0.1) = 250;
uniform float noiseIntensity: hint_range(0, 0.05,0.001) = 0.001;
uniform float offsetIntensity: hint_range(0, 0.05,0.0001) = 0.05;
uniform float colorOffsetIntensity: hint_range(0.1, 1.5,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;
// why these values for i?
for (float i = 0.0; i < 0.71; i += 0.1313)
{
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;
}
"
[sub_resource type="ShaderMaterial" id="ShaderMaterial_6gnwq"]
shader = SubResource("Shader_rt5uu")
shader_parameter/shake = 2.116
shader_parameter/noiseQuality = 208.9
shader_parameter/noiseIntensity = 0.018
shader_parameter/offsetIntensity = 0.032
shader_parameter/colorOffsetIntensity = 0.5
[node name="VHS" type="Control"]
layout_mode = 3
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2
[node name="ColorRect" type="ColorRect" parent="."]
material = SubResource("ShaderMaterial_6gnwq")
layout_mode = 1
anchors_preset = 15
anchor_right = 1.0
anchor_bottom = 1.0
grow_horizontal = 2
grow_vertical = 2