OpenGL从一种颜色调到另一种颜色

时间:2013-04-02 12:46:47

标签: opengl

我制作了一个小粒子系统。我现在想做的是让颗粒在它的使用寿命期间从一种颜色褪色到另一种颜色。例如,从黑色到白色或从黄色到红色。

我使用glColor() functions来设置粒子的颜色。

我该怎么做?

1 个答案:

答案 0 :(得分:1)

你必须自己克服颜色:

计算0到1之间的混合因子并混合颜色

float blend = lifeTime / maxLifeTime;
float red = (destRed * blend) + (srcRed * (1.0 - blend));
float green = (destGreen * blend) + (srcGreen * (1.0 - blend));
float blue = (destBlue * blend) + (srcBlue * (1.0 - blend));

问候 罗恩

相关问题