Fix particle shader

This commit is contained in:
Atlante45 2015-11-25 11:38:59 -08:00
parent bd23a4137e
commit 591025850b

View file

@ -56,19 +56,11 @@ float bezierInterpolate(float y1, float y2, float y3, float u) {
return (1.0 - u) * (1.0 - u) * y1 + 2.0 * (1.0 - u) * u * y2 + u * u * y3;
}
float interpolate3Floats(float y1, float y2, float y3, float u) {
if ((u <= 0.5 && y1 == y2) || (u >= 0.5 && y2 == y3)) {
// Flat line.
return y2;
}
return bezierInterpolate(y1, y2, y3, u);
}
vec4 interpolate3Vec4(vec4 y1, vec4 y2, vec4 y3, float u) {
return vec4(interpolate3Floats(y1.x, y2.x, y3.x, u),
interpolate3Floats(y1.y, y2.y, y3.y, u),
interpolate3Floats(y1.z, y2.z, y3.z, u),
interpolate3Floats(y1.w, y2.w, y3.w, u));
return vec4(bezierInterpolate(y1.x, y2.x, y3.x, u),
bezierInterpolate(y1.y, y2.y, y3.y, u),
bezierInterpolate(y1.z, y2.z, y3.z, u),
bezierInterpolate(y1.w, y2.w, y3.w, u));
}
@ -90,7 +82,7 @@ void main(void) {
varColor = interpolate3Vec4(particle.color.start, particle.color.middle, particle.color.finish, age);
// anchor point in eye space
float radius = interpolate3Floats(particle.radius.start, particle.radius.middle, particle.radius.finish , age);
float radius = bezierInterpolate(particle.radius.start, particle.radius.middle, particle.radius.finish , age);
vec4 quadPos = radius * UNIT_QUAD[twoTriID];
vec4 anchorPoint;