Get the turbulence more correct.

This looks right, and should be easier to tweak.
This commit is contained in:
Bill Currie 2012-01-11 06:38:27 +09:00
parent d2dae4cc58
commit 5dbf913d41

View file

@ -8,15 +8,24 @@ const float SPEED = 20.0;
const float CYCLE = 128.0;
const float PI = 3.14159;
const float FACTOR = PI * 2.0 / CYCLE;
const vec2 BIAS = vec2 (1.0, 1.0);
const float SCALE = 16.0;
vec2
turb_st (vec2 st, float time)
{
vec2 angle = st.ts * CYCLE;
vec2 phase = vec2 (time, time) * SPEED;
return st + (sin ((angle + phase) * FACTOR) + BIAS) / SCALE;
}
void
main (void)
{
float pix;
vec2 rt = vec2 (realtime, realtime);
vec2 st = tst;
vec2 st;
st = st + sin ((tst.ts * 64.0 + rt * SPEED) * FACTOR) / 64.0;
st = turb_st (tst, realtime);
pix = texture2D (texture, st).r;
gl_FragColor = texture2D (palette, vec2 (pix, 0.5));
}