Created
May 23, 2017 13:01
-
-
Save PopupAsylumUK/524f97a1f8b5ca42b2d7114c2d4a24d2 to your computer and use it in GitHub Desktop.
A Smooth Clipping Function
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
public static float SmoothClip(float input, float min, float max, float spread, float step) { | |
float timelinePosition = (input - min) / (max - min) * (1 - spread) + spread; | |
float signedDistanceToScrubber = timelinePosition - step; | |
float normalizedDistanceToScrubber = signedDistanceToScrubber / spread; | |
return Mathf.Clamp01(1 - normalizedDistanceToScrubber); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment