Originally posted by golden_boy
View Post



*water1 { glslprogram { !!cvarf r_wateralpha varying vec2 tc; varying vec4 tf; varying vec3 norm; varying vec3 eye; #ifdef VERTEX_SHADER attribute vec2 v_texcoord; attribute vec3 v_normal; uniform vec3 e_eyepos; void main (void) { tc = v_texcoord.st; tf = ftetransform(); norm = v_normal; eye = e_eyepos - v_position; gl_Position = tf; } #endif #ifdef FRAGMENT_SHADER uniform sampler2D s_t0; //refract uniform sampler2D s_t1; //normalmap uniform sampler2D s_t2; //diffuse uniform float e_time; uniform float cvar_r_wateralpha; void main (void) { vec2 stc, ntc; vec3 n, refr, refl; float fres; stc = (1.0 + (tf.xy / tf.w)) * 0.5; //apply q1-style warp, just for kicks ntc.s = tc.s + sin(tc.t+e_time)*0.125; ntc.t = tc.t + sin(tc.s+e_time)*0.125; //generate the two waveforms n = (texture2D(s_t1, 0.2*tc + vec2(e_time*0.1, 0)).xyz); n += (texture2D(s_t1, 0.2*tc - vec2(0, e_time*0.097)).xyz); n -= 1.0 - 4.0/256.0; //rebalance to avoid 8bit precision issues n = normalize(n); refr = texture2D(s_t0, stc + n.st*0.2).rgb; refl = texture2D(s_t2, ntc).rgb; //actually this is just the regular warped texture //fresnel term please! fres = abs(dot(norm, normalize(eye))); fres *= 1.0-(cvar_r_wateralpha * 0.5); //I've used an extra multiplier to ensure its visible. gl_FragColor = vec4(refr * fres + refl*(1-fres), 1.0); } #endif } { map $currentrender } { map water1_norm.tga } { map water1.tga } }
Comment