From 5dbf913d41e1c0cb0484b04f94b18039b3bf7388 Mon Sep 17 00:00:00 2001 From: Bill Currie Date: Wed, 11 Jan 2012 06:38:27 +0900 Subject: [PATCH] Get the turbulence more correct. This looks right, and should be easier to tweak. --- libs/video/renderer/glsl/quaketrb.frag | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libs/video/renderer/glsl/quaketrb.frag b/libs/video/renderer/glsl/quaketrb.frag index 885123ec3..52d6c4ab2 100644 --- a/libs/video/renderer/glsl/quaketrb.frag +++ b/libs/video/renderer/glsl/quaketrb.frag @@ -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)); }