diff options
Diffstat (limited to 'cli/app/search/live.py')
| -rw-r--r-- | cli/app/search/live.py | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/cli/app/search/live.py b/cli/app/search/live.py index 6fc2834..c6ee4c9 100644 --- a/cli/app/search/live.py +++ b/cli/app/search/live.py @@ -24,12 +24,13 @@ from app.search.params import timestamp from app.utils.cortex_utils import results_folder, upload_file_to_cortex from app.utils.tf_utils import read_checkpoint from subprocess import Popen, PIPE +from easing_functions import QuadEaseInOut # frames per second FPS = 25 # amount to smooth manual parameter changes. set to 1 to disable smoothing -SMOOTH_AMOUNT = 4 +SMOOTH_AMOUNT = 6 params = params_dense_dict('live') @@ -100,10 +101,10 @@ class SinParam: orbit_time = InterpolatorParam(name=name + '_time', value=0.0) if lerp: noise = LerpParam(name + '_noise', shape=shape, datatype=datatype) - output = tf.math.sin(orbit_time.variable + noise.output) * orbit_radius.variable + output = tf.math.cos(orbit_time.variable + noise.output) * orbit_radius.variable else: noise = InterpolatorParam(name + '_noise_a', shape=shape, datatype=datatype) - output = tf.math.sin(orbit_time.variable + noise.variable) * orbit_radius.variable + output = tf.math.cos(orbit_time.variable + noise.variable) * orbit_radius.variable interpolator.sin_params[name] = self self.name = name self.orbit_speed = orbit_speed @@ -132,6 +133,7 @@ class LerpParam: a = InterpolatorParam(name=name + '_a', shape=shape, datatype=datatype) b = InterpolatorParam(name=name + '_b', shape=shape, datatype=datatype) n = InterpolatorParam(name=name + '_n', value=0.0, smooth=True) + t = InterpolatorParam(name=name + '_t', value=0.0, smooth=False) speed = InterpolatorParam(name=name + '_speed', value=FPS, smooth=True) output = a.variable * (1 - n.variable) + b.variable * n.variable interpolator.lerp_params[name] = self @@ -139,12 +141,15 @@ class LerpParam: self.a = a self.b = b self.n = n + self.t = t + self.ease = QuadEaseInOut(start=0, end=1, duration=1) self.speed = speed self.output = output self.direction = 0 def switch(self, target_value=None): - if self.n.value > 0.5: + self.t.value = self.n.value + if self.t.value > 0.5: target_param = self.a self.direction = -1 else: @@ -157,8 +162,8 @@ class LerpParam: def update(self): if self.direction != 0: - n = clamp(self.n.value + self.direction / self.speed.value) - self.n.assign(n, immediate=True) + self.t.value = clamp(self.t.value + self.direction / self.speed.value) + self.n.assign(self.ease(self.t.value), immediate=True) print("set_opt: {}_n {}".format(self.name, self.n.value)) if self.n.value == 0 or self.n.value == 1: self.direction = 0 @@ -185,8 +190,8 @@ class InterpolatorParam: def assign(self, value, immediate=False): if self.datatype == 'float': value = float(value) - self.next_value = float(value) - if immediate or not self.smooth: + self.next_value = value + if not self.smooth or immediate: self.value = self.next_value else: self.value = value |
