-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgrass.tscn
113 lines (93 loc) · 3 KB
/
grass.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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
[gd_scene load_steps=8 format=2]
[ext_resource path="res://Grasses.png" type="Texture" id=1]
[ext_resource path="res://icon.png" type="Texture" id=2]
[sub_resource type="CanvasItemMaterial" id=1]
particles_animation = true
particles_anim_h_frames = 19
particles_anim_v_frames = 1
particles_anim_loop = true
[sub_resource type="Shader" id=2]
code = "shader_type particles;
uniform float spacing = 10;
uniform float height = 40.0;
uniform float angle : hint_range(0.1, 2.0) = 0.5;
uniform float period: hint_range(0.1, 5.0) = 1.0;
uniform float min_height_random: hint_range(0.1,2) = 0.8;
uniform float max_height_random: hint_range(0.1,2) = 1.2;
float rand_from_seed(inout uint seed) {
int k;
int s = int(seed);
if (s == 0)
s = 305420679;
k = s / 127773;
s = 16807 * (s - k * 127773) - 2836 * k;
if (s < 0)
s += 2147483647;
return float(uint(seed) % uint(65536))/65535.0;
}
uint hash(uint x) {
x = ((x >> uint(16)) ^ x) * uint(73244475);
x = ((x >> uint(16)) ^ x) * uint(73244475);
x = (x >> uint(16)) ^ x;
return x;
}
void vertex(){
// uint seed = hash(NUMBER+uint(1)+ uint(372846));
uint seed = hash(uint(INDEX));
float pi = 3.14159;
float degree_to_rad = pi / 180.0;
float h_mod = min_height_random + (max_height_random-min_height_random) * rand_from_seed(seed);
//height = rand_from_seed(seed) * height;
float f = height /2.0 * h_mod;
vec2 pos = vec2(0.0,0.0);
pos.x = float(INDEX);
pos *= spacing;
TRANSFORM[3][0] = pos.x;
TRANSFORM[3][1] = -f;
// CUSTOM.x = pi/2.;
CUSTOM.x = cos(TIME*period) * angle;
TRANSFORM[3][1] -= cos(CUSTOM.x) * f -f;
TRANSFORM[3][0] -= sin(CUSTOM.x) * f;
// vec3 res = rotate(TRANSFORM[3].xyz, vec3(0.0,0.0,1.0),0.6);
// TRANSFORM[3].xyz = res;
TRANSFORM[0] = vec4(cos(CUSTOM.x),-sin(CUSTOM.x),0.0,0.0);
TRANSFORM[1] = vec4(sin(CUSTOM.x),cos(CUSTOM.x),0.0,0.0);
TRANSFORM[2] = vec4(0.0,0.0,1.0,0.0);
TRANSFORM[0].xyz *= h_mod;
TRANSFORM[1].xyz *= h_mod;
TRANSFORM[2].xyz *= h_mod;
CUSTOM.z = rand_from_seed(seed);
CUSTOM.y = rand_from_seed(seed);
}
"
[sub_resource type="ShaderMaterial" id=3]
shader = SubResource( 2 )
shader_param/spacing = 10.0
shader_param/height = 200.0
shader_param/angle = 0.3
shader_param/period = 1.0
shader_param/min_height_random = 0.8
shader_param/max_height_random = 1.2
[sub_resource type="CanvasItemMaterial" id=4]
particles_animation = true
particles_anim_h_frames = 10
particles_anim_v_frames = 10
particles_anim_loop = false
[sub_resource type="ParticlesMaterial" id=5]
flag_disable_z = true
gravity = Vector3( 0, 98, 0 )
orbit_velocity = 0.0
orbit_velocity_random = 0.0
anim_speed = 14.89
[node name="root" type="Node2D"]
[node name="Particles2D" type="Particles2D" parent="."]
material = SubResource( 1 )
position = Vector2( 212.915, 394.34 )
amount = 100
process_material = SubResource( 3 )
texture = ExtResource( 1 )
[node name="Particles2D2" type="Particles2D" parent="."]
visible = false
material = SubResource( 4 )
process_material = SubResource( 5 )
texture = ExtResource( 2 )