From c97129d711503ec18449d92a52c6cb7ecb79e293 Mon Sep 17 00:00:00 2001 From: Matei Date: Thu, 22 Jun 2006 21:11:56 +0000 Subject: [PATCH] Added water murkiness parameters to shaders. This was SVN commit r4014. --- binaries/data/mods/official/shaders/water_high.fs | 14 ++++++++++---- binaries/data/mods/official/shaders/water_high.vs | 2 -- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/binaries/data/mods/official/shaders/water_high.fs b/binaries/data/mods/official/shaders/water_high.fs index 06ae3534c9..fba44826ec 100644 --- a/binaries/data/mods/official/shaders/water_high.fs +++ b/binaries/data/mods/official/shaders/water_high.fs @@ -7,19 +7,23 @@ uniform sampler2D reflectionMap; uniform sampler2D refractionMap; uniform float shininess; uniform float waviness; +uniform vec3 tint; +uniform float murkiness; +uniform float fullDepth; -varying vec3 worldPos; -varying vec3 waterColor; +varying vec3 worldPos; varying float waterDepth; varying float w; -const vec3 specularColor = vec3(0.2, 0.2, 0.2); +const vec3 specularColor = vec3(0.15, 0.15, 0.15); void main() { vec3 n, l, h, v; // Normal, light vector, half-vector and view vector (vector to eye) float ndotl, ndoth, ndotv; float fresnel; + float myMurkiness; // Murkiness and tint at this pixel (tweaked based on lighting and depth) + vec3 myTint; float t; vec2 reflCoords, refrCoords; vec3 reflColor, refrColor, specular; @@ -43,7 +47,9 @@ void main() reflColor = texture2D(reflectionMap, reflCoords).rgb; - refrColor = (0.5 + 0.5*ndotl) * mix(texture2D(refractionMap, refrCoords).rgb, waterColor, 0.3); + myMurkiness = murkiness * min(waterDepth / fullDepth, 1.0); + myTint = (ambient + ndotl * sunColor) * tint; + refrColor = (0.6 + 0.4*ndotl) * mix(texture2D(refractionMap, refrCoords).rgb, myTint, myMurkiness); specular = pow(max(0.0, ndoth), shininess) * sunColor * specularColor; diff --git a/binaries/data/mods/official/shaders/water_high.vs b/binaries/data/mods/official/shaders/water_high.vs index f3749e4278..dd7eda46c8 100644 --- a/binaries/data/mods/official/shaders/water_high.vs +++ b/binaries/data/mods/official/shaders/water_high.vs @@ -4,14 +4,12 @@ uniform mat4 refractionMatrix; attribute float vertexDepth; varying vec3 worldPos; -varying vec3 waterColor; varying float waterDepth; varying float w; void main() { worldPos = gl_Vertex.xyz; - waterColor = gl_Color.rgb; waterDepth = vertexDepth; gl_TexCoord[0] = gl_MultiTexCoord0; gl_TexCoord[1] = reflectionMatrix * gl_Vertex; // projective texturing