2012-01-10 11:50:47 +00:00
|
|
|
uniform sampler2D palette;
|
|
|
|
uniform sampler2D texture;
|
|
|
|
uniform float realtime;
|
2012-01-29 01:27:28 +00:00
|
|
|
uniform vec4 fog;
|
2012-01-10 11:50:47 +00:00
|
|
|
|
|
|
|
varying vec2 tst;
|
2012-01-28 12:20:34 +00:00
|
|
|
varying vec4 color;
|
2012-01-10 11:50:47 +00:00
|
|
|
|
|
|
|
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
|
|
|
|
2012-01-29 01:27:28 +00:00
|
|
|
float
|
|
|
|
sqr (float x)
|
|
|
|
{
|
|
|
|
return x * x;
|
|
|
|
}
|
|
|
|
|
|
|
|
vec4
|
|
|
|
fogBlend (vec4 color)
|
|
|
|
{
|
|
|
|
float f;
|
|
|
|
vec4 fog_color = vec4 (fog.rgb, 1.0);
|
|
|
|
|
2012-07-17 10:10:10 +00:00
|
|
|
f = exp (-sqr (fog.a * gl_FragCoord.z / gl_FragCoord.w));
|
2012-07-17 10:08:36 +00:00
|
|
|
return vec4 (mix (fog_color.rgb, color.rgb, f), color.a);
|
2012-01-29 01:27:28 +00:00
|
|
|
}
|
|
|
|
|
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-29 01:27:28 +00:00
|
|
|
gl_FragColor = fogBlend (texture2D (palette, vec2 (pix, 0.0)) * color);
|
2012-01-10 11:50:47 +00:00
|
|
|
}
|