summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders
diff options
context:
space:
mode:
authorBrad Kittenbrink <brad@lindenlab.com>2009-02-18 21:10:16 +0000
committerBrad Kittenbrink <brad@lindenlab.com>2009-02-18 21:10:16 +0000
commitabdc99f21b542c4fea67030ddbd7166c9d1c6c63 (patch)
tree3e984e405adfdec189ca8a047daca5250737ffbf /indra/newview/app_settings/shaders
parent34412f0530cf6a411b4de906a8e9da59cbcb3a85 (diff)
Merge of QAR-1267 to trunk. This was a combo merge of QAR-1175 (maint-render-9) and QAR-1236 (dll-msvcrt-2)
svn merge -r 109838:112264 svn+ssh://svn.lindenlab.com/svn/linden/branches/maint-render/maint-render-9-merge-r109833
Diffstat (limited to 'indra/newview/app_settings/shaders')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl88
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl69
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl68
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl78
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl20
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl15
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl38
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl42
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl48
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl29
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl30
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl63
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl41
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl20
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl83
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl75
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl28
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl14
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl279
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl24
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl139
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl25
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl36
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl41
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/treeF.glsl20
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/treeV.glsl22
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/waterF.glsl157
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/waterV.glsl76
-rw-r--r--indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterF.glsl1
35 files changed, 1732 insertions, 6 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
new file mode 100644
index 0000000000..a91e9fa15b
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -0,0 +1,88 @@
+/**
+ * @file alphaF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+uniform sampler2D diffuseMap;
+uniform sampler2DShadow shadowMap0;
+uniform sampler2DShadow shadowMap1;
+uniform sampler2DShadow shadowMap2;
+uniform sampler2DShadow shadowMap3;
+uniform sampler2D noiseMap;
+uniform sampler2DRect positionMap;
+
+uniform mat4 shadow_matrix[4];
+uniform vec4 shadow_clip;
+uniform vec2 screen_res;
+
+vec3 atmosLighting(vec3 light);
+vec3 scaleSoftClip(vec3 light);
+
+varying vec3 vary_ambient;
+varying vec3 vary_directional;
+varying vec3 vary_fragcoord;
+varying vec3 vary_position;
+
+uniform float alpha_soften;
+
+void main()
+{
+ vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
+ frag *= screen_res;
+
+ vec3 samp_pos = texture2DRect(positionMap, frag).xyz;
+
+ float shadow = 1.0;
+ vec4 pos = vec4(vary_position, 1.0);
+
+ if (pos.z > -shadow_clip.w)
+ {
+ if (pos.z < -shadow_clip.z)
+ {
+ vec4 lpos = shadow_matrix[3]*pos;
+ shadow = shadow2DProj(shadowMap3, lpos).x;
+ shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
+ }
+ else if (pos.z < -shadow_clip.y)
+ {
+ vec4 lpos = shadow_matrix[2]*pos;
+ shadow = shadow2DProj(shadowMap2, lpos).x;
+ }
+ else if (pos.z < -shadow_clip.x)
+ {
+ vec4 lpos = shadow_matrix[1]*pos;
+ shadow = shadow2DProj(shadowMap1, lpos).x;
+ }
+ else
+ {
+ vec4 lpos = shadow_matrix[0]*pos;
+ shadow = shadow2DProj(shadowMap0, lpos).x;
+ }
+ }
+
+ vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, gl_Color.a);
+ vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * col;
+
+ color.rgb = atmosLighting(color.rgb);
+
+ color.rgb = scaleSoftClip(color.rgb);
+
+ if (samp_pos.z != 0.0)
+ {
+ float dist_factor = alpha_soften;
+ float a = gl_Color.a;
+ a *= a;
+ dist_factor *= 1.0/(1.0-a);
+ color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0);
+ }
+
+ //gl_FragColor = gl_Color;
+ gl_FragColor = color;
+ //gl_FragColor = vec4(1,0,1,1);
+
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
new file mode 100644
index 0000000000..b496bd674f
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -0,0 +1,69 @@
+/**
+ * @file alphaV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
+void calcAtmospherics(vec3 inPositionEye);
+
+float calcDirectionalLight(vec3 n, vec3 l);
+float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+
+vec3 atmosAmbient(vec3 light);
+vec3 atmosAffectDirectionalLight(float lightIntensity);
+vec3 scaleDownLight(vec3 light);
+vec3 scaleUpLight(vec3 light);
+
+varying vec3 vary_ambient;
+varying vec3 vary_directional;
+varying vec3 vary_fragcoord;
+varying vec3 vary_position;
+
+uniform float near_clip;
+
+void main()
+{
+ //transform vertex
+ gl_Position = ftransform();
+
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+
+ vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
+ vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
+ vary_position = pos.xyz;
+
+ calcAtmospherics(pos.xyz);
+
+ //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
+ vec4 col;
+ col.a = gl_Color.a;
+
+ // Add windlight lights
+ col.rgb = atmosAmbient(vec3(0.));
+ col.rgb = scaleUpLight(col.rgb);
+
+ // Collect normal lights (need to be divided by two, as we later multiply by 2)
+ col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
+ col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
+ col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
+ col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
+ col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
+ col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+ col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
+ col.rgb = scaleDownLight(col.rgb);
+
+ vary_ambient = col.rgb*gl_Color.rgb;
+ vary_directional.rgb = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
+
+ col.rgb = min(col.rgb*gl_Color.rgb, 1.0);
+
+ gl_FrontColor = col;
+
+ gl_FogFragCoord = pos.z;
+
+ pos = gl_ModelViewProjectionMatrix * gl_Vertex;
+ vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
+
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl
new file mode 100644
index 0000000000..6c94f5c5a7
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl
@@ -0,0 +1,68 @@
+/**
+ * @file avatarAlphaF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D diffuseMap;
+uniform sampler2DShadow shadowMap0;
+uniform sampler2DShadow shadowMap1;
+uniform sampler2DShadow shadowMap2;
+uniform sampler2DShadow shadowMap3;
+uniform sampler2D noiseMap;
+
+uniform mat4 shadow_matrix[4];
+uniform vec4 shadow_clip;
+
+vec3 atmosLighting(vec3 light);
+vec3 scaleSoftClip(vec3 light);
+
+varying vec3 vary_ambient;
+varying vec3 vary_directional;
+varying vec4 vary_position;
+varying vec3 vary_normal;
+
+void main()
+{
+ float shadow = 1.0;
+ vec4 pos = vary_position;
+ vec3 norm = normalize(vary_normal);
+
+ vec3 nz = texture2D(noiseMap, gl_FragCoord.xy/128.0).xyz;
+
+ if (pos.z > -shadow_clip.w)
+ {
+
+ if (pos.z < -shadow_clip.z)
+ {
+ vec4 lpos = shadow_matrix[3]*pos;
+ shadow = shadow2DProj(shadowMap3, lpos).x;
+ }
+ else if (pos.z < -shadow_clip.y)
+ {
+ vec4 lpos = shadow_matrix[2]*pos;
+ shadow = shadow2DProj(shadowMap2, lpos).x;
+ }
+ else if (pos.z < -shadow_clip.x)
+ {
+ vec4 lpos = shadow_matrix[1]*pos;
+ shadow = shadow2DProj(shadowMap1, lpos).x;
+ }
+ else
+ {
+ vec4 lpos = shadow_matrix[0]*pos;
+ shadow = shadow2DProj(shadowMap0, lpos).x;
+ }
+ }
+
+
+ vec4 col = vec4(vary_ambient + vary_directional*shadow, gl_Color.a);
+ vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * col;
+
+ color.rgb = atmosLighting(color.rgb);
+
+ color.rgb = scaleSoftClip(color.rgb);
+
+ gl_FragColor = color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
new file mode 100644
index 0000000000..c1988d3c78
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -0,0 +1,78 @@
+/**
+ * @file avatarAlphaV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
+mat4 getSkinnedTransform();
+void calcAtmospherics(vec3 inPositionEye);
+
+float calcDirectionalLight(vec3 n, vec3 l);
+float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
+
+vec3 atmosAmbient(vec3 light);
+vec3 atmosAffectDirectionalLight(float lightIntensity);
+vec3 scaleDownLight(vec3 light);
+vec3 scaleUpLight(vec3 light);
+
+varying vec4 vary_position;
+varying vec3 vary_ambient;
+varying vec3 vary_directional;
+varying vec3 vary_normal;
+
+void main()
+{
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ vec4 pos;
+ vec3 norm;
+
+ mat4 trans = getSkinnedTransform();
+ pos.x = dot(trans[0], gl_Vertex);
+ pos.y = dot(trans[1], gl_Vertex);
+ pos.z = dot(trans[2], gl_Vertex);
+ pos.w = 1.0;
+
+ norm.x = dot(trans[0].xyz, gl_Normal);
+ norm.y = dot(trans[1].xyz, gl_Normal);
+ norm.z = dot(trans[2].xyz, gl_Normal);
+ norm = normalize(norm);
+
+ gl_Position = gl_ProjectionMatrix * pos;
+ vary_position = pos;
+ vary_normal = norm;
+
+ calcAtmospherics(pos.xyz);
+
+ //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
+ vec4 col;
+ col.a = gl_Color.a;
+
+ // Add windlight lights
+ col.rgb = atmosAmbient(vec3(0.));
+ col.rgb = scaleUpLight(col.rgb);
+
+ // Collect normal lights (need to be divided by two, as we later multiply by 2)
+ col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
+ col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
+ col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
+ col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
+ col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
+ col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
+ col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
+ col.rgb = scaleDownLight(col.rgb);
+
+ vary_ambient = col.rgb*gl_Color.rgb;
+ vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
+
+ col.rgb = min(col.rgb*gl_Color.rgb, 1.0);
+
+ gl_FrontColor = col;
+
+ gl_FogFragCoord = pos.z;
+
+}
+
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
new file mode 100644
index 0000000000..58aa5a9cb5
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -0,0 +1,20 @@
+/**
+ * @file avatarF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D diffuseMap;
+
+varying vec3 vary_normal;
+varying vec4 vary_position;
+
+void main()
+{
+ gl_FragData[0] = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy);
+ gl_FragData[1] = vec4(0,0,0,0);
+ gl_FragData[2] = vec4(normalize(vary_normal), 0.0);
+ gl_FragData[3] = vary_position;
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
new file mode 100644
index 0000000000..27c09db922
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
@@ -0,0 +1,15 @@
+/**
+ * @file avatarShadowF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D diffuseMap;
+
+
+void main()
+{
+ gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy));
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
new file mode 100644
index 0000000000..14da6b1ad4
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
@@ -0,0 +1,38 @@
+/**
+ * @file avatarShadowV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+mat4 getSkinnedTransform();
+
+attribute vec4 weight;
+
+void main()
+{
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ vec4 pos;
+ vec3 norm;
+
+ mat4 trans = getSkinnedTransform();
+ pos.x = dot(trans[0], gl_Vertex);
+ pos.y = dot(trans[1], gl_Vertex);
+ pos.z = dot(trans[2], gl_Vertex);
+ pos.w = 1.0;
+
+ norm.x = dot(trans[0].xyz, gl_Normal);
+ norm.y = dot(trans[1].xyz, gl_Normal);
+ norm.z = dot(trans[2].xyz, gl_Normal);
+ norm = normalize(norm);
+
+ pos = gl_ProjectionMatrix * pos;
+ //smash geometry against near clip plane
+ pos.z = max(pos.z, -1.0);
+ gl_Position = pos;
+
+ gl_FrontColor = gl_Color;
+}
+
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl
new file mode 100644
index 0000000000..12a7ff7f29
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl
@@ -0,0 +1,42 @@
+/**
+ * @file avatarV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+mat4 getSkinnedTransform();
+
+attribute vec4 weight;
+
+varying vec3 vary_normal;
+varying vec4 vary_position;
+
+void main()
+{
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ vec4 pos;
+ vec3 norm;
+
+ mat4 trans = getSkinnedTransform();
+ pos.x = dot(trans[0], gl_Vertex);
+ pos.y = dot(trans[1], gl_Vertex);
+ pos.z = dot(trans[2], gl_Vertex);
+ pos.w = 1.0;
+
+ norm.x = dot(trans[0].xyz, gl_Normal);
+ norm.y = dot(trans[1].xyz, gl_Normal);
+ norm.z = dot(trans[2].xyz, gl_Normal);
+ norm = normalize(norm);
+
+ vary_position = pos;
+ vary_normal = norm;
+
+ gl_Position = gl_ProjectionMatrix * pos;
+ //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+ gl_FrontColor = gl_Color;
+}
+
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
new file mode 100644
index 0000000000..3c6700a871
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -0,0 +1,48 @@
+/**
+ * @file blurLightF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+uniform sampler2DRect positionMap;
+uniform sampler2DRect normalMap;
+uniform sampler2DRect lightMap;
+
+uniform float blur_size;
+uniform vec2 delta;
+uniform vec3 kern[32];
+uniform int kern_length;
+uniform float kern_scale;
+
+varying vec2 vary_fragcoord;
+
+void main()
+{
+ vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz;
+ vec3 pos = texture2DRect(positionMap, vary_fragcoord.xy).xyz;
+ vec2 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rg;
+
+ vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy);
+
+ vec2 defined_weight = kern[0].xy; // special case the first (centre) sample's weight in the blur; we have to sample it anyway so we get it for 'free'
+ vec2 col = defined_weight * ccol;
+
+ for (int i = 1; i < kern_length; i++)
+ {
+ vec2 tc = vary_fragcoord.xy + kern[i].z*dlt;
+ vec3 samppos = texture2DRect(positionMap, tc).xyz;
+ float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
+ if (d*d <= 0.003)
+ {
+ col += texture2DRect(lightMap, tc).rg*kern[i].xy;
+ defined_weight += kern[i].xy;
+ }
+ }
+
+ col /= defined_weight;
+
+ gl_FragColor = vec4(col.r, col.g, 0.0, 1.0);
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
new file mode 100644
index 0000000000..b7f07e5702
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
@@ -0,0 +1,17 @@
+/**
+ * @file blurLightF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+varying vec2 vary_fragcoord;
+uniform vec2 screen_res;
+
+void main()
+{
+ //transform vertex
+ gl_Position = ftransform();
+ vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
+ vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
new file mode 100644
index 0000000000..a8712bc8cc
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -0,0 +1,29 @@
+/**
+ * @file bumpF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D diffuseMap;
+uniform sampler2D bumpMap;
+
+varying vec3 vary_mat0;
+varying vec3 vary_mat1;
+varying vec3 vary_mat2;
+varying vec4 vary_position;
+
+void main()
+{
+ vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
+ vec3 norm = texture2D(bumpMap, gl_TexCoord[0].xy).rgb * 2.0 - 1.0;
+
+ vec3 tnorm = vec3(dot(norm,vary_mat0),
+ dot(norm,vary_mat1),
+ dot(norm,vary_mat2));
+
+ gl_FragData[0].rgb = gl_Color.rgb*col;
+ gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a);
+ gl_FragData[2] = vec4(normalize(tnorm), 0.0);
+ gl_FragData[3] = vary_position;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
new file mode 100644
index 0000000000..ba180922cc
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
@@ -0,0 +1,30 @@
+/**
+ * @file bumpV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+varying vec3 vary_mat0;
+varying vec3 vary_mat1;
+varying vec3 vary_mat2;
+varying vec4 vary_position;
+
+void main()
+{
+ //transform vertex
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+
+ vary_position = gl_ModelViewMatrix * gl_Vertex;
+
+ vec3 n = normalize(gl_NormalMatrix * gl_Normal);
+ vec3 b = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz);
+ vec3 t = cross(b, n);
+
+ vary_mat0 = vec3(t.x, b.x, n.x);
+ vary_mat1 = vec3(t.y, b.y, n.y);
+ vary_mat2 = vec3(t.z, b.z, n.z);
+
+ gl_FrontColor = gl_Color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 14e6361f83..f2ba2df69a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -8,9 +8,13 @@
uniform sampler2D diffuseMap;
varying vec3 vary_normal;
+varying vec4 vary_position;
void main()
{
- gl_FragColor = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy);
- gl_FragColor.rgb = vary_normal*0.5+0.5;
+ vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
+ gl_FragData[0] = vec4(gl_Color.rgb*col, 1.0);
+ gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a);
+ gl_FragData[2] = vec4(normalize(vary_normal), 0.0);
+ gl_FragData[3] = vary_position;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
index 8e9069368a..3413a7f9d6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
@@ -6,7 +6,7 @@
*/
varying vec3 vary_normal;
-varying vec3 vary_position;
+varying vec4 vary_position;
void main()
{
@@ -14,7 +14,7 @@ void main()
gl_Position = ftransform();
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
- vary_position = (gl_ModelViewMatrix * gl_Vertex).xyz;
+ vary_position = gl_ModelViewMatrix * gl_Vertex;
vary_normal = normalize(gl_NormalMatrix * gl_Normal);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
new file mode 100644
index 0000000000..2a811c5897
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -0,0 +1,63 @@
+/**
+ * @file fullbrightF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+uniform sampler2D diffuseMap;
+uniform sampler2DShadow shadowMap0;
+uniform sampler2DShadow shadowMap1;
+uniform sampler2DShadow shadowMap2;
+uniform sampler2DShadow shadowMap3;
+uniform sampler2D noiseMap;
+uniform sampler2DRect positionMap;
+
+uniform mat4 shadow_matrix[4];
+uniform vec4 shadow_clip;
+uniform vec2 screen_res;
+
+vec3 fullbrightAtmosTransport(vec3 light);
+vec3 fullbrightScaleSoftClip(vec3 light);
+
+varying vec3 vary_ambient;
+varying vec3 vary_directional;
+varying vec4 vary_position;
+varying vec3 vary_normal;
+varying vec3 vary_fragcoord;
+
+uniform float alpha_soften;
+
+void main()
+{
+ vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
+ frag *= screen_res;
+
+ vec3 samp_pos = texture2DRect(positionMap, frag).xyz;
+
+ float shadow = 1.0;
+ vec4 pos = vary_position;
+
+ vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy)*gl_Color;
+
+ color.rgb = fullbrightAtmosTransport(color.rgb);
+
+ color.rgb = fullbrightScaleSoftClip(color.rgb);
+
+ if (samp_pos.z != 0.0)
+ {
+ float dist_factor = alpha_soften;
+ float a = gl_Color.a;
+ a *= a;
+ dist_factor *= 1.0/(1.0-a);
+ color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0);
+ }
+
+ //gl_FragColor = gl_Color;
+ gl_FragColor = color;
+ //gl_FragColor = vec4(1,0,1,1);
+
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl
new file mode 100644
index 0000000000..6381a1ced8
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl
@@ -0,0 +1,41 @@
+/**
+ * @file fullbrightV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+void calcAtmospherics(vec3 inPositionEye);
+
+vec3 atmosAmbient(vec3 light);
+vec3 atmosAffectDirectionalLight(float lightIntensity);
+vec3 scaleDownLight(vec3 light);
+vec3 scaleUpLight(vec3 light);
+
+varying vec4 vary_position;
+varying vec3 vary_ambient;
+varying vec3 vary_directional;
+varying vec3 vary_normal;
+varying vec3 vary_fragcoord;
+uniform float near_clip;
+
+void main()
+{
+ //transform vertex
+ gl_Position = ftransform();
+
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+
+ vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
+ vary_position = pos;
+
+ calcAtmospherics(pos.xyz);
+
+ gl_FrontColor = gl_Color;
+
+ gl_FogFragCoord = pos.z;
+
+ pos = gl_ModelViewProjectionMatrix * gl_Vertex;
+ vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
+
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
new file mode 100644
index 0000000000..20a3f3df5b
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
@@ -0,0 +1,20 @@
+/**
+ * @file impostorF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D diffuseMap;
+uniform sampler2D normalMap;
+uniform sampler2D specularMap;
+
+varying vec4 vary_position;
+
+void main()
+{
+ gl_FragData[0] = texture2D(diffuseMap, gl_TexCoord[0].xy);
+ gl_FragData[1] = texture2D(specularMap, gl_TexCoord[0].xy);
+ gl_FragData[2] = vec4(texture2D(normalMap, gl_TexCoord[0].xy).xyz, vary_position.z);
+ gl_FragData[3] = vary_position;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl
new file mode 100644
index 0000000000..9c5ae31541
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl
@@ -0,0 +1,19 @@
+/**
+ * @file impostorV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+varying vec4 vary_position;
+
+void main()
+{
+ //transform vertex
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+
+ vary_position = gl_ModelViewMatrix * gl_Vertex;
+
+ gl_FrontColor = gl_Color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
new file mode 100644
index 0000000000..3689d12840
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -0,0 +1,83 @@
+/**
+ * @file multiPointLightF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+uniform sampler2DRect diffuseRect;
+uniform sampler2DRect specularRect;
+uniform sampler2DRect positionMap;
+uniform sampler2DRect normalMap;
+uniform samplerCube environmentMap;
+uniform sampler2DRect lightMap;
+uniform sampler2D noiseMap;
+
+uniform vec3 env_mat[3];
+uniform float sun_wash;
+
+uniform int light_count;
+
+uniform vec4 light[16];
+uniform vec4 light_col[16];
+
+varying vec3 vary_fragcoord;
+uniform vec2 screen_res;
+
+void main()
+{
+ vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res;
+ vec3 pos = texture2DRect(positionMap, frag.xy).xyz;
+ vec3 norm = normalize(texture2DRect(normalMap, frag.xy).xyz);
+ vec4 spec = texture2DRect(specularRect, frag.xy);
+ vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
+ float noise = texture2D(noiseMap, frag.xy/128.0).b;
+ vec3 out_col = vec3(0,0,0);
+
+ for (int i = 0; i < light_count; ++i)
+ {
+ vec3 lv = light[i].xyz-pos;
+ float dist2 = dot(lv,lv);
+ if (dist2 > light[i].w)
+ {
+ continue;
+ }
+
+ float da = dot(norm, lv);
+ if (da < 0.0)
+ {
+ continue;
+ }
+
+ lv = normalize(lv);
+ da = dot(norm, lv);
+
+ float fa = light_col[i].a+1.0;
+ float dist_atten = clamp(1.0-(dist2-light[i].w*(1.0-fa))/(light[i].w*fa), 0.0, 1.0);
+ dist_atten *= noise;
+
+ float lit = da * dist_atten;
+
+ vec3 col = light_col[i].rgb*lit*diff;
+
+ if (spec.a > 0.0)
+ {
+ vec3 ref = reflect(normalize(pos), norm);
+ float sa = dot(ref,lv);
+ sa = max(sa, 0.0);
+ sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
+ sa *= noise;
+ col += da*sa*light_col[i].rgb*spec.rgb;
+ }
+
+ out_col += col;
+ }
+
+ //attenuate point light contribution by SSAO component
+ out_col *= texture2DRect(lightMap, frag.xy).g;
+
+ gl_FragColor.rgb = out_col;
+ gl_FragColor.a = 0.0;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
new file mode 100644
index 0000000000..52bad1f34c
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -0,0 +1,75 @@
+/**
+ * @file pointLightF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+uniform sampler2DRect diffuseRect;
+uniform sampler2DRect specularRect;
+uniform sampler2DRect positionMap;
+uniform sampler2DRect normalMap;
+uniform samplerCube environmentMap;
+uniform sampler2DRect lightMap;
+uniform sampler2D noiseMap;
+
+uniform vec3 env_mat[3];
+uniform float sun_wash;
+
+varying vec4 vary_light;
+
+varying vec3 vary_fragcoord;
+uniform vec2 screen_res;
+
+void main()
+{
+ vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
+ frag *= screen_res;
+ vec3 pos = texture2DRect(positionMap, frag).xyz;
+ vec3 lv = vary_light.xyz-pos;
+ float dist2 = dot(lv,lv);
+ if (dist2 > vary_light.w)
+ {
+ discard;
+ }
+
+ vec3 norm = texture2DRect(normalMap, frag).xyz;
+ float da = dot(norm, lv);
+ if (da < 0.0)
+ {
+ discard;
+ }
+
+ norm = normalize(norm);
+ lv = normalize(lv);
+ da = dot(norm, lv);
+
+ float noise = texture2D(noiseMap, frag/128.0).b;
+
+ vec3 col = texture2DRect(diffuseRect, frag).rgb;
+ float fa = gl_Color.a+1.0;
+ float dist_atten = clamp(1.0-(dist2-vary_light.w*(1.0-fa))/(vary_light.w*fa), 0.0, 1.0);
+ float lit = da * dist_atten * noise;
+
+ col = gl_Color.rgb*lit*col;
+
+ vec4 spec = texture2DRect(specularRect, frag);
+ if (spec.a > 0.0)
+ {
+ vec3 ref = reflect(normalize(pos), norm);
+ float sa = dot(ref,lv);
+ sa = max(sa, 0.0);
+ sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
+ sa *= noise;
+ col += da*sa*gl_Color.rgb*spec.rgb;
+ }
+
+ //attenuate point light contribution by SSAO component
+ col *= texture2DRect(lightMap, frag.xy).g;
+
+
+ gl_FragColor.rgb = col;
+ gl_FragColor.a = 0.0;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
new file mode 100644
index 0000000000..a4edb88259
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
@@ -0,0 +1,28 @@
+/**
+ * @file pointLightF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+varying vec4 vary_light;
+varying vec3 vary_fragcoord;
+
+uniform vec2 screen_res;
+uniform float near_clip;
+
+void main()
+{
+ //transform vertex
+ gl_Position = ftransform();
+
+ vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
+ vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
+
+ vec4 tex = gl_MultiTexCoord0;
+ tex.w = 1.0;
+
+ vary_light = gl_MultiTexCoord0;
+
+ gl_FrontColor = gl_Color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
new file mode 100644
index 0000000000..b3758c3638
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
@@ -0,0 +1,14 @@
+/**
+ * @file shadowF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D diffuseMap;
+
+
+void main()
+{
+ gl_FragColor = vec4(1,1,1,texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a);
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
new file mode 100644
index 0000000000..aae1beeae3
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
@@ -0,0 +1,17 @@
+/**
+ * @file shadowV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+void main()
+{
+ //transform vertex
+ vec4 pos = gl_ModelViewProjectionMatrix*gl_Vertex;
+ //smash geometry against the near clip plane (great for ortho projections)
+ pos.z = max(pos.z, -1.0);
+ gl_Position = pos;
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+ gl_FrontColor = gl_Color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
new file mode 100644
index 0000000000..d5671a6ce4
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -0,0 +1,279 @@
+/**
+ * @file softenLightF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+uniform sampler2DRect diffuseRect;
+uniform sampler2DRect specularRect;
+uniform sampler2DRect positionMap;
+uniform sampler2DRect normalMap;
+uniform sampler2DRect depthMap;
+uniform sampler2DRect lightMap;
+uniform sampler2D noiseMap;
+uniform samplerCube environmentMap;
+
+uniform float blur_size;
+uniform float blur_fidelity;
+
+// Inputs
+uniform vec4 morphFactor;
+uniform vec3 camPosLocal;
+//uniform vec4 camPosWorld;
+uniform vec4 gamma;
+uniform vec4 lightnorm;
+uniform vec4 sunlight_color;
+uniform vec4 ambient;
+uniform vec4 blue_horizon;
+uniform vec4 blue_density;
+uniform vec4 haze_horizon;
+uniform vec4 haze_density;
+uniform vec4 cloud_shadow;
+uniform vec4 density_multiplier;
+uniform vec4 distance_multiplier;
+uniform vec4 max_y;
+uniform vec4 glow;
+uniform float scene_light_strength;
+uniform vec3 env_mat[3];
+uniform mat4 shadow_matrix[3];
+uniform vec4 shadow_clip;
+uniform mat3 ssao_effect_mat;
+
+varying vec4 vary_light;
+varying vec2 vary_fragcoord;
+
+vec3 vary_PositionEye;
+
+vec3 vary_SunlitColor;
+vec3 vary_AmblitColor;
+vec3 vary_AdditiveColor;
+vec3 vary_AtmosAttenuation;
+
+vec3 getPositionEye()
+{
+ return vary_PositionEye;
+}
+vec3 getSunlitColor()
+{
+ return vary_SunlitColor;
+}
+vec3 getAmblitColor()
+{
+ return vary_AmblitColor;
+}
+vec3 getAdditiveColor()
+{
+ return vary_AdditiveColor;
+}
+vec3 getAtmosAttenuation()
+{
+ return vary_AtmosAttenuation;
+}
+
+
+void setPositionEye(vec3 v)
+{
+ vary_PositionEye = v;
+}
+
+void setSunlitColor(vec3 v)
+{
+ vary_SunlitColor = v;
+}
+
+void setAmblitColor(vec3 v)
+{
+ vary_AmblitColor = v;
+}
+
+void setAdditiveColor(vec3 v)
+{
+ vary_AdditiveColor = v;
+}
+
+void setAtmosAttenuation(vec3 v)
+{
+ vary_AtmosAttenuation = v;
+}
+
+void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
+
+ vec3 P = inPositionEye;
+ setPositionEye(P);
+
+ //(TERRAIN) limit altitude
+ if (P.y > max_y.x) P *= (max_y.x / P.y);
+ if (P.y < -max_y.x) P *= (-max_y.x / P.y);
+
+ vec3 tmpLightnorm = lightnorm.xyz;
+
+ vec3 Pn = normalize(P);
+ float Plen = length(P);
+
+ vec4 temp1 = vec4(0);
+ vec3 temp2 = vec3(0);
+ vec4 blue_weight;
+ vec4 haze_weight;
+ vec4 sunlight = sunlight_color;
+ vec4 light_atten;
+
+ //sunlight attenuation effect (hue and brightness) due to atmosphere
+ //this is used later for sunlight modulation at various altitudes
+ light_atten = (blue_density * 1.0 + vec4(haze_density.r) * 0.25) * (density_multiplier.x * max_y.x);
+ //I had thought blue_density and haze_density should have equal weighting,
+ //but attenuation due to haze_density tends to seem too strong
+
+ temp1 = blue_density + vec4(haze_density.r);
+ blue_weight = blue_density / temp1;
+ haze_weight = vec4(haze_density.r) / temp1;
+
+ //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain)
+ temp2.y = max(0.0, tmpLightnorm.y);
+ temp2.y = 1. / temp2.y;
+ sunlight *= exp( - light_atten * temp2.y);
+
+ // main atmospheric scattering line integral
+ temp2.z = Plen * density_multiplier.x;
+
+ // Transparency (-> temp1)
+ // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier.x in a variable because the ati
+ // compiler gets confused.
+ temp1 = exp(-temp1 * temp2.z * distance_multiplier.x);
+
+ //final atmosphere attenuation factor
+ setAtmosAttenuation(temp1.rgb);
+
+ //compute haze glow
+ //(can use temp2.x as temp because we haven't used it yet)
+ temp2.x = dot(Pn, tmpLightnorm.xyz);
+ temp2.x = 1. - temp2.x;
+ //temp2.x is 0 at the sun and increases away from sun
+ temp2.x = max(temp2.x, .03); //was glow.y
+ //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
+ temp2.x *= glow.x;
+ //higher glow.x gives dimmer glow (because next step is 1 / "angle")
+ temp2.x = pow(temp2.x, glow.z);
+ //glow.z should be negative, so we're doing a sort of (1 / "angle") function
+
+ //add "minimum anti-solar illumination"
+ temp2.x += .25;
+
+ //increase ambient when there are more clouds
+ vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5;
+
+ /* decrease value and saturation (that in HSV, not HSL) for occluded areas
+ * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html
+ * // The following line of code performs the equivalent of:
+ * float ambAlpha = tmpAmbient.a;
+ * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis
+ * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue);
+ * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha);
+ */
+ tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
+
+ //haze color
+ setAdditiveColor(
+ vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow.x) + tmpAmbient)
+ + (haze_horizon.r * haze_weight) * (sunlight*(1.-cloud_shadow.x) * temp2.x
+ + tmpAmbient)));
+
+ //brightness of surface both sunlight and ambient
+ setSunlitColor(vec3(sunlight * .5));
+ setAmblitColor(vec3(tmpAmbient * .25));
+ setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1));
+}
+
+vec3 atmosLighting(vec3 light)
+{
+ light *= getAtmosAttenuation().r;
+ light += getAdditiveColor();
+ return (2.0 * light);
+}
+
+vec3 atmosTransport(vec3 light) {
+ light *= getAtmosAttenuation().r;
+ light += getAdditiveColor() * 2.0;
+ return light;
+}
+vec3 atmosGetDiffuseSunlightColor()
+{
+ return getSunlitColor();
+}
+
+vec3 scaleDownLight(vec3 light)
+{
+ return (light / scene_light_strength );
+}
+
+vec3 scaleUpLight(vec3 light)
+{
+ return (light * scene_light_strength);
+}
+
+vec3 atmosAmbient(vec3 light)
+{
+ return getAmblitColor() + light / 2.0;
+}
+
+vec3 atmosAffectDirectionalLight(float lightIntensity)
+{
+ return getSunlitColor() * lightIntensity;
+}
+
+vec3 scaleSoftClip(vec3 light)
+{
+ //soft clip effect:
+ light = 1. - clamp(light, vec3(0.), vec3(1.));
+ light = 1. - pow(light, gamma.xxx);
+
+ return light;
+}
+
+void main()
+{
+ vec2 tc = vary_fragcoord.xy;
+ vec3 pos = texture2DRect(positionMap, tc).xyz;
+ vec3 norm = texture2DRect(normalMap, tc).xyz;
+ vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
+
+ float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
+
+ vec4 diffuse = vec4(texture2DRect(diffuseRect, tc).rgb, 1.0);
+ vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
+
+ vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
+ float scol = scol_ambocc.r;
+ float ambocc = scol_ambocc.g;
+
+ calcAtmospherics(pos.xyz, ambocc);
+
+ vec3 col = atmosAmbient(vec3(0));
+ col += atmosAffectDirectionalLight(min(da, scol));
+
+ col *= diffuse.rgb;
+
+ if (spec.a > 0.2)
+ {
+ vec3 ref = reflect(pos.xyz, norm.xyz);
+ vec3 rc;
+ rc.x = dot(ref, env_mat[0]);
+ rc.y = dot(ref, env_mat[1]);
+ rc.z = dot(ref, env_mat[2]);
+
+ vec3 refcol = textureCube(environmentMap, rc).rgb;
+ col.rgb += refcol * spec.rgb;
+ }
+
+ col = atmosLighting(col);
+ col = scaleSoftClip(col);
+
+ gl_FragColor.rgb = col;
+ gl_FragColor.a = 0.0;
+ //gl_FragColor.rg = scol_ambocc.rg;
+ //gl_FragColor.rgb = norm.rgb*0.5+0.5;
+ //gl_FragColor.rgb = vec3(ambocc);
+ //gl_FragColor.rgb = vec3(scol);
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
new file mode 100644
index 0000000000..ad8af4780d
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
@@ -0,0 +1,24 @@
+/**
+ * @file softenLightF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform vec2 screen_res;
+
+varying vec4 vary_light;
+varying vec2 vary_fragcoord;
+void main()
+{
+ //transform vertex
+ gl_Position = ftransform();
+
+ vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
+ vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
+
+ vec4 tex = gl_MultiTexCoord0;
+ tex.w = 1.0;
+
+ vary_light = gl_MultiTexCoord0;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
new file mode 100644
index 0000000000..d43fe6ca95
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
@@ -0,0 +1,139 @@
+/**
+ * @file sunLightF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+#extension GL_ARB_texture_rectangle : enable
+
+uniform sampler2DRect positionMap;
+uniform sampler2DRect normalMap;
+uniform sampler2DRect depthMap;
+uniform sampler2DShadow shadowMap0;
+uniform sampler2DShadow shadowMap1;
+uniform sampler2DShadow shadowMap2;
+uniform sampler2DShadow shadowMap3;
+uniform sampler2D noiseMap;
+
+// Inputs
+uniform mat4 shadow_matrix[4];
+uniform vec4 shadow_clip;
+uniform float ssao_radius;
+uniform float ssao_max_radius;
+uniform float ssao_factor;
+uniform float ssao_factor_inv;
+
+varying vec2 vary_fragcoord;
+varying vec4 vary_light;
+
+//calculate decreases in ambient lighting when crowded out (SSAO)
+float calcAmbientOcclusion(vec4 pos, vec3 norm)
+{
+ vec2 kern[8];
+ // exponentially (^2) distant occlusion samples spread around origin
+ kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
+ kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
+ kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
+ kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
+ kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
+ kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
+ kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
+ kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
+
+ vec2 pos_screen = vary_fragcoord.xy;
+ vec3 pos_world = pos.xyz;
+ vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
+
+ float angle_hidden = 0.0;
+ int points = 0;
+
+ float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
+
+ // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
+ for (int i = 0; i < 8; i++)
+ {
+ vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
+ vec3 samppos_world = texture2DRect(positionMap, samppos_screen).xyz;
+
+ vec3 diff = pos_world - samppos_world;
+ float dist2 = dot(diff, diff);
+
+ // assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
+ // --> solid angle shrinking by the square of distance
+ //radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
+ //(k should vary inversely with # of samples, but this is taken care of later)
+
+ //if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) // -0.05*norm to shift sample point back slightly for flat surfaces
+ // angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional. max of 1.0 (= ssao_factor_inv * ssao_factor)
+ angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
+
+ // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion"
+ points = points + int(diff.z > -1.0);
+ }
+
+ angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
+
+ return 1.0 - (float(points != 0) * angle_hidden);
+}
+
+void main()
+{
+ vec2 pos_screen = vary_fragcoord.xy;
+ vec4 pos = vec4(texture2DRect(positionMap, pos_screen).xyz, 1.0);
+ vec3 norm = texture2DRect(normalMap, pos_screen).xyz;
+
+ /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
+ {
+ gl_FragColor = vec4(0.0); // doesn't matter
+ return;
+ }*/
+
+ float shadow = 1.0;
+ float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
+
+ if (dp_directional_light == 0.0)
+ {
+ // if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup
+ shadow = 0.0;
+ }
+ else if (pos.z > -shadow_clip.w)
+ {
+ if (pos.z < -shadow_clip.z)
+ {
+ vec4 lpos = shadow_matrix[3]*pos;
+ shadow = shadow2DProj(shadowMap3, lpos).x;
+ shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
+ }
+ else if (pos.z < -shadow_clip.y)
+ {
+ vec4 lpos = shadow_matrix[2]*pos;
+ shadow = shadow2DProj(shadowMap2, lpos).x;
+ }
+ else if (pos.z < -shadow_clip.x)
+ {
+ vec4 lpos = shadow_matrix[1]*pos;
+ shadow = shadow2DProj(shadowMap1, lpos).x;
+ }
+ else
+ {
+ vec4 lpos = shadow_matrix[0]*pos;
+ shadow = shadow2DProj(shadowMap0, lpos).x;
+ }
+
+ // take the most-shadowed value out of these two:
+ // * the blurred sun shadow in the light (shadow) map
+ // * an unblurred dot product between the sun and this norm
+ // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting
+ shadow = min(shadow, dp_directional_light);
+ }
+ else
+ {
+ // more distant than the shadow map covers - just use directional shading as shadow
+ shadow = dp_directional_light;
+ }
+
+ gl_FragColor[0] = shadow;
+ gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
+ //gl_FragColor[2] is unused as of August 2008, may be used for debugging
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
new file mode 100644
index 0000000000..5081485c4b
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
@@ -0,0 +1,25 @@
+/**
+ * @file sunLightF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+varying vec4 vary_light;
+varying vec2 vary_fragcoord;
+
+uniform vec2 screen_res;
+
+void main()
+{
+ //transform vertex
+ gl_Position = ftransform();
+ vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
+ vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
+ vec4 tex = gl_MultiTexCoord0;
+ tex.w = 1.0;
+
+ vary_light = gl_MultiTexCoord0;
+
+ gl_FrontColor = gl_Color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
new file mode 100644
index 0000000000..211b2e0397
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -0,0 +1,36 @@
+/**
+ * @file terrainF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D detail_0;
+uniform sampler2D detail_1;
+uniform sampler2D detail_2;
+uniform sampler2D detail_3;
+uniform sampler2D alpha_ramp;
+
+varying vec3 vary_normal;
+varying vec4 vary_position;
+
+void main()
+{
+ /// Note: This should duplicate the blending functionality currently used for the terrain rendering.
+
+ vec4 color0 = texture2D(detail_0, gl_TexCoord[0].xy);
+ vec4 color1 = texture2D(detail_1, gl_TexCoord[0].xy);
+ vec4 color2 = texture2D(detail_2, gl_TexCoord[0].xy);
+ vec4 color3 = texture2D(detail_3, gl_TexCoord[0].xy);
+
+ float alpha1 = texture2D(alpha_ramp, gl_TexCoord[0].zw).a;
+ float alpha2 = texture2D(alpha_ramp,gl_TexCoord[1].xy).a;
+ float alphaFinal = texture2D(alpha_ramp, gl_TexCoord[1].zw).a;
+ vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal );
+
+ gl_FragData[0] = vec4(outColor.rgb, 1.0);
+ gl_FragData[1] = vec4(outColor.rgb*0.2, 0.2);
+ gl_FragData[2] = vec4(normalize(vary_normal), 0.0);
+ gl_FragData[3] = vary_position;
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
new file mode 100644
index 0000000000..e9d6dcabff
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
@@ -0,0 +1,41 @@
+/**
+ * @file terrainV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+varying vec3 vary_normal;
+varying vec4 vary_position;
+
+vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
+{
+ 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;
+}
+
+void main()
+{
+ //transform vertex
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+ vary_position = gl_ModelViewMatrix * gl_Vertex;
+ vary_normal = normalize(gl_NormalMatrix * gl_Normal);
+
+ // Transform and pass tex coords
+ gl_TexCoord[0].xy = texgen_object(gl_Vertex, gl_MultiTexCoord0, gl_TextureMatrix[0], gl_ObjectPlaneS[0], gl_ObjectPlaneT[0]).xy;
+
+ vec4 t = gl_MultiTexCoord1;
+
+ gl_TexCoord[0].zw = t.xy;
+ gl_TexCoord[1].xy = t.xy-vec2(2.0, 0.0);
+ gl_TexCoord[1].zw = t.xy-vec2(1.0, 0.0);
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
new file mode 100644
index 0000000000..bc2c9816dc
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -0,0 +1,20 @@
+/**
+ * @file treeF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+uniform sampler2D diffuseMap;
+
+varying vec3 vary_normal;
+varying vec4 vary_position;
+
+void main()
+{
+ vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
+ gl_FragData[0] = gl_Color*col;
+ gl_FragData[1] = vec4(0,0,0,0);
+ gl_FragData[2] = vec4(normalize(vary_normal), 0.0);
+ gl_FragData[3] = vary_position;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
new file mode 100644
index 0000000000..9131d7c2b3
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
@@ -0,0 +1,22 @@
+/**
+ * @file treeV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+varying vec3 vary_normal;
+varying vec4 vary_position;
+
+void main()
+{
+ //transform vertex
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+
+ vary_position = gl_ModelViewMatrix * gl_Vertex;
+
+ vary_normal = normalize(gl_NormalMatrix * gl_Normal);
+
+ gl_FrontColor = gl_Color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
new file mode 100644
index 0000000000..0a1f019e3d
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -0,0 +1,157 @@
+/**
+ * @file waterF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+vec3 scaleSoftClip(vec3 inColor);
+vec3 atmosTransport(vec3 inColor);
+
+uniform sampler2D bumpMap;
+uniform sampler2D screenTex;
+uniform sampler2D refTex;
+uniform sampler2DShadow shadowMap0;
+uniform sampler2DShadow shadowMap1;
+uniform sampler2DShadow shadowMap2;
+uniform sampler2DShadow shadowMap3;
+uniform sampler2D noiseMap;
+
+uniform mat4 shadow_matrix[4];
+uniform vec4 shadow_clip;
+
+uniform float sunAngle;
+uniform float sunAngle2;
+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;
+
+
+//bigWave is (refCoord.w, view.w);
+varying vec4 refCoord;
+varying vec4 littleWave;
+varying vec4 view;
+varying vec4 vary_position;
+
+void main()
+{
+ vec4 color;
+ float dist = length(view.xy);
+
+ //normalize view vector
+ vec3 viewVec = normalize(view.xyz);
+
+ //get wave 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;
+ //get base fresnel components
+
+ 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 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, 128.0);
+
+ //figure out distortion vector (ripply)
+ vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0);
+
+ vec4 fb = texture2D(screenTex, distort2);
+
+ //mix with reflection
+ // 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);
+
+ float shadow = 1.0;
+ vec4 pos = vary_position;
+
+ vec3 nz = texture2D(noiseMap, gl_FragCoord.xy/128.0).xyz;
+
+ if (pos.z > -shadow_clip.w)
+ {
+ vec4 spos = pos;
+
+ if (pos.z < -shadow_clip.z)
+ {
+ vec4 lpos = (shadow_matrix[3]*spos);
+ shadow = shadow2DProj(shadowMap3, lpos).x;
+ }
+ else if (pos.z < -shadow_clip.y)
+ {
+ vec4 lpos = (shadow_matrix[2]*spos);
+ shadow = shadow2DProj(shadowMap2, lpos).x;
+ }
+ else if (pos.z < -shadow_clip.x)
+ {
+ vec4 lpos = (shadow_matrix[1]*spos);
+ shadow = shadow2DProj(shadowMap1, lpos).x;
+ }
+ else
+ {
+ vec4 lpos = (shadow_matrix[0]*spos);
+ shadow = shadow2DProj(shadowMap0, lpos).x;
+ }
+ }
+
+ spec *= shadow;
+ color.rgb += spec * specular;
+
+ 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/deferred/waterV.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
new file mode 100644
index 0000000000..b45e5c5302
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
@@ -0,0 +1,76 @@
+/**
+ * @file waterV.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+void calcAtmospherics(vec3 inPositionEye);
+
+uniform vec2 d1;
+uniform vec2 d2;
+uniform float time;
+uniform vec3 eyeVec;
+uniform float waterHeight;
+
+varying vec4 refCoord;
+varying vec4 littleWave;
+varying vec4 view;
+
+varying vec4 vary_position;
+
+float wave(vec2 v, float t, float f, vec2 d, float s)
+{
+ return (dot(d, v)*f + t*s)*f;
+}
+
+void main()
+{
+ //transform vertex
+ vec4 position = gl_Vertex;
+ mat4 modelViewProj = gl_ModelViewProjectionMatrix;
+
+ vec4 oPosition;
+
+ //get view vector
+ vec3 oEyeVec;
+ oEyeVec.xyz = position.xyz-eyeVec;
+
+ float d = length(oEyeVec.xy);
+ float ld = min(d, 2560.0);
+
+ position.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.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
+ vary_position = gl_ModelViewMatrix * oPosition;
+ 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.45, 0.9) + d2 * time * 0.13;
+ littleWave.zw = (v.xy) * vec2(0.1, 0.2) + d1 * time * 0.1;
+ view.w = bigWave.y;
+ refCoord.w = bigWave.x;
+
+ gl_Position = oPosition;
+}
diff --git a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
index dbdfe1174c..5d7af2c13a 100644
--- a/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
+++ b/indra/newview/app_settings/shaders/class1/effects/glowExtractF.glsl
@@ -20,8 +20,8 @@ void main()
/// CALCULATING LUMINANCE (Using NTSC lum weights)
/// http://en.wikipedia.org/wiki/Luma_%28video%29
- float lum = smoothstep(minLuminance, 1.0, dot(col.rgb, lumWeights ) );
- float warmth = smoothstep(minLuminance, 1.0, max(col.r * warmthWeights.r, max(col.g * warmthWeights.g, col.b * warmthWeights.b)) );
+ float lum = smoothstep(minLuminance, minLuminance+1.0, dot(col.rgb, lumWeights ) );
+ float warmth = smoothstep(minLuminance, minLuminance+1.0, max(col.r * warmthWeights.r, max(col.g * warmthWeights.g, col.b * warmthWeights.b)) );
gl_FragColor.rgb = col.rgb;
gl_FragColor.a = max(col.a, mix(lum, warmth, warmthAmount) * maxExtractAlpha);
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
index bd9b30a075..7e1788678d 100644
--- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
@@ -7,6 +7,7 @@
vec3 scaleSoftClip(vec3 inColor);
vec3 atmosTransport(vec3 inColor);
+vec3 applyWaterFog(vec4 inColor);
uniform sampler2D diffuseMap;
uniform sampler2D bumpMap;