-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtree.tscn
69 lines (57 loc) · 2.6 KB
/
tree.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
[gd_scene load_steps=4 format=2]
[ext_resource path="res://art/arbol.png" type="Texture" id=1]
[sub_resource type="Shader" id=1]
code = "// https://godotshaders.com/shader/2d-wind-sway/
// original wind shader from https://github.com/Maujoe/godot-simple-wind-shader-2d/tree/master/assets/maujoe.simple_wind_shader_2d
// original script modified by HungryProton so that the assets are moving differently : https://pastebin.com/VL3AfV8D
//
// speed - The speed of the wind movement.
// minStrength - The minimal strength of the wind movement.
// maxStrength - The maximal strength of the wind movement.
// strengthScale - Scalefactor for the wind strength.
// interval - The time between minimal and maximal strength changes.
// detail - The detail (number of waves) of the wind movement.
// distortion - The strength of geometry distortion.
// heightOffset - The height where the wind begins to move. By default 0.0.
shader_type canvas_item;
render_mode blend_mix;
// Wind settings.
uniform float speed = 1.0;
uniform float minStrength : hint_range(0.0, 1.0) = 0.05;
uniform float maxStrength : hint_range(0.0, 1.0) = 0.01;
uniform float strengthScale = 100.0;
uniform float interval = 3.5;
uniform float detail = 1.0;
uniform float distortion : hint_range(0.0, 1.0);
uniform float heightOffset : hint_range(0.0, 1.0);
// With the offset value, you can if you want different moves for each asset. Just put a random value (1, 2, 3) in the editor. Don't forget to mark the material as unique if you use this
uniform float offset = 0;
float getWind(vec2 vertex, vec2 uv, float time){
float diff = pow(maxStrength - minStrength, 2.0);
float strength = clamp(minStrength + diff + sin(time / interval) * diff, minStrength, maxStrength) * strengthScale;
float wind = (sin(time) + cos(time * detail)) * strength * max(0.0, (1.0-uv.y) - heightOffset);
return wind;
}
void vertex() {
vec4 pos = WORLD_MATRIX * vec4(0.0, 0.0, 0.0, 1.0);
float time = TIME * speed + offset;
//float time = TIME * speed + pos.x * pos.y ; not working when moving...
VERTEX.x += getWind(VERTEX.xy, UV, time);
}"
[sub_resource type="ShaderMaterial" id=2]
shader = SubResource( 1 )
shader_param/speed = 2.5
shader_param/minStrength = 0.03
shader_param/maxStrength = 0.09
shader_param/strengthScale = 150.0
shader_param/interval = 5.0
shader_param/detail = 1.0
shader_param/distortion = 0.8
shader_param/heightOffset = 0.5
shader_param/offset = 0.0
[node name="tree" type="Node2D"]
[node name="sprite" type="Sprite" parent="."]
material = SubResource( 2 )
position = Vector2( 862.986, 165.52 )
scale = Vector2( 0.66, 0.66 )
texture = ExtResource( 1 )