Skip to content

Commit

Permalink
Merge pull request #60 from tsoding/58
Browse files Browse the repository at this point in the history
(#58) Add params to some filters
  • Loading branch information
rexim authored Jun 7, 2021
2 parents 48367e8 + a755207 commit a2560d4
Showing 1 changed file with 71 additions and 10 deletions.
81 changes: 71 additions & 10 deletions js/filters.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,62 @@
// TODO(#58): add params to all of the filters
// TODO(#61): human readable titles for the filter params
const filters = {
"Hop": {
"transparent": 0x00FF00,
"duration": "0.85 * 2",
"duration": "interval * 2",
// TODO(#62): when you have too many params the UI gets really cluttered
"params": {
"interval": {
"type": "float",
"init": 0.85,
"min": 0.01,
"max": 2.00,
"step": 0.01,
},
"ground": {
"type": "float",
"init": 0.5,
"min": -1.0,
"max": 1.0,
"step": 0.01,
},
"scale": {
"type": "float",
"init": 0.40,
"min": 0.0,
"max": 1.0,
"step": 0.01,
},
// TODO(#63): jump_height in the "Hop" filter does not make any sense
// If it's bigger the emote should jump higher. Right now it is the other way around.
"jump_height": {
"type": "float",
"init": 4.0,
"min": 1.0,
"max": 10.0,
"step": 0.01,
},
"hops": {
"type": "float",
"init": 2.0,
"min": 1.0,
"max": 5.0,
"step": 1.0,
}
},
"vertex": `#version 100
precision mediump float;
attribute vec2 meshPosition;
uniform float time;
uniform vec2 emoteSize;
uniform float interval;
uniform float ground;
uniform float scale;
uniform float jump_height;
uniform float hops;
varying vec2 uv;
float sliding_from_left_to_right(float time_interval) {
Expand All @@ -21,14 +68,11 @@ float flipping_directions(float time_interval) {
}
void main() {
float scale = 0.40;
float hops = 2.0;
float x_time_interval = 0.85;
float x_time_interval = interval;
float y_time_interval = x_time_interval / (2.0 * hops);
float height = 0.5;
vec2 offset = vec2(
sliding_from_left_to_right(x_time_interval) * flipping_directions(x_time_interval) * (1.0 - scale),
((sliding_from_left_to_right(y_time_interval) * flipping_directions(y_time_interval) + 1.0) / 4.0) - height);
((sliding_from_left_to_right(y_time_interval) * flipping_directions(y_time_interval) + 1.0) / jump_height) - ground);
gl_Position = vec4(
meshPosition * scale + offset,
Expand Down Expand Up @@ -171,7 +215,23 @@ void main() {
},
"Bounce": {
"transparent": 0x00FF00,
"duration": "Math.PI / 5.0",
"duration": "Math.PI / period",
"params": {
"period": {
"type": "float",
"init": 5.0,
"min": 1.0,
"max": 10.0,
"step": 0.1,
},
"scale": {
"type": "float",
"init": 0.30,
"min": 0.0,
"max": 1.0,
"step": 0.01,
}
},
"vertex": `#version 100
precision mediump float;
Expand All @@ -180,12 +240,13 @@ attribute vec2 meshPosition;
uniform vec2 resolution;
uniform float time;
uniform float period;
uniform float scale;
varying vec2 uv;
void main() {
float scale = 0.30;
float period_interval = 5.0;
vec2 offset = vec2(0.0, (2.0 * abs(sin(time * period_interval)) - 1.0) * (1.0 - scale));
vec2 offset = vec2(0.0, (2.0 * abs(sin(time * period)) - 1.0) * (1.0 - scale));
gl_Position = vec4(meshPosition * scale + offset, 0.0, 1.0);
uv = (meshPosition + 1.0) / 2.0;
}
Expand Down

0 comments on commit a2560d4

Please sign in to comment.