Last active
May 23, 2021 01:36
-
-
Save behreajj/e868aedca8009c37329dcf9b0008b22a to your computer and use it in GitHub Desktop.
Zig Zag, Bounce, Oscillate
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float zigzag(float t) { | |
float a = t * 0.5; | |
float b = a - floor(a); | |
return 1.0 - abs(b + b - 1.0); | |
} | |
float oscillate(float t) { | |
return 0.5 + 0.5 * sin(M_PI * (t - 0.5)); | |
} | |
float bounce(float t) { | |
return abs(sin(M_PI_2 * t)); | |
} | |
shader pingPongScalar( | |
float A = 0.0, | |
float B = 1.0, | |
float T = 0.5, | |
output float ZigZag = 0.5, | |
output float Oscillate = 0.5, | |
output float Bounce = 0.5) { | |
ZigZag = mix(A, B, zigzag(T)); | |
Oscillate = mix(A, B, oscillate(T)); | |
Bounce = mix(A, B, bounce(T)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment