Skip to content

Commit

Permalink
ripple: Match input and output midpoints
Browse files Browse the repository at this point in the history
In this module, we do this in the shader (rather than using ProtonAOSP's
Java changes) for simplicity.
  • Loading branch information
kdrag0n committed Nov 28, 2021
1 parent d00a1df commit c517670
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,15 @@ float easeInOutCirc(float x) {
: (sqrt(1.0 - pow(-2.0 * x + 2.0, 2.0)) + 1.0) / 2.0;
}
// Input progress that results in 0.5 after the ease-out sine curve
const float MID_PROGRESS = 1.0 / 3.0;
vec4 main(vec2 pos) {
// Piecewise progress to map 0.5 in to 0.5 out after easeOutSine
float progress = (in_progress <= 0.5) ? in_progress / 0.5 * MID_PROGRESS
: MID_PROGRESS + (1.0 - MID_PROGRESS) * (in_progress - 0.5) / 0.5;
// Curve the linear animation progress for responsiveness
float progress = easeOutSine(in_progress);
progress = easeOutSine(progress);
// Show highlight immediately instead of fading in for instant feedback
// Fade the entire ripple out, including base highlight
Expand Down
8 changes: 7 additions & 1 deletion ripple.glsl
Original file line number Diff line number Diff line change
Expand Up @@ -77,9 +77,15 @@ float easeInOutCirc(float x) {
: (sqrt(1.0 - pow(-2.0 * x + 2.0, 2.0)) + 1.0) / 2.0;
}

// Input progress that results in 0.5 after the ease-out sine curve
const float MID_PROGRESS = 1.0 / 3.0;

vec4 main(vec2 pos) {
// Piecewise progress to map 0.5 in to 0.5 out after easeOutSine
float progress = (in_progress <= 0.5) ? in_progress / 0.5 * MID_PROGRESS
: MID_PROGRESS + (1.0 - MID_PROGRESS) * (in_progress - 0.5) / 0.5;
// Curve the linear animation progress for responsiveness
float progress = easeOutSine(in_progress);
progress = easeOutSine(progress);

// Show highlight immediately instead of fading in for instant feedback
// Fade the entire ripple out, including base highlight
Expand Down

0 comments on commit c517670

Please sign in to comment.