1- [gd_scene load_steps =14 format =2 ]
1+ [gd_scene load_steps =16 format =2 ]
22
33[ext_resource path ="res://TerrainChunked.gd" type ="Script" id =1 ]
44[ext_resource path ="res://Scenes/Camera.tscn" type ="PackedScene" id =2 ]
99[ext_resource path ="res://TerrainTool.gd" type ="Script" id =7 ]
1010[ext_resource path ="res://addons/sairam.quadtree/AABBUtils.gd" type ="Script" id =8 ]
1111[ext_resource path ="res://Materials/Terrain.material" type ="Material" id =9 ]
12+ [ext_resource path ="res://GUI.tscn" type ="PackedScene" id =10 ]
13+ [ext_resource path ="res://Materials/Drawing.material" type ="Material" id =11 ]
14+
15+ [sub_resource type ="Shader" id =4 ]
16+ code = "shader_type spatial ;
17+ // by Sairam
18+ uniform float radius = 3.0 ;
19+ uniform float attenuated_radius = 0.01 ;
20+ uniform float attenuation_strength = 1.0 ;
21+ uniform float attenuated_size_multiplier = 1.0 ;
22+ uniform float max_power = 1 ;
23+ uniform float min_power = 0 ;
24+
25+ uniform vec4 color : hint_color = vec4 (0.0 , 1.0 , 1.0 , 0.5 );
26+
27+ varying vec3 vertex_1 ;
28+
29+ float get_power_at_position (vec3 point ) {
30+ vec3 origin = vec3 (0.0 , 0.0 , 0.0 );
31+ float dist = pow (distance (origin , point ), 2.0 );
32+
33+ if (dist >= radius * radius ) {
34+ return min_power ;
35+ }
36+ if (dist <= attenuated_radius * attenuated_radius ) {
37+ return max_power ;
38+ }
39+
40+ float ratio = 1.0 - ((dist - attenuated_radius * attenuated_radius ) / (radius * radius - attenuated_radius * attenuated_radius ));
41+ return mix (min_power , max_power , ratio ) * attenuation_strength * attenuated_size_multiplier ;
42+ }
1243
13- [sub_resource type ="SpatialMaterial" id =2 ]
14- albedo_color = Color ( 0 , 1 , 1 , 1 )
15-
16- [sub_resource type ="CylinderMesh" id =3 ]
17- material = SubResource ( 2 )
18- top_radius = 3.0
19- bottom_radius = 3.0
20- height = 0.5
21-
22- [sub_resource type ="SpatialMaterial" id =4 ]
23- flags_unshaded = true
24- params_line_width = 24.8
25- albedo_color = Color ( 1 , 0 , 0 , 1 )
44+ void vertex () {
45+ vertex_1 = VERTEX ;
46+ }
2647
27- [sub_resource type ="SpatialMaterial" id =5 ]
48+ void fragment () {
49+ ALBEDO = color .xyz ;
50+ ALPHA = get_power_at_position (vertex_1 ) * color .a ;
51+ }"
52+
53+ [sub_resource type ="ShaderMaterial" id =5 ]
54+ shader = SubResource ( 4 )
55+ shader_param/radius = 3.0
56+ shader_param/attenuated_radius = 0.01
57+ shader_param/attenuation_strength = 1.164
58+ shader_param/attenuated_size_multiplier = 1.778
59+ shader_param/max_power = 1.0
60+ shader_param/min_power = 0.0
61+ shader_param/color = Color ( 0 , 1 , 1 , 0.498039 )
62+
63+ [sub_resource type ="CylinderMesh" id =6 ]
64+ material = SubResource ( 5 )
65+ top_radius = 4.0
66+ bottom_radius = 4.0
67+ height = 0.01
68+
69+ [sub_resource type ="SpatialMaterial" id =7 ]
2870flags_unshaded = true
2971params_line_width = 24.8
3072albedo_color = Color ( 0 , 0 , 0 , 1 )
@@ -36,9 +78,10 @@ script = ExtResource( 8 )
3678
3779[node name ="Terrain" type ="Spatial" parent ="." ]
3880script = ExtResource ( 1 )
81+ chunk_size = 8
3982terrain_tool_node = NodePath ("../Tools/TerrainTool" )
4083terrain_material = ExtResource ( 9 )
41- size = 64
84+ size = 128
4285
4386[node name ="Camera" parent ="." instance =ExtResource ( 2 )]
4487transform = Transform ( 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 5 , 0 )
@@ -49,14 +92,16 @@ zooming/max_distance = 300.0
4992[node name ="Tools" type ="Spatial" parent ="." ]
5093
5194[node name ="TerrainTool" type ="MeshInstance" parent ="Tools" ]
52- mesh = SubResource ( 3 )
95+ mesh = SubResource ( 6 )
5396material/0 = null
5497script = ExtResource ( 7 )
5598
5699[node name ="AttenuatedCircle" type ="Spatial" parent ="Tools/TerrainTool" ]
57100script = ExtResource ( 6 )
58101radius = 3.0
59- attentuation_radius = 1.0
102+ attentuation_radius = 0.01
103+ attentuation_size_multiplier = 0.5
104+ min_power = 0.01
60105
61106[node name ="Raise" type ="AudioStreamPlayer" parent ="Tools/TerrainTool" ]
62107stream = ExtResource ( 4 )
@@ -69,16 +114,77 @@ volume_db = -3.098
69114[node name ="ImmediateGeometry" type ="ImmediateGeometry" parent ="Tools" ]
70115transform = Transform ( 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 0.1 , 0 )
71116visible = false
72- material_override = SubResource ( 4 )
117+ material_override = ExtResource ( 11 )
73118
74119[node name ="ImmediateGeometry2" type ="ImmediateGeometry" parent ="Tools" ]
75120transform = Transform ( 1 , 0 , 0 , 0 , 1 , 0 , 0 , 0 , 1 , 0 , 0.1 , 0 )
76121visible = false
77- material_override = SubResource ( 5 )
122+ material_override = SubResource ( 7 )
123+
124+ [node name ="Control2" parent ="." instance =ExtResource ( 10 )]
125+ mouse_filter = 2
126+
127+ [node name ="PanelContainer" parent ="Control2" index ="0" ]
128+ margin_left = -509.0
129+ margin_top = -208.0
130+ mouse_filter = 1
131+
132+ [node name ="VBoxContainer" parent ="Control2/PanelContainer" index ="0" ]
133+ margin_right = 447.0
134+ margin_bottom = 141.0
135+
136+ [node name ="Radius" parent ="Control2/PanelContainer/VBoxContainer" index ="0" ]
137+ margin_right = 440.0
138+
139+ [node name ="Radius" parent ="Control2/PanelContainer/VBoxContainer/Radius" index ="1" ]
140+ margin_right = 412.0
141+
142+ [node name ="Label2" parent ="Control2/PanelContainer/VBoxContainer/Radius" index ="2" ]
143+ margin_left = 416.0
144+ margin_right = 440.0
145+
146+ [node name ="Strength" parent ="Control2/PanelContainer/VBoxContainer" index ="1" ]
147+ margin_right = 440.0
148+
149+ [node name ="Strength" parent ="Control2/PanelContainer/VBoxContainer/Strength" index ="1" ]
150+ margin_right = 412.0
151+
152+ [node name ="Label2" parent ="Control2/PanelContainer/VBoxContainer/Strength" index ="2" ]
153+ margin_left = 416.0
154+ margin_right = 440.0
155+
156+ [node name ="RotationDegrees" parent ="Control2/PanelContainer/VBoxContainer" index ="2" ]
157+ margin_right = 440.0
158+
159+ [node name ="RotationDegrees" parent ="Control2/PanelContainer/VBoxContainer/RotationDegrees" index ="1" ]
160+ margin_right = 412.0
161+
162+ [node name ="Label2" parent ="Control2/PanelContainer/VBoxContainer/RotationDegrees" index ="2" ]
163+ margin_left = 416.0
164+ margin_right = 440.0
165+
166+ [node name ="HBoxContainer4" parent ="Control2/PanelContainer/VBoxContainer" index ="3" ]
167+ margin_right = 440.0
168+ margin_bottom = 134.0
169+
170+ [node name ="Button" parent ="Control2/PanelContainer/VBoxContainer/HBoxContainer4" index ="0" ]
171+ margin_right = 131.0
172+ margin_bottom = 56.0
173+
174+ [node name ="Button2" parent ="Control2/PanelContainer/VBoxContainer/HBoxContainer4" index ="1" ]
175+ margin_left = 154.0
176+ margin_right = 285.0
177+ margin_bottom = 56.0
178+
179+ [node name ="Button3" parent ="Control2/PanelContainer/VBoxContainer/HBoxContainer4" index ="2" ]
180+ margin_left = 308.0
181+ margin_right = 440.0
182+ margin_bottom = 56.0
78183
79184[node name ="Control" type ="Control" parent ="." ]
80185margin_right = 40.0
81186margin_bottom = 40.0
187+ mouse_filter = 1
82188script = ExtResource ( 3 )
83189__meta__ = {
84190"_edit_use_anchors_" : false
@@ -93,3 +199,10 @@ __meta__ = {
93199
94200[node name ="DirectionalLight" type ="DirectionalLight" parent ="." ]
95201transform = Transform ( 1 , 0 , 0 , 0 , 0.707107 , 0.707107 , 0 , -0.707107 , 0.707107 , 0 , 0 , 0 )
202+
203+ [connection signal ="radius_changed" from ="Control2/PanelContainer" to ="Tools/TerrainTool" method ="_on_PanelContainer_radius_changed" ]
204+ [connection signal ="rotation_changed" from ="Control2/PanelContainer" to ="Tools/TerrainTool" method ="_on_PanelContainer_rotation_changed" ]
205+ [connection signal ="state_changed" from ="Control2/PanelContainer" to ="Tools/TerrainTool" method ="_on_PanelContainer_state_changed" ]
206+ [connection signal ="strength_changed" from ="Control2/PanelContainer" to ="Tools/TerrainTool" method ="_on_PanelContainer_strength_changed" ]
207+
208+ [editable path ="Control2" ]
0 commit comments