1
0
Fork 0
forked from fte/fteqw
fteqw/engine/shaders/glsl/underwaterwarp.glsl
Spoike de4a7409b2 ------------------------------------------------------------------------
r4235 | acceptthis | 2013-03-03 19:10:27 +0000 (Sun, 03 Mar 2013) | 5 lines

fix missing q2 surface water warp. fix missing q2 underwater warp.
tweak altwater shader+rendering to be capable of depth info too. Not enabling that yet.
fix q2 conchar colour issue.
fix rtlights in water.
attempt to remove borders of shadowmap lights. implement support for dynamic resolution shadowmaps. still needs to choose the resolution properly.
------------------------------------------------------------------------


git-svn-id: https://svn.code.sf.net/p/fteqw/code/trunk@4231 fc73d0e0-1445-4013-8a0c-d673dee63da5
2013-03-12 23:13:39 +00:00

37 lines
1.1 KiB
GLSL

!!cvarf r_waterwarp
//this is a post processing shader that is drawn fullscreen whenever the view is underwater.
//its generally expected to warp the view a little.
#ifdef VERTEX_SHADER
attribute vec2 v_texcoord;
varying vec2 v_stc;
varying vec2 v_warp;
varying vec2 v_edge;
uniform float e_time;
void main ()
{
gl_Position = ftetransform();
v_stc = (1.0+(gl_Position.xy / gl_Position.w))/2.0;
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;
}
#endif
#ifdef FRAGMENT_SHADER
varying vec2 v_stc;
varying vec2 v_warp;
varying vec2 v_edge;
uniform sampler2D s_t0;/*$currentrender*/
uniform sampler2D s_t1;/*warp image*/
uniform sampler2D s_t2;/*edge image*/
uniform vec4 e_rendertexturescale;
uniform float cvar_r_waterwarp;
void main ()
{
vec2 amp = (0.010 / 0.625) * cvar_r_waterwarp * texture2D(s_t2, v_edge).rg;
vec3 offset = (texture2D(s_t1, v_warp).rgb - 0.5) * 2.0;
vec2 temp = v_stc + offset.xy * amp;
gl_FragColor = texture2D(s_t0, temp*e_rendertexturescale.st);
}
#endif