float EASE_LINEAR           = 0.0;
float EASE_QUAD_IN          = 1.0;
float EASE_QUAD_OUT         = 2.0;
float EASE_QUAD_IN_OUT      = 3.0;
float EASE_CUBIC_IN         = 4.0;
float EASE_CUBIC_OUT        = 5.0;
float EASE_CUBIC_IN_OUT     = 6.0;
float EASE_QUART_IN         = 7.0;
float EASE_QUART_OUT        = 8.0;
float EASE_QUART_IN_OUT     = 9.0;
float EASE_QUINT_IN         = 10.0;
float EASE_QUINT_OUT        = 11.0;
float EASE_QUINT_IN_OUT     = 12.0;
float EASE_SINE_IN          = 13.0;
float EASE_SINE_OUT         = 14.0;
float EASE_SINE_IN_OUT      = 15.0;
// float EASE_CIRC_IN          = 16.0;
// float EASE_CIRC_OUT         = 17.0;
// float EASE_CIRC_IN_OUT      = 18.0;
float EASE_EXP_IN           = 19.0;
float EASE_EXP_OUT          = 20.0;
float EASE_EXP_IN_OUT       = 21.0;
float EASE_ELASTIC_IN       = 22.0;
float EASE_ELASTIC_OUT      = 23.0;
float EASE_ELASTIC_IN_OUT   = 24.0;
float EASE_BACK_IN          = 25.0;
float EASE_BACK_OUT         = 27.0;
float EASE_BACK_IN_OUT      = 28.0;
// float EASE_BOUNCE_IN        = 29.0;
// float EASE_BOUNCE_OUT       = 30.0;
// float EASE_BOUNCE_IN_OUT    = 31.0;

float tweenEase(float p, float ease) {
	float pi = 3.14159;
	float piOver2 = pi/2.0;
	if (abs(ease - EASE_LINEAR) < 0.01) {
		return p;
	} else if (abs(ease - EASE_QUAD_IN) < 0.01) {
		return p * p;
	} else if (abs(ease - EASE_QUAD_OUT) < 0.01) {
		return -(p * (p - 2.0));
	} else if (abs(ease - EASE_QUAD_IN_OUT) < 0.01) {
		if (p < 0.5) return 2.0 * p * p;
		else return (-2.0 * p * p) + (4.0 * p) - 1.0;
	} else if (abs(ease - EASE_CUBIC_IN) < 0.01) {
		return p * p * p;
	} else if (abs(ease - EASE_CUBIC_OUT) < 0.01) {
		float f = (p - 1.0);
		return f * f * f + 1.0;
	} else if (abs(ease - EASE_CUBIC_IN_OUT) < 0.01) {
		float f = ((2.0 * p) - 2.0);
		if (p < 0.5) return 4.0 * p * p * p;
		else return 0.5 * f * f * f + 1.0;
	} else if (abs(ease - EASE_QUART_IN) < 0.01) {
		return p * p * p * p;
	} else if (abs(ease - EASE_QUART_OUT) < 0.01) {
		float f = (p - 1.0);
		return f * f * f * (1.0 - p) + 1.0;
	} else if (abs(ease - EASE_QUART_IN_OUT) < 0.01) {
		float f = (p - 1.0);
		if (p < 0.5) return 8.0 * p * p * p * p;
		else return -8.0 * f * f * f * f + 1.0;
	} else if (abs(ease - EASE_QUINT_IN) < 0.01) {
		return p * p * p * p * p;
	} else if (abs(ease - EASE_QUINT_OUT) < 0.01) {
		float f = (p - 1.0);
		return f * f * f * f * f + 1.0;
	} else if (abs(ease - EASE_QUINT_IN_OUT) < 0.01) {
		float f = ((2.0 * p) - 2.0);
		if (p < 0.5) return 16.0 * p * p * p * p * p;
		else return 0.5 * f * f * f * f * f + 1.0;
	} else if (abs(ease - EASE_SINE_IN) < 0.01) {
		return sin((p - 1.0) * piOver2) + 1.0;
	} else if (abs(ease - EASE_SINE_OUT) < 0.01) {
		return sin(p * piOver2);
	} else if (abs(ease - EASE_SINE_IN_OUT) < 0.01) {
		return 0.5 * (1.0 - cos(p * pi));
	// } else if (abs(ease - EASE_CIRC_IN) < 0.01) {
	// 	float value = 1 - sqrt(1 - (p * p));
	// 	if (isnan(value)) value = 1;
	// 	return value;
	// } else if (abs(ease - EASE_CIRC_OUT) < 0.01) {
	// 	return sqrt((2 - p) * p);
	// } else if (abs(ease - EASE_CIRC_IN_OUT) < 0.01) {
	// 	if (p < 0.5) return 0.5 * (1 - sqrt(1 - 4 * (p * p)));
	// 	else return 0.5 * (sqrt(-((2 * p) - 3) * ((2 * p) - 1)) + 1);
	} else if (abs(ease - EASE_EXP_IN) < 0.01) {
		return (p == 0.0) ? p : pow(2.0, 10.0 * (p - 1.0));
	} else if (abs(ease - EASE_EXP_OUT) < 0.01) {
		return (p == 1.0) ? p : 1.0 - pow(2.0, -10.0 * p);
	} else if (abs(ease - EASE_EXP_IN_OUT) < 0.01) {
		if (p == 0.0 || p == 1.0) return p;
		if (p < 0.5) return 0.5 * pow(2.0, (20.0 * p) - 10.0);
		else return -0.5 * pow(2.0, (-20.0 * p) + 10.0) + 1.0;
	} else if (abs(ease - EASE_ELASTIC_IN) < 0.01) {
		return sin(13.0 * piOver2 * p) * pow(2.0, 10.0 * (p - 1.0));
	} else if (abs(ease - EASE_ELASTIC_OUT) < 0.01) {
		return sin(-13.0 * piOver2 * (p + 1.0)) * pow(2.0, -10.0 * p) + 1.0;
	} else if (abs(ease - EASE_ELASTIC_IN_OUT) < 0.01) {
		if (p < 0.5) return 0.5 * sin(13.0 * piOver2 * (2.0 * p)) * pow(2.0, 10.0 * ((2.0 * p) - 1.0));
		else return 0.5 * (sin(-13.0 * piOver2 * ((2.0 * p - 1.0) + 1.0)) * pow(2.0, -10.0 * (2.0 * p - 1.0)) + 2.0);
	} else if (abs(ease - EASE_BACK_IN) < 0.01) {
		return p * p * p - p * sin(p * pi);
	} else if (abs(ease - EASE_BACK_OUT) < 0.01) {
		float f = (1.0 - p);
		return 1.0 - (f * f * f - f * sin(f * pi));
	} else if (abs(ease - EASE_BACK_IN_OUT) < 0.01) {
		if (p < 0.5) {
			float f = 2.0 * p;
			return 0.5 * (f * f * f - f * sin(f * pi));
		} else {
			float f = (1.0 - (2.0*p - 1.0));
			return 0.5 * (1.0 - (f * f * f - f * sin(f * pi))) + 0.5;
		}
	// } else if (abs(ease - EASE_BOUNCE_IN) < 0.01) {
	// 	return 1 - tweenEase(1 - p, EASE_BOUNCE_OUT);
	// } else if (abs(ease - EASE_BOUNCE_OUT) < 0.01) {
	// 	if (p < 4/11.0) return (121 * p * p)/16.0;
	// 	else if (p < 8/11.0) return (363/40.0 * p * p) - (99/10.0 * p) + 17/5.0;
	// 	else if (p < 9/10.0) return (4356/361.0 * p * p) - (35442/1805.0 * p) + 16061/1805.0;
	// 	else return (54/5.0 * p * p) - (513/25.0 * p) + 268/25.0;
	// } else if (abs(ease - EASE_BOUNCE_IN_OUT) < 0.01) {
	// 	if (p < 0.5) return 0.5 * tweenEase(p*2, EASE_BOUNCE_IN);
	// 	else return 0.5 * tweenEase(p * 2 - 1, EASE_BOUNCE_OUT) + 0.5;
	}

	return 0.0;
}

void EndFragmentShader() {
#if (__VERSION__ == 100)
	gl_FragColor = finalColor;
#endif
}
