2012-01-10 11:50:47 +00:00
|
|
|
uniform sampler2D palette;
|
|
|
|
uniform sampler2D texture;
|
|
|
|
uniform float realtime;
|
|
|
|
|
|
|
|
varying vec2 tst;
|
|
|
|
|
|
|
|
const float SPEED = 20.0;
|
|
|
|
const float CYCLE = 128.0;
|
|
|
|
const float PI = 3.14159;
|
|
|
|
const float FACTOR = PI * 2.0 / CYCLE;
|
2012-01-10 21:38:27 +00:00
|
|
|
const vec2 BIAS = vec2 (1.0, 1.0);
|
2012-01-10 22:51:15 +00:00
|
|
|
const float SCALE = 8.0;
|
2012-01-10 21:38:27 +00:00
|
|
|
|
|
|
|
vec2
|
|
|
|
turb_st (vec2 st, float time)
|
|
|
|
{
|
2012-01-10 22:51:15 +00:00
|
|
|
vec2 angle = st.ts * CYCLE / 2.0;
|
2012-01-10 21:38:27 +00:00
|
|
|
vec2 phase = vec2 (time, time) * SPEED;
|
|
|
|
return st + (sin ((angle + phase) * FACTOR) + BIAS) / SCALE;
|
|
|
|
}
|
2012-01-10 11:50:47 +00:00
|
|
|
|
|
|
|
void
|
|
|
|
main (void)
|
|
|
|
{
|
|
|
|
float pix;
|
2012-01-10 21:38:27 +00:00
|
|
|
vec2 st;
|
2012-01-10 11:50:47 +00:00
|
|
|
|
2012-01-10 21:38:27 +00:00
|
|
|
st = turb_st (tst, realtime);
|
2012-01-10 11:50:47 +00:00
|
|
|
pix = texture2D (texture, st).r;
|
2012-01-14 11:51:43 +00:00
|
|
|
gl_FragColor = texture2D (palette, vec2 (pix, 0.0));
|
2012-01-10 11:50:47 +00:00
|
|
|
}
|