2012-05-09 15:30:53 +00:00
|
|
|
!!cvarf r_waterwarp
|
2018-11-27 16:48:19 +00:00
|
|
|
!!samps screen=0 warp=1 edge=2
|
2012-05-09 15:30:53 +00:00
|
|
|
|
|
|
|
//this is a post processing shader that is drawn fullscreen whenever the view is underwater.
|
|
|
|
//its generally expected to warp the view a little.
|
|
|
|
|
|
|
|
varying vec2 v_stc;
|
|
|
|
varying vec2 v_warp;
|
|
|
|
varying vec2 v_edge;
|
2018-11-27 16:48:19 +00:00
|
|
|
#ifdef VERTEX_SHADER
|
|
|
|
attribute vec2 v_texcoord;
|
2012-05-09 15:30:53 +00:00
|
|
|
uniform float e_time;
|
|
|
|
void main ()
|
|
|
|
{
|
2013-03-12 22:35:33 +00:00
|
|
|
gl_Position = ftetransform();
|
2014-08-19 06:08:23 +00:00
|
|
|
v_stc = vec2(v_texcoord.x, 1.0-v_texcoord.y);
|
2013-03-12 22:35:33 +00:00
|
|
|
v_warp.s = e_time * 0.25 + v_texcoord.s;
|
|
|
|
v_warp.t = e_time * 0.25 + v_texcoord.t;
|
|
|
|
v_edge = v_texcoord.xy;
|
2012-05-09 15:30:53 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef FRAGMENT_SHADER
|
2013-03-12 22:35:33 +00:00
|
|
|
uniform vec4 e_rendertexturescale;
|
2012-05-09 15:30:53 +00:00
|
|
|
uniform float cvar_r_waterwarp;
|
|
|
|
void main ()
|
|
|
|
{
|
2018-11-27 16:48:19 +00:00
|
|
|
vec2 amp = (0.010 / 0.625) * cvar_r_waterwarp * texture2D(s_edge, v_edge).rg;
|
|
|
|
vec3 offset = (texture2D(s_warp, v_warp).rgb - 0.5) * 2.0;
|
2013-03-12 23:13:39 +00:00
|
|
|
vec2 temp = v_stc + offset.xy * amp;
|
2018-11-27 16:48:19 +00:00
|
|
|
gl_FragColor = texture2D(s_screen, temp*e_rendertexturescale.st);
|
2012-05-09 15:30:53 +00:00
|
|
|
}
|
|
|
|
#endif
|