summaryrefslogtreecommitdiffstats
path: root/water/Water.gd
diff options
context:
space:
mode:
Diffstat (limited to 'water/Water.gd')
-rw-r--r--water/Water.gd16
1 files changed, 15 insertions, 1 deletions
diff --git a/water/Water.gd b/water/Water.gd
index d8027f8..9937725 100644
--- a/water/Water.gd
+++ b/water/Water.gd
@@ -13,6 +13,9 @@ export var wave3_steepness = 0.5 setget _set_wave3_steepness
export var wave3_wavelength = 10.0 setget _set_wave3_wavelength
export var wave3_direction = Vector2(1.0,0.0) setget _set_wave3_direction
+export var wave_speed = 2.0 setget _set_wave_speed
+export var wave_size = 1.5 setget _set_wave_size
+
onready var water_plane = $"MeshInstance"
func _set_wave_prop(idx, prop, val):
@@ -72,6 +75,16 @@ func _update_wave(idx):
material.set_shader_param("wave" + str(idx+1), _wave_to_v3(waves[idx]))
material.set_shader_param("wave" + str(idx+1) + "_dir", waves[idx].direction)
+func _set_wave_speed(val):
+ var material = self.water_plane.get_surface_material(0)
+ wave_speed = val
+ material.set_shader_param("wave_speed", wave_speed)
+
+func _set_wave_size(val):
+ var material = self.water_plane.get_surface_material(0)
+ wave_size = val
+ material.set_shader_param("wave_size", wave_size)
+
func _set_time(val):
_time = val
var material = self.water_plane.get_surface_material(0)
@@ -80,7 +93,7 @@ func _set_time(val):
material.set_shader_param("wave" + str(idx+1) + "_t", waves[idx]._t)
func _physics_process(delta):
- self._time += delta
+ self._time += delta * wave_speed
func gertsner_wave(pos, idx):
if idx >= waves.size(): return 0.0
@@ -101,6 +114,7 @@ func sample_wave(pos):
var offset = Vector3.ZERO
for idx in waves.size():
offset += gertsner_wave(pos, idx)
+ offset.y *= wave_size
return offset
func height(pos):