From 5dbc9c05c1ebd33e37315c096d2c9e1c6b96a8f2 Mon Sep 17 00:00:00 2001 From: dusoleil Date: Mon, 12 Sep 2022 20:40:16 -0400 Subject: Add gertsner wave shader --- Wave.gd | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Wave.gd (limited to 'Wave.gd') diff --git a/Wave.gd b/Wave.gd new file mode 100644 index 0000000..c876831 --- /dev/null +++ b/Wave.gd @@ -0,0 +1,48 @@ +class_name Wave +extends Resource + +export var steepness = 1.0 setget set_steepness +export var wavelength = 1.0 setget set_wavelength +export var direction = Vector2(1.0,0.0) setget set_direction + +var _k = 1.0 setget _set_k +var _a = 1.0 setget _set_a +var _c = 1.0 setget _set_c +var _time = 0.0 setget _set_time +var _t = 1.0 setget _set_t + +func _init(s, w, d, t): + self.steepness = s + self.wavelength = w + self.direction = d + self._time = t + +func set_steepness(val): + steepness = val + self._a = steepness / _k + +func set_wavelength(val): + wavelength = val + self._k = TAU / wavelength + +func set_direction(val): + direction = val + +func _set_k(val): + _k = val + self._a = steepness / _k + self._c = sqrt(9.8 / _k) + +func _set_a(val): + _a = val + +func _set_c(val): + _c = val + self._t = _c * _time + +func _set_time(val): + _time = val + self._t = _c * _time + +func _set_t(val): + _t = val -- cgit v1.2.3