summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/environment
diff options
context:
space:
mode:
authorBrad Kittenbrink <brad@lindenlab.com>2008-02-27 18:58:14 +0000
committerBrad Kittenbrink <brad@lindenlab.com>2008-02-27 18:58:14 +0000
commit6d52efe452aa8469e0343da1c7d108f3f52ab651 (patch)
treea87be48e9840d7fc1f7ee514d7c7f994e71fdb3c /indra/newview/app_settings/shaders/class1/environment
parent6027ad2630b8650cabcf00628ee9b0d25bedd67f (diff)
Merge of windlight into release (QAR-286). This includes all changes in
windlight14 which have passed QA (up through r79932). svn merge -r 80831:80833 svn+ssh://svn.lindenlab.com/svn/linden/branches/merge_windlight14_r80620
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/environment')
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/terrainF.glsl16
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/terrainV.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl23
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl45
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterF.glsl96
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl20
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterV.glsl90
7 files changed, 250 insertions, 53 deletions
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
index fde370155d..2278c6916d 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
@@ -1,9 +1,13 @@
-void terrain_lighting(inout vec3 color);
-
-uniform sampler2D detail0; //0
-uniform sampler2D detail1; //2
-uniform sampler2D alphaRamp; //1
+/**
+ * @file terrainF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+uniform sampler2D detail0;
+uniform sampler2D detail1;
+uniform sampler2D alphaRamp;
void main()
{
@@ -12,8 +16,6 @@ void main()
texture2D(detail0, gl_TexCoord[0].xy).rgb,
a);
- terrain_lighting(color);
-
gl_FragColor.rgb = color;
gl_FragColor.a = texture2D(alphaRamp, gl_TexCoord[3].xy).a;
}
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
index 3153a80e93..112d669819 100644
--- a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
@@ -1,7 +1,11 @@
-vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
-void default_scatter(vec3 viewVec, vec3 lightDir);
+/**
+ * @file terrainV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
-attribute vec4 materialColor;
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
{
@@ -25,7 +29,7 @@ void main()
vec4 pos = gl_ModelViewMatrix * gl_Vertex;
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
- vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color);
+ vec4 color = calcLighting(pos.xyz, norm, vec4(1,1,1,1), gl_Color);
gl_FrontColor = color;
@@ -33,5 +37,4 @@ void main()
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;
- default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
}
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
new file mode 100644
index 0000000000..e2f68e8826
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainWaterF.glsl
@@ -0,0 +1,23 @@
+/**
+ * @file terrainWaterF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+// this class1 shader is just a copy of terrainF
+
+uniform sampler2D detail0;
+uniform sampler2D detail1;
+uniform sampler2D alphaRamp;
+
+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);
+
+ gl_FragColor.rgb = color;
+ gl_FragColor.a = texture2D(alphaRamp, gl_TexCoord[3].xy).a;
+}
diff --git a/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
new file mode 100644
index 0000000000..f1740a4dcd
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/environment/underWaterF.glsl
@@ -0,0 +1,45 @@
+/**
+ * @file underWaterF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D diffuseMap;
+uniform sampler2D bumpMap;
+uniform sampler2D screenTex;
+
+uniform float refScale;
+uniform vec4 waterFogColor;
+
+//bigWave is (refCoord.w, view.w);
+varying vec4 refCoord;
+varying vec4 littleWave;
+varying vec4 view;
+
+void main()
+{
+ vec4 color;
+
+ //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;
+
+ //crunch normal to range [-1,1]
+ wavef -= vec3(1,1,1);
+
+ //figure out distortion vector (ripply)
+ vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5;
+ distort = distort+wavef.xy*refScale;
+
+ vec4 fb = texture2D(screenTex, distort);
+
+ gl_FragColor.rgb = mix(waterFogColor.rgb, fb.rgb, waterFogColor.a * 0.001 + 0.999);
+ gl_FragColor.a = fb.a;
+}
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
index f8b8031ce6..1c14381df9 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
@@ -1,22 +1,94 @@
-void water_lighting(inout vec3 diff);
+/**
+ * @file waterF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+vec3 scaleSoftClip(vec3 inColor);
+vec3 atmosTransport(vec3 inColor);
-uniform samplerCube environmentMap;
uniform sampler2D diffuseMap;
-uniform sampler2D bumpMap;
+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;
+uniform float refScale;
+uniform float kd;
+uniform vec2 screenRes;
+uniform vec3 normScale;
+uniform float fresnelScale;
+uniform float fresnelOffset;
+uniform float blurMultiplier;
+uniform vec4 fogCol;
-varying vec4 specular;
+//bigWave is (refCoord.w, view.w);
+varying vec4 refCoord;
+varying vec4 littleWave;
+varying vec4 view;
void main()
{
- vec4 depth = texture2D(diffuseMap, gl_TexCoord[0].xy);
- vec4 diff = texture2D(bumpMap, gl_TexCoord[1].xy);
- vec3 ref = textureCube(environmentMap, gl_TexCoord[2].xyz).rgb;
+ vec3 viewVec = view.xyz;
+ vec4 color;
+
+ float dist = length(viewVec.xy);
+
+ //normalize view vector
+ viewVec = normalize(viewVec);
+
+ //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);
+
+ //get base fresnel components
- diff.rgb *= depth.rgb;
+ float df = dot(viewVec,wavef) * fresnelScale + fresnelOffset;
+
+ vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5;
+
+ float dist2 = dist;
+ dist = max(dist, 5.0);
+
+ //get reflected color
+ vec2 refdistort = wavef.xy*dot(normScale, vec3(0.333));
+ vec2 refvec = distort+refdistort/dist;
+ vec4 refcol = texture2D(refTex, refvec);
+
+ //get specular component
+ float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0);
+
+ //harden specular
+ spec = pow(spec, lightExp);
+
+ //figure out distortion vector (ripply)
+ vec2 distort2 = distort+wavef.xy*refScale/max(dist*df, 1.0);
- vec3 col = mix(diff.rgb, ref, specular.a)+specular.rgb*diff.rgb;
+ vec4 fb = texture2D(screenTex, distort2);
+
+ //mix with reflection
+ color.rgb = mix(mix(fogCol.rgb, fb.rgb, fogCol.a), refcol.rgb, df);
+ color.rgb += spec * specular;
- water_lighting(col.rgb);
- gl_FragColor.rgb = col.rgb;
- gl_FragColor.a = (gl_Color.a+depth.a)*0.5;
+ color.rgb = atmosTransport(color.rgb);
+ color.rgb = scaleSoftClip(color.rgb);
+ color.a = spec * sunAngle2;
+
+ gl_FragColor = color;
}
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
new file mode 100644
index 0000000000..59e44fa871
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl
@@ -0,0 +1,20 @@
+/**
+ * @file waterFogF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+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);
+ 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 873a6fcb34..d332798103 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
@@ -1,41 +1,73 @@
-void default_scatter(vec3 viewVec, vec3 lightDir);
-vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol);
-vec2 getScatterCoord(vec3 viewVec, vec3 lightDir);
+/**
+ * @file waterV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
-varying vec4 specular;
+void calcAtmospherics(vec3 inPositionEye);
-vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
+uniform vec2 d1;
+uniform vec2 d2;
+uniform float time;
+uniform vec3 eyeVec;
+uniform float waterHeight;
+
+varying vec4 refCoord;
+varying vec4 littleWave;
+varying vec4 view;
+
+float wave(vec2 v, float t, float f, vec2 d, float s)
{
- vec4 tcoord;
-
- tcoord.x = dot(vpos, tp0);
- tcoord.y = dot(vpos, tp1);
- tcoord.z = tc.z;
- tcoord.w = tc.w;
-
- tcoord = mat * tcoord;
-
- return tcoord;
+ return (dot(d, v)*f + t*s)*f;
}
void main()
{
//transform vertex
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
- gl_TexCoord[0] = gl_MultiTexCoord0;
- gl_TexCoord[1] = texgen_object(gl_Vertex, gl_MultiTexCoord1, gl_TextureMatrix[1], gl_ObjectPlaneS[1],gl_ObjectPlaneT[1]);
+ vec4 position = gl_Vertex;
+ mat4 modelViewProj = gl_ModelViewProjectionMatrix;
- vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
- vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
- vec4 spec = gl_Color;
- gl_FrontColor.rgb = calcLightingSpecular(pos, norm, gl_Color, spec, vec3(0.0, 0.0, 0.0)).rgb;
- gl_FrontColor.a = gl_Color.a;
- specular = spec;
- specular.a = gl_Color.a*0.5;
- vec3 ref = reflect(pos,norm);
+ vec4 oPosition;
+
+ //get view vector
+ vec3 oEyeVec;
+ oEyeVec.xyz = position.xyz-eyeVec;
+
+ float d = length(oEyeVec.xy);
+ float ld = min(d, 2560.0);
- gl_TexCoord[2] = gl_TextureMatrix[2]*vec4(ref,1);
+ position.xy = eyeVec.xy + oEyeVec.xy/d*ld;
+ view.xyz = oEyeVec;
+
+ d = clamp(ld/1536.0-0.5, 0.0, 1.0);
+ d *= d;
- default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
+ oPosition = position;
+ 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;
+ 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;
+
+ calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz);
+
+
+ //pass wave parameters to pixel shader
+ vec2 bigWave = (v.xy) * vec2(0.04,0.04) + d1 * time * 0.055;
+ //get two normal map (detail map) texture coordinates
+ littleWave.xy = (v.xy) * vec2(0.6, 1.2) + d2 * time * 0.05;
+ // littleWave.zw = (v.xy) * vec2(0.07, 0.15) - d1 * time * 0.043;
+ littleWave.zw = (v.xy) * vec2(0.3, 0.6) + d1 * time * 0.1;
+ view.w = bigWave.y;
+ refCoord.w = bigWave.x;
+
+ gl_Position = oPosition;
}
-