summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/environment
diff options
context:
space:
mode:
authorTodd Stinson <stinson@lindenlab.com>2011-12-13 11:15:18 -0800
committerTodd Stinson <stinson@lindenlab.com>2011-12-13 11:15:18 -0800
commit9d1db4f19ae7ca044e47d0fe4e605e14882351c5 (patch)
tree2d499d53b60b2486f1e6666f8b9fe2063f984d22 /indra/newview/app_settings/shaders/class1/environment
parent817c97c2f836948f210599a6f67e36a411b22c21 (diff)
parentdbc91a7fac9513bdd879c5c2dc82208e08eaad2d (diff)
Pull and merge from https://bitbucket.org/lindenlab/viewer-development.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/environment')
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/terrainF.glsl45
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/terrainV.glsl51
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl48
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl83
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterF.glsl90
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl50
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterV.glsl30
7 files changed, 288 insertions, 109 deletions
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
index c61d5a2a08..18f6d91804 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
@@ -1,4 +1,4 @@
-/**
+/**
* @file terrainF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
@@ -23,19 +23,42 @@
* $/LicenseInfo$
*/
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 gl_FragColor;
+#endif
+VARYING vec4 vertex_color;
+VARYING vec4 vary_texcoord0;
+VARYING vec4 vary_texcoord1;
-uniform sampler2D detail0;
-uniform sampler2D detail1;
-uniform sampler2D alphaRamp;
+uniform sampler2D detail_0;
+uniform sampler2D detail_1;
+uniform sampler2D detail_2;
+uniform sampler2D detail_3;
+uniform sampler2D alpha_ramp;
-void main()
+vec3 atmosLighting(vec3 light);
+
+vec3 scaleSoftClip(vec3 color);
+
+void main()
{
- float a = texture2D(alphaRamp, gl_TexCoord[1].xy).a;
- vec3 color = mix(texture2D(detail1, gl_TexCoord[2].xy).rgb,
- texture2D(detail0, gl_TexCoord[0].xy).rgb,
- a);
+ /// Note: This should duplicate the blending functionality currently used for the terrain rendering.
+
+ /// TODO Confirm tex coords and bind them appropriately in vert shader.
+ vec4 color0 = texture2D(detail_0, vary_texcoord0.xy);
+ vec4 color1 = texture2D(detail_1, vary_texcoord0.xy);
+ vec4 color2 = texture2D(detail_2, vary_texcoord0.xy);
+ vec4 color3 = texture2D(detail_3, vary_texcoord0.xy);
- gl_FragColor.rgb = color;
- gl_FragColor.a = texture2D(alphaRamp, gl_TexCoord[3].xy).a;
+ float alpha1 = texture2D(alpha_ramp, vary_texcoord0.zw).a;
+ float alpha2 = texture2D(alpha_ramp,vary_texcoord1.xy).a;
+ float alphaFinal = texture2D(alpha_ramp, vary_texcoord1.zw).a;
+ vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal );
+
+ /// Add WL Components
+ outColor.rgb = atmosLighting(outColor.rgb * vertex_color.rgb);
+
+ gl_FragColor = vec4(scaleSoftClip(outColor.rgb), 1.0);
}
+
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
index 917891c063..d09c5f9247 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
@@ -1,4 +1,4 @@
-/**
+/**
* @file terrainV.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
@@ -22,8 +22,25 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
+uniform mat3 normal_matrix;
+uniform mat4 texture_matrix0;
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
+
+uniform vec4 object_plane_t;
+uniform vec4 object_plane_s;
+
+ATTRIBUTE vec3 position;
+ATTRIBUTE vec3 normal;
+ATTRIBUTE vec2 texcoord0;
+ATTRIBUTE vec2 texcoord1;
+
+VARYING vec4 vertex_color;
+VARYING vec4 vary_texcoord0;
+VARYING vec4 vary_texcoord1;
+
+void calcAtmospherics(vec3 inPositionEye);
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
@@ -44,17 +61,27 @@ vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
void main()
{
//transform vertex
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-
- vec4 pos = gl_ModelViewMatrix * gl_Vertex;
- vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
+ gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0);
+
+ vec4 pos = modelview_matrix * vec4(position.xyz, 1.0);
+ vec3 norm = normalize(normal_matrix * normal);
+
+ calcAtmospherics(pos.xyz);
+
+ /// Potentially better without it for water.
+ pos /= pos.w;
+
+ vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), vec4(0));
- vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), gl_Color);
+ vertex_color = color;
+
+ // Transform and pass tex coords
+ vary_texcoord0.xy = texgen_object(vec4(position.xyz, 1.0), vec4(texcoord0,0,1), texture_matrix0, object_plane_s, object_plane_t).xy;
- gl_FrontColor = color;
+ vec4 t = vec4(texcoord1,0,1);
- gl_TexCoord[0] = texgen_object(gl_Vertex,gl_MultiTexCoord0,gl_TextureMatrix[0],gl_ObjectPlaneS[0],gl_ObjectPlaneT[0]);
- gl_TexCoord[1] = gl_TextureMatrix[1]*gl_MultiTexCoord1;
- gl_TexCoord[2] = texgen_object(gl_Vertex,gl_MultiTexCoord2,gl_TextureMatrix[2],gl_ObjectPlaneS[2],gl_ObjectPlaneT[2]);
- gl_TexCoord[3] = gl_TextureMatrix[3]*gl_MultiTexCoord3;
+ vary_texcoord0.zw = t.xy;
+ vary_texcoord1.xy = t.xy-vec2(2.0, 0.0);
+ vary_texcoord1.zw = t.xy-vec2(1.0, 0.0);
}
+
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
index 711b42b95e..e5c7ced52c 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
@@ -1,4 +1,4 @@
-/**
+/**
* @file terrainWaterF.glsl
*
* $LicenseInfo:firstyear=2007&license=viewerlgpl$
@@ -22,22 +22,44 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 gl_FragColor;
+#endif
-// this class1 shader is just a copy of terrainF
+VARYING vec4 vertex_color;
+VARYING vec4 vary_texcoord0;
+VARYING vec4 vary_texcoord1;
-uniform sampler2D detail0;
-uniform sampler2D detail1;
-uniform sampler2D alphaRamp;
+uniform sampler2D detail_0;
+uniform sampler2D detail_1;
+uniform sampler2D detail_2;
+uniform sampler2D detail_3;
+uniform sampler2D alpha_ramp;
-void main()
+vec3 atmosLighting(vec3 light);
+
+vec4 applyWaterFog(vec4 color);
+
+void main()
{
- float a = texture2D(alphaRamp, gl_TexCoord[1].xy).a;
- vec3 color = mix(texture2D(detail1, gl_TexCoord[2].xy).rgb,
- texture2D(detail0, gl_TexCoord[0].xy).rgb,
- a);
+ /// Note: This should duplicate the blending functionality currently used for the terrain rendering.
+
+ /// TODO Confirm tex coords and bind them appropriately in vert shader.
+ vec4 color0 = texture2D(detail_0, vary_texcoord0.xy);
+ vec4 color1 = texture2D(detail_1, vary_texcoord0.xy);
+ vec4 color2 = texture2D(detail_2, vary_texcoord0.xy);
+ vec4 color3 = texture2D(detail_3, vary_texcoord0.xy);
- gl_FragColor.rgb = color;
- gl_FragColor.a = texture2D(alphaRamp, gl_TexCoord[3].xy).a;
+ float alpha1 = texture2D(alpha_ramp, vary_texcoord0.zw).a;
+ float alpha2 = texture2D(alpha_ramp,vary_texcoord1.xy).a;
+ float alphaFinal = texture2D(alpha_ramp, vary_texcoord1.zw).a;
+ vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal );
+
+ /// Add WL Components
+ outColor.rgb = atmosLighting(outColor.rgb * vertex_color.rgb);
+
+ outColor = applyWaterFog(outColor);
+ gl_FragColor = outColor;
}
+
diff --git a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
index 72e8e739b3..1fdb90f792 100644
--- a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
@@ -23,36 +23,82 @@
* $/LicenseInfo$
*/
-
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 gl_FragColor;
+#endif
uniform sampler2D diffuseMap;
uniform sampler2D bumpMap;
uniform sampler2D screenTex;
+uniform sampler2D refTex;
+uniform sampler2D screenDepth;
+uniform vec4 fogCol;
+uniform vec3 lightDir;
+uniform vec3 specular;
+uniform float lightExp;
+uniform vec2 fbScale;
uniform float refScale;
+uniform float znear;
+uniform float zfar;
+uniform float kd;
+uniform vec4 waterPlane;
+uniform vec3 eyeVec;
uniform vec4 waterFogColor;
+uniform float waterFogDensity;
+uniform float waterFogKS;
+uniform vec2 screenRes;
//bigWave is (refCoord.w, view.w);
-varying vec4 refCoord;
-varying vec4 littleWave;
-varying vec4 view;
+VARYING vec4 refCoord;
+VARYING vec4 littleWave;
+VARYING vec4 view;
-void main()
+vec4 applyWaterFog(vec4 color, vec3 viewVec)
{
- vec4 color;
+ //normalize view vector
+ vec3 view = normalize(viewVec);
+ float es = -view.z;
+
+ //find intersection point with water plane and eye vector
- //get bigwave normal
- vec3 wavef = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0;
-
- //get detail normals
- vec3 dcol = texture2D(bumpMap, littleWave.xy).rgb*0.75;
- dcol += texture2D(bumpMap, littleWave.zw).rgb*1.25;
-
- //interpolate between big waves and little waves (big waves in deep water)
- wavef = (wavef+dcol)*0.5;
+ //get eye depth
+ float e0 = max(-waterPlane.w, 0.0);
+
+ //get object depth
+ float depth = length(viewVec);
+
+ //get "thickness" of water
+ float l = max(depth, 0.1);
- //crunch normal to range [-1,1]
- wavef -= vec3(1,1,1);
+ float kd = waterFogDensity;
+ float ks = waterFogKS;
+ vec4 kc = waterFogColor;
+
+ float F = 0.98;
+
+ float t1 = -kd * pow(F, ks * e0);
+ float t2 = kd + ks * es;
+ float t3 = pow(F, t2*l) - 1.0;
+
+ float L = min(t1/t2*t3, 1.0);
+
+ float D = pow(0.98, l*kd);
+ //return vec4(1.0, 0.0, 1.0, 1.0);
+ return color * D + kc * L;
+ //depth /= 10.0;
+ //return vec4(depth,depth,depth,0.0);
+}
+
+void main()
+{
+ vec4 color;
+
+ //get detail normals
+ vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0;
+ vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0;
+ vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0;
+ vec3 wavef = normalize(wave1+wave2+wave3);
//figure out distortion vector (ripply)
vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5;
@@ -60,6 +106,5 @@ void main()
vec4 fb = texture2D(screenTex, distort);
- gl_FragColor.rgb = mix(waterFogColor.rgb, fb.rgb, waterFogColor.a * 0.001 + 0.999);
- gl_FragColor.a = fb.a;
+ gl_FragColor = applyWaterFog(fb,view.xyz);
}
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
index 4d555b566a..444c896d38 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
@@ -23,20 +23,19 @@
* $/LicenseInfo$
*/
-
+#ifdef DEFINE_GL_FRAGCOLOR
+out vec4 gl_FragColor;
+#endif
vec3 scaleSoftClip(vec3 inColor);
vec3 atmosTransport(vec3 inColor);
-vec3 applyWaterFog(vec4 inColor);
-uniform sampler2D diffuseMap;
uniform sampler2D bumpMap;
uniform sampler2D screenTex;
uniform sampler2D refTex;
uniform float sunAngle;
uniform float sunAngle2;
-uniform float scaledAngle;
uniform vec3 lightDir;
uniform vec3 specular;
uniform float lightExp;
@@ -47,67 +46,92 @@ uniform vec3 normScale;
uniform float fresnelScale;
uniform float fresnelOffset;
uniform float blurMultiplier;
-uniform vec4 fogCol;
+
//bigWave is (refCoord.w, view.w);
-varying vec4 refCoord;
-varying vec4 littleWave;
-varying vec4 view;
+VARYING vec4 refCoord;
+VARYING vec4 littleWave;
+VARYING vec4 view;
void main()
{
- vec3 viewVec = view.xyz;
vec4 color;
- float dist = length(viewVec.xy);
+ float dist = length(view.xy);
//normalize view vector
- viewVec = normalize(viewVec);
+ vec3 viewVec = normalize(view.xyz);
//get wave normals
- vec3 wavef = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0;
-
- //get detail normals
- vec3 dcol = texture2D(bumpMap, littleWave.xy).rgb*0.75;
- dcol += texture2D(bumpMap, littleWave.zw).rgb*1.25;
-
- //interpolate between big waves and little waves (big waves in deep water)
- wavef = (wavef + dcol) * 0.5;
-
- //crunch normal to range [-1,1]
- wavef -= vec3(1,1,1);
- wavef = normalize(wavef);
-
+ vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0;
+ vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0;
+ vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0;
//get base fresnel components
- float df = dot(viewVec,wavef) * fresnelScale + fresnelOffset;
+ vec3 df = vec3(
+ dot(viewVec, wave1),
+ dot(viewVec, (wave2 + wave3) * 0.5),
+ dot(viewVec, wave3)
+ ) * fresnelScale + fresnelOffset;
+ df *= df;
vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5;
float dist2 = dist;
dist = max(dist, 5.0);
+ float dmod = sqrt(dist);
+
+ vec2 dmod_scale = vec2(dmod*dmod, dmod);
+
//get reflected color
- vec2 refdistort = wavef.xy*dot(normScale, vec3(0.333));
- vec2 refvec = distort+refdistort/dist;
- vec4 refcol = texture2D(refTex, refvec);
+ vec2 refdistort1 = wave1.xy*normScale.x;
+ vec2 refvec1 = distort+refdistort1/dmod_scale;
+ vec4 refcol1 = texture2D(refTex, refvec1);
+
+ vec2 refdistort2 = wave2.xy*normScale.y;
+ vec2 refvec2 = distort+refdistort2/dmod_scale;
+ vec4 refcol2 = texture2D(refTex, refvec2);
+
+ vec2 refdistort3 = wave3.xy*normScale.z;
+ vec2 refvec3 = distort+refdistort3/dmod_scale;
+ vec4 refcol3 = texture2D(refTex, refvec3);
+
+ vec4 refcol = refcol1 + refcol2 + refcol3;
+ float df1 = df.x + df.y + df.z;
+ refcol *= df1 * 0.333;
+
+ vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5;
+
+ wavef.z *= max(-viewVec.z, 0.1);
+ wavef = normalize(wavef);
+
+ float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset;
+
+ vec2 refdistort4 = wavef.xy*0.125;
+ refdistort4.y -= abs(refdistort4.y);
+ vec2 refvec4 = distort+refdistort4/dmod;
+ float dweight = min(dist2*blurMultiplier, 1.0);
+ vec4 baseCol = texture2D(refTex, refvec4);
+ refcol = mix(baseCol*df2, refcol, dweight);
//get specular component
float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0);
-
+
//harden specular
- spec = pow(spec, lightExp);
+ spec = pow(spec, 128.0);
//figure out distortion vector (ripply)
- vec2 distort2 = distort+wavef.xy*refScale/max(dist*df, 1.0);
+ vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0);
vec4 fb = texture2D(screenTex, distort2);
//mix with reflection
- color.rgb = mix(mix(fogCol.rgb, fb.rgb, fogCol.a), refcol.rgb, df);
+ // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug
+ color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999);
color.rgb += spec * specular;
- //color.rgb = applyWaterFog(color);//atmosTransport(color.rgb);
+ color.rgb = atmosTransport(color.rgb);
color.rgb = scaleSoftClip(color.rgb);
color.a = spec * sunAngle2;
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
index d44690d1fb..4bdfce9260 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
@@ -25,16 +25,50 @@
+uniform vec4 lightnorm;
+uniform vec4 waterPlane;
+uniform vec4 waterFogColor;
+uniform float waterFogDensity;
+uniform float waterFogKS;
+
+vec3 getPositionEye();
+
vec4 applyWaterFog(vec4 color)
{
- // GL_EXP2 Fog
- //float fog = exp(-gl_Fog.density * gl_Fog.density * gl_FogFragCoord * gl_FogFragCoord);
- // GL_EXP Fog
- // float fog = exp(-gl_Fog.density * gl_FogFragCoord);
- // GL_LINEAR Fog
- float fog = (gl_Fog.end - gl_FogFragCoord) * gl_Fog.scale;
- fog = clamp(fog, 0.0, 1.0);
- color.rgb = mix(gl_Fog.color.rgb, color.rgb, fog);
+ //normalize view vector
+ vec3 view = normalize(getPositionEye());
+ float es = -(dot(view, waterPlane.xyz));
+
+ //find intersection point with water plane and eye vector
+
+ //get eye depth
+ float e0 = max(-waterPlane.w, 0.0);
+
+ vec3 int_v = waterPlane.w > 0.0 ? view * waterPlane.w/es : vec3(0.0, 0.0, 0.0);
+
+ //get object depth
+ float depth = length(getPositionEye() - int_v);
+
+ //get "thickness" of water
+ float l = max(depth, 0.1);
+
+ float kd = waterFogDensity;
+ float ks = waterFogKS;
+ vec4 kc = waterFogColor;
+
+ float F = 0.98;
+
+ float t1 = -kd * pow(F, ks * e0);
+ float t2 = kd + ks * es;
+ float t3 = pow(F, t2*l) - 1.0;
+
+ float L = min(t1/t2*t3, 1.0);
+
+ float D = pow(0.98, l*kd);
+
+ color.rgb = color.rgb * D + kc.rgb * L;
+ color.a = kc.a + color.a;
+
return color;
}
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
index 610c06fbbc..f66ba1d2d9 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
@@ -22,8 +22,11 @@
* Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
* $/LicenseInfo$
*/
-
+uniform mat4 modelview_matrix;
+uniform mat4 modelview_projection_matrix;
+
+ATTRIBUTE vec3 position;
void calcAtmospherics(vec3 inPositionEye);
@@ -33,9 +36,9 @@ uniform float time;
uniform vec3 eyeVec;
uniform float waterHeight;
-varying vec4 refCoord;
-varying vec4 littleWave;
-varying vec4 view;
+VARYING vec4 refCoord;
+VARYING vec4 littleWave;
+VARYING vec4 view;
float wave(vec2 v, float t, float f, vec2 d, float s)
{
@@ -45,8 +48,7 @@ float wave(vec2 v, float t, float f, vec2 d, float s)
void main()
{
//transform vertex
- vec4 position = gl_Vertex;
- mat4 modelViewProj = gl_ModelViewProjectionMatrix;
+ mat4 modelViewProj = modelview_projection_matrix;
vec4 oPosition;
@@ -57,27 +59,29 @@ void main()
float d = length(oEyeVec.xy);
float ld = min(d, 2560.0);
- position.xy = eyeVec.xy + oEyeVec.xy/d*ld;
+ vec3 lpos = position;
+ lpos.xy = eyeVec.xy + oEyeVec.xy/d*ld;
view.xyz = oEyeVec;
d = clamp(ld/1536.0-0.5, 0.0, 1.0);
d *= d;
- oPosition = position;
+ oPosition = vec4(lpos, 1.0);
oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
oPosition = modelViewProj * oPosition;
refCoord.xyz = oPosition.xyz + vec3(0,0,0.2);
//get wave position parameter (create sweeping horizontal waves)
- vec3 v = position.xyz;
+ vec3 v = lpos;
v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0;
//push position for further horizon effect.
- position.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
- position.w = 1.0;
- position = position*gl_ModelViewMatrix;
+ vec4 pos;
+ pos.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
+ pos.w = 1.0;
+ pos = modelview_matrix*pos;
- calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz);
+ calcAtmospherics(pos.xyz);
//pass wave parameters to pixel shader