Index: ps/trunk/binaries/data/mods/official/shaders/water_high.xml =================================================================== --- ps/trunk/binaries/data/mods/official/shaders/water_high.xml (nonexistent) +++ ps/trunk/binaries/data/mods/official/shaders/water_high.xml (revision 3892) @@ -0,0 +1,8 @@ + + + + + shaders/water_high.vs + shaders/water_high.fs + + Index: ps/trunk/binaries/data/mods/official/shaders/water_high.fs =================================================================== --- ps/trunk/binaries/data/mods/official/shaders/water_high.fs (nonexistent) +++ ps/trunk/binaries/data/mods/official/shaders/water_high.fs (revision 3892) @@ -0,0 +1,44 @@ +uniform vec3 ambient; +uniform vec3 sunDir; +uniform vec3 sunColor; +uniform vec3 cameraPos; +uniform sampler2D normalMap; +uniform float shininess; + +varying vec3 worldPos; +varying vec3 waterColor; /* Water colour with LOS multiplied in */ +varying float waterDepth; + +void main() +{ + vec3 n, l, h, v; /* normal, vector to light, half-vector and view vector (vector to eye) */ + float ndotl, ndoth, ndotv; + float fresnel; + float t; + vec3 color; + vec3 specular; + + n = normalize(texture2D(normalMap, gl_TexCoord[0].st).xzy - vec3(0.5, 0.5, 0.5)); + l = -sunDir; + v = normalize(cameraPos - worldPos); + h = normalize(l + v); + + ndotl = dot(n, l); + ndoth = dot(n, h); + ndotv = dot(n, v); + + fresnel = pow(1.0 - ndotv, 0.8); /* A rather arbitrary Fresnel approximation */ + + color = ambient * waterColor; + specular = vec3(0.0, 0.0, 0.0); + if(ndotl > 0.0) + { + color += ndotl * sunColor * waterColor; + specular = pow(ndoth, shininess) * sunColor * 0.6; /* Assume specular color is (.6,.6,.6) for now */ + } + + gl_FragColor.rgb = color + specular; + + t = 8.0 * max(0.0, 0.7-v.y); + gl_FragColor.a = mix(0.15*waterDepth*(1.2 + t), 0.15*waterDepth*(2.0 + t), fresnel) * fresnel; +} Index: ps/trunk/binaries/data/mods/official/shaders/water_high.vs =================================================================== --- ps/trunk/binaries/data/mods/official/shaders/water_high.vs (nonexistent) +++ ps/trunk/binaries/data/mods/official/shaders/water_high.vs (revision 3892) @@ -0,0 +1,14 @@ +attribute float vertexDepth; + +varying vec3 worldPos; +varying vec3 waterColor; /* Water colour with LOS multiplied in */ +varying float waterDepth; + +void main() +{ + worldPos = gl_Vertex.xyz; + waterColor = gl_Color.xyz; + waterDepth = vertexDepth; + gl_TexCoord[0] = gl_MultiTexCoord0; + gl_Position = ftransform(); +}