-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTrailScatter.tres
57 lines (47 loc) · 1.31 KB
/
TrailScatter.tres
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
[gd_resource type="ShaderMaterial" load_steps=2 format=2]
[sub_resource type="Shader" id=1]
code = "shader_type canvas_item;
uniform float scatter_range = 0;
uniform float mult = 1.0;
uniform float trail = 0.9;
uniform float scatter_chance = 0.3;
float rand(inout float seed, vec2 uv){
vec2 co = uv * seed;
float num = fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
seed *= num;
return num;
}
void fragment() {
float seed = TIME;
vec2 co = SCREEN_UV;
// vec2 pixel_size = 1.0 / vec2(textureSize(SCREEN_TEXTURE, 0));
vec4 scr = textureLod(SCREEN_TEXTURE, SCREEN_UV, 0.0);
vec4 last = texture(TEXTURE, UV);
vec2 px_range = SCREEN_PIXEL_SIZE * scatter_range;
////scatter////
if (rand(seed, co) < scatter_chance) {
vec2 offset = vec2(
mix(-px_range.x, px_range.x, rand(seed, co)),
mix(-px_range.y, px_range.y, rand(seed, co))
);
vec4 offset_c = textureLod(SCREEN_TEXTURE, SCREEN_UV+offset, 0.0);
scr = offset_c;
COLOR = offset_c;
} else {
COLOR = scr * mult;
}
////trail///
if (rand(seed, UV) < trail) {
COLOR = last;
}
}
"
_sections_unfolded = [ "Resource" ]
[resource]
render_priority = 0
shader = SubResource( 1 )
shader_param/scatter_range = 15.0
shader_param/mult = null
shader_param/trail = null
shader_param/scatter_chance = 0.3
_sections_unfolded = [ "shader_param" ]