summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl67
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl11
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarEyesV.glsl21
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl5
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/blurLightMSF.glsl113
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl79
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl165
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl40
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl23
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/giF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/giV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightMSF.glsl137
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiSpotLightMSF.glsl232
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightMSF.glsl108
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl9
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredMSF.glsl133
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFMSF.glsl37
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/skyF.glsl44
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/skyV.glsl140
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightMSF.glsl318
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/spotLightMSF.glsl234
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/starsF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/starsV.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightMSF.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl4
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOMSF.glsl123
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/treeF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/treeV.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/waterF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/waterV.glsl2
69 files changed, 2111 insertions, 121 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index 3b12a07a27..4a0815a163 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -5,13 +5,14 @@
* $/LicenseInfo$
*/
-#version 120
+
#extension GL_ARB_texture_rectangle : enable
-uniform sampler2D diffuseMap;
uniform sampler2DRect depthMap;
+vec4 diffuseLookup(vec2 texcoord);
+
uniform mat4 shadow_matrix[6];
uniform vec4 shadow_clip;
uniform vec2 screen_res;
@@ -47,7 +48,7 @@ void main()
vec4 pos = vec4(vary_position, 1.0);
- vec4 diff= texture2D(diffuseMap, gl_TexCoord[0].xy);
+ vec4 diff= diffuseLookup(gl_TexCoord[0].xy);
vec4 col = vec4(vary_ambient + vary_directional.rgb, gl_Color.a);
vec4 color = diff * col;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
new file mode 100644
index 0000000000..b0d029dbf4
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaNonIndexedF.glsl
@@ -0,0 +1,67 @@
+/**
+ * @file alphaF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+#extension GL_ARB_texture_rectangle : enable
+
+uniform sampler2DRect depthMap;
+uniform sampler2D diffuseMap;
+
+
+uniform mat4 shadow_matrix[6];
+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;
+varying vec3 vary_pointlight_col;
+
+uniform mat4 inv_proj;
+
+vec4 getPosition(vec2 pos_screen)
+{
+ float depth = texture2DRect(depthMap, pos_screen.xy).a;
+ vec2 sc = pos_screen.xy*2.0;
+ sc /= screen_res;
+ sc -= vec2(1.0,1.0);
+ vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+ vec4 pos = inv_proj * ndc;
+ pos /= pos.w;
+ pos.w = 1.0;
+ return pos;
+}
+
+void main()
+{
+ vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
+ frag *= screen_res;
+
+ vec4 pos = vec4(vary_position, 1.0);
+
+ vec4 diff= texture2D(diffuseMap,gl_TexCoord[0].xy);
+
+ vec4 col = vec4(vary_ambient + vary_directional.rgb, gl_Color.a);
+ vec4 color = diff * col;
+
+ color.rgb = atmosLighting(color.rgb);
+
+ color.rgb = scaleSoftClip(color.rgb);
+
+ color.rgb += diff.rgb * vary_pointlight_col.rgb;
+
+ gl_FragColor = color;
+ //gl_FragColor = vec4(1,0,1,1);
+ //gl_FragColor = vec4(1,0,1,1)*shadow;
+
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
index 65d9209983..ac3f7189c2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
@@ -5,7 +5,7 @@
* $License$
*/
-#version 120
+
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
mat4 getObjectSkinnedTransform();
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 2691fc8ded..44cb78e914 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
void calcAtmospherics(vec3 inPositionEye);
@@ -23,6 +23,7 @@ varying vec3 vary_fragcoord;
varying vec3 vary_position;
varying vec3 vary_light;
varying vec3 vary_pointlight_col;
+varying float vary_texture_index;
uniform float near_clip;
uniform float shadow_offset;
@@ -61,11 +62,13 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
void main()
{
//transform vertex
- gl_Position = ftransform();
+ vec4 vert = vec4(gl_Vertex.xyz, 1.0);
+ vary_texture_index = gl_Vertex.w;
+ gl_Position = gl_ModelViewProjectionMatrix * vert;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
- vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
+ vec4 pos = (gl_ModelViewMatrix * vert);
vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
float dp_directional_light = max(0.0, dot(norm, gl_LightSource[0].position.xyz));
@@ -102,7 +105,7 @@ void main()
gl_FogFragCoord = pos.z;
- pos = gl_ModelViewProjectionMatrix * gl_Vertex;
+ pos = gl_ModelViewProjectionMatrix * vert;
vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
index 164322c3a7..870d593311 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowF.glsl
@@ -5,7 +5,7 @@
* $License$
*/
-#version 120
+
uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
index 5ae41cb730..c7a4f86727 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/attachmentShadowV.glsl
@@ -5,7 +5,7 @@
* $License$
*/
-#version 120
+
mat4 getObjectSkinnedTransform();
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index a012cb5030..68e4055cf2 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
mat4 getSkinnedTransform();
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarEyesV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarEyesV.glsl
new file mode 100644
index 0000000000..7bc78fe407
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarEyesV.glsl
@@ -0,0 +1,21 @@
+/**
+ * @file avatarEyesV.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+varying vec3 vary_normal;
+
+void main()
+{
+ //transform vertex
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+
+ vary_normal = normalize(gl_NormalMatrix * gl_Normal);
+
+ gl_FrontColor = gl_Color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
index 9748727147..3268618093 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
index 1b7ae06888..78986ab12e 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
@@ -5,14 +5,17 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform sampler2D diffuseMap;
+varying vec4 post_pos;
void main()
{
//gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a);
gl_FragColor = vec4(1,1,1,1);
+
+ gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
index cf6579a40d..f177fcd8f1 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
@@ -5,12 +5,14 @@
* $/LicenseInfo$
*/
-#version 120
+
mat4 getSkinnedTransform();
attribute vec4 weight;
+varying vec4 post_pos;
+
void main()
{
gl_TexCoord[0] = gl_MultiTexCoord0;
@@ -30,8 +32,9 @@ void main()
norm = normalize(norm);
pos = gl_ProjectionMatrix * pos;
- pos.z = max(pos.z, -pos.w+0.01);
- gl_Position = pos;
+ post_pos = pos;
+
+ gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);
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
index 69c93799b5..7eac11287a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
mat4 getSkinnedTransform();
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index d9f021b114..8c75c8045a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
#extension GL_ARB_texture_rectangle : enable
@@ -26,7 +26,7 @@ uniform vec2 screen_res;
vec4 getPosition(vec2 pos_screen)
{
- float depth = texture2DRect(depthMap, pos_screen.xy).a;
+ float depth = texture2DRect(depthMap, pos_screen.xy).r;
vec2 sc = pos_screen.xy*2.0;
sc /= screen_res;
sc -= vec2(1.0,1.0);
@@ -39,7 +39,7 @@ vec4 getPosition(vec2 pos_screen)
void main()
{
- vec2 tc = vary_fragcoord.xy;
+ vec2 tc = vary_fragcoord.xy;
vec3 norm = texture2DRect(normalMap, tc).xyz;
norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
vec3 pos = getPosition(tc).xyz;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightMSF.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightMSF.glsl
new file mode 100644
index 0000000000..6ca51377c1
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightMSF.glsl
@@ -0,0 +1,113 @@
+/**
+ * @file blurLightF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+#extension GL_ARB_texture_rectangle : enable
+#extension GL_ARB_texture_multisample : enable
+
+uniform sampler2DMS depthMap;
+uniform sampler2DMS normalMap;
+uniform sampler2DRect lightMap;
+
+uniform float dist_factor;
+uniform float blur_size;
+uniform vec2 delta;
+uniform vec3 kern[4];
+uniform float kern_scale;
+
+varying vec2 vary_fragcoord;
+
+uniform mat4 inv_proj;
+uniform vec2 screen_res;
+
+vec3 texture2DMS3(sampler2DMS tex, ivec2 tc)
+{
+ vec3 ret = vec3(0,0,0);
+ for (int i = 0; i < samples; i++)
+ {
+ ret += texelFetch(tex, tc, i).rgb;
+ }
+
+ return ret/samples;
+}
+
+float texture2DMS1(sampler2DMS tex, ivec2 tc)
+{
+ float ret = 0;
+ for (int i = 0; i < samples; i++)
+ {
+ ret += texelFetch(tex, tc, i).r;
+ }
+
+ return ret/samples;
+}
+
+vec4 getPosition(ivec2 pos_screen)
+{
+ float depth = texture2DMS1(depthMap, pos_screen.xy);
+ vec2 sc = pos_screen.xy*2.0;
+ sc /= screen_res;
+ sc -= vec2(1.0,1.0);
+ vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+ vec4 pos = inv_proj * ndc;
+ pos /= pos.w;
+ pos.w = 1.0;
+ return pos;
+}
+
+void main()
+{
+ vec2 tc = vary_fragcoord.xy;
+ ivec2 itc = ivec2(tc);
+
+ vec3 norm = texture2DMS3(normalMap, itc).xyz;
+ norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
+ vec3 pos = getPosition(itc).xyz;
+ vec4 ccol = texture2DRect(lightMap, tc).rgba;
+
+ vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy);
+ dlt /= max(-pos.z*dist_factor, 1.0);
+
+ 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'
+ vec4 col = defined_weight.xyxx * ccol;
+
+ // relax tolerance according to distance to avoid speckling artifacts, as angles and distances are a lot more abrupt within a small screen area at larger distances
+ float pointplanedist_tolerance_pow2 = pos.z*pos.z*0.00005;
+
+ // perturb sampling origin slightly in screen-space to hide edge-ghosting artifacts where smoothing radius is quite large
+ tc += ( (mod(tc.x+tc.y,2) - 0.5) * kern[1].z * dlt * 0.5 );
+
+ for (int i = 1; i < 4; i++)
+ {
+ vec2 samptc = tc + kern[i].z*dlt;
+ vec3 samppos = getPosition(ivec2(samptc)).xyz;
+ float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
+ if (d*d <= pointplanedist_tolerance_pow2)
+ {
+ col += texture2DRect(lightMap, samptc)*kern[i].xyxx;
+ defined_weight += kern[i].xy;
+ }
+ }
+ for (int i = 1; i < 4; i++)
+ {
+ vec2 samptc = vec2(tc - kern[i].z*dlt);
+ vec3 samppos = getPosition(ivec2(samptc)).xyz;
+ float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
+ if (d*d <= pointplanedist_tolerance_pow2)
+ {
+ col += texture2DRect(lightMap, samptc)*kern[i].xyxx;
+ defined_weight += kern[i].xy;
+ }
+ }
+
+ col /= defined_weight.xyxx;
+ col.y *= col.y;
+
+ gl_FragColor = col;
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
index c2d05c601a..862f809de5 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/blurLightV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec2 vary_fragcoord;
uniform vec2 screen_res;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index 37bfaac32c..75b4dc624a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform sampler2D diffuseMap;
uniform sampler2D bumpMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
index d884f2e4a5..dc69519a85 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpSkinnedV.glsl
@@ -5,7 +5,7 @@
* $License$
*/
-#version 120
+
varying vec3 vary_mat0;
varying vec3 vary_mat1;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl b/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
index 9b109b2db6..5b6726488b 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec3 vary_mat0;
varying vec3 vary_mat1;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
new file mode 100644
index 0000000000..ef300d5631
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl
@@ -0,0 +1,79 @@
+/**
+ * @file WLCloudsF.glsl
+ *
+ * $LicenseInfo:firstyear=2005&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+/////////////////////////////////////////////////////////////////////////
+// The fragment shader for the sky
+/////////////////////////////////////////////////////////////////////////
+
+varying vec4 vary_CloudColorSun;
+varying vec4 vary_CloudColorAmbient;
+varying float vary_CloudDensity;
+
+uniform sampler2D cloud_noise_texture;
+uniform vec4 cloud_pos_density1;
+uniform vec4 cloud_pos_density2;
+uniform vec4 gamma;
+
+/// Soft clips the light with a gamma correction
+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()
+{
+ // Set variables
+ vec2 uv1 = gl_TexCoord[0].xy;
+ vec2 uv2 = gl_TexCoord[1].xy;
+
+ vec4 cloudColorSun = vary_CloudColorSun;
+ vec4 cloudColorAmbient = vary_CloudColorAmbient;
+ float cloudDensity = vary_CloudDensity;
+ vec2 uv3 = gl_TexCoord[2].xy;
+ vec2 uv4 = gl_TexCoord[3].xy;
+
+ // Offset texture coords
+ uv1 += cloud_pos_density1.xy; //large texture, visible density
+ uv2 += cloud_pos_density1.xy; //large texture, self shadow
+ uv3 += cloud_pos_density2.xy; //small texture, visible density
+ uv4 += cloud_pos_density2.xy; //small texture, self shadow
+
+
+ // Compute alpha1, the main cloud opacity
+ float alpha1 = (texture2D(cloud_noise_texture, uv1).x - 0.5) + (texture2D(cloud_noise_texture, uv3).x - 0.5) * cloud_pos_density2.z;
+ alpha1 = min(max(alpha1 + cloudDensity, 0.) * 10. * cloud_pos_density1.z, 1.);
+
+ // And smooth
+ alpha1 = 1. - alpha1 * alpha1;
+ alpha1 = 1. - alpha1 * alpha1;
+
+
+ // Compute alpha2, for self shadowing effect
+ // (1 - alpha2) will later be used as percentage of incoming sunlight
+ float alpha2 = (texture2D(cloud_noise_texture, uv2).x - 0.5);
+ alpha2 = min(max(alpha2 + cloudDensity, 0.) * 2.5 * cloud_pos_density1.z, 1.);
+
+ // And smooth
+ alpha2 = 1. - alpha2;
+ alpha2 = 1. - alpha2 * alpha2;
+
+ // Combine
+ vec4 color;
+ color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient);
+ color *= 2.;
+
+ /// Gamma correct for WL (soft clip effect).
+ gl_FragData[0] = vec4(scaleSoftClip(color.rgb), alpha1);
+ gl_FragData[1] = vec4(0.0,0.0,0.0,0.0);
+ gl_FragData[2] = vec4(0,0,1,0);
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
new file mode 100644
index 0000000000..3eac63076c
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl
@@ -0,0 +1,165 @@
+/**
+ * @file WLCloudsV.glsl
+ *
+ * $LicenseInfo:firstyear=2005&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+//////////////////////////////////////////////////////////////////////////
+// The vertex shader for creating the atmospheric sky
+///////////////////////////////////////////////////////////////////////////////
+
+// Output parameters
+varying vec4 vary_CloudColorSun;
+varying vec4 vary_CloudColorAmbient;
+varying float vary_CloudDensity;
+
+// Inputs
+uniform vec3 camPosLocal;
+
+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 max_y;
+
+uniform vec4 glow;
+
+uniform vec4 cloud_color;
+
+uniform vec4 cloud_scale;
+
+void main()
+{
+
+ // World / view / projection
+ gl_Position = ftransform();
+
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ // Get relative position
+ vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0);
+
+ // Set altitude
+ if (P.y > 0.)
+ {
+ P *= (max_y.x / P.y);
+ }
+ else
+ {
+ P *= (-32000. / P.y);
+ }
+
+ // Can normalize then
+ vec3 Pn = normalize(P);
+ float Plen = length(P);
+
+ // Initialize temp variables
+ vec4 temp1 = vec4(0.);
+ vec4 temp2 = vec4(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 + haze_density.x * 0.25) * (density_multiplier.x * max_y.x);
+
+ // Calculate relative weights
+ temp1 = blue_density + haze_density.x;
+ blue_weight = blue_density / temp1;
+ haze_weight = haze_density.x / temp1;
+
+ // Compute sunlight from P & lightnorm (for long rays like sky)
+ temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y );
+ temp2.y = 1. / temp2.y;
+ sunlight *= exp( - light_atten * temp2.y);
+
+ // Distance
+ temp2.z = Plen * density_multiplier.x;
+
+ // Transparency (-> temp1)
+ // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
+ // compiler gets confused.
+ temp1 = exp(-temp1 * temp2.z);
+
+
+ // Compute haze glow
+ temp2.x = dot(Pn, lightnorm.xyz);
+ temp2.x = 1. - temp2.x;
+ // temp2.x is 0 at the sun and increases away from sun
+ temp2.x = max(temp2.x, .001);
+ // 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;
+ tmpAmbient += (1. - tmpAmbient) * cloud_shadow.x * 0.5;
+
+ // Dim sunlight by cloud shadow percentage
+ sunlight *= (1. - cloud_shadow.x);
+
+ // Haze color below cloud
+ vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient)
+ + (haze_horizon.r * haze_weight) * (sunlight * temp2.x + tmpAmbient)
+ );
+
+ // CLOUDS
+
+ sunlight = sunlight_color;
+ temp2.y = max(0., lightnorm.y * 2.);
+ temp2.y = 1. / temp2.y;
+ sunlight *= exp( - light_atten * temp2.y);
+
+ // Cloud color out
+ vary_CloudColorSun = (sunlight * temp2.x) * cloud_color;
+ vary_CloudColorAmbient = tmpAmbient * cloud_color;
+
+ // Attenuate cloud color by atmosphere
+ temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds
+ vary_CloudColorSun *= temp1;
+ vary_CloudColorAmbient *= temp1;
+ vec4 oHazeColorBelowCloud = additiveColorBelowCloud * (1. - temp1);
+
+ // Make a nice cloud density based on the cloud_shadow value that was passed in.
+ vary_CloudDensity = 2. * (cloud_shadow.x - 0.25);
+
+
+ // Texture coords
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_TexCoord[0].xy -= 0.5;
+ gl_TexCoord[0].xy /= cloud_scale.x;
+ gl_TexCoord[0].xy += 0.5;
+
+ gl_TexCoord[1] = gl_TexCoord[0];
+ gl_TexCoord[1].x += lightnorm.x * 0.0125;
+ gl_TexCoord[1].y += lightnorm.z * 0.0125;
+
+ gl_TexCoord[2] = gl_TexCoord[0] * 16.;
+ gl_TexCoord[3] = gl_TexCoord[1] * 16.;
+
+ // Combine these to minimize register use
+ vary_CloudColorAmbient += oHazeColorBelowCloud;
+
+ // needs this to compile on mac
+ //vary_AtmosAttenuation = vec3(0.0,0.0,0.0);
+
+ // END CLOUDS
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index 35cfb80c93..43af480c50 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform sampler2D diffuseMap;
@@ -20,3 +20,4 @@ void main()
vec3 nvn = normalize(vary_normal);
gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
new file mode 100644
index 0000000000..e7b5dcce7f
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl
@@ -0,0 +1,19 @@
+/**
+ * @file diffuseIndexedF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+varying vec3 vary_normal;
+
+void main()
+{
+ vec3 col = gl_Color.rgb * diffuseLookup(gl_TexCoord[0].xy).rgb;
+
+ gl_FragData[0] = vec4(col, 0.0);
+ gl_FragData[1] = gl_Color.aaaa; // spec
+ //gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a); // spec - from former class3 - maybe better, but not so well tested
+ vec3 nvn = normalize(vary_normal);
+ gl_FragData[2] = vec4(nvn.xy * 0.5 + 0.5, nvn.z, 0.0);
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl
index 9a45c03237..2c4caea109 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseSkinnedV.glsl
@@ -5,7 +5,7 @@
* $License$
*/
-#version 120
+
varying vec3 vary_normal;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
index 03d3322cb6..b56d1493c3 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
@@ -5,16 +5,18 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec3 vary_normal;
+varying float vary_texture_index;
void main()
{
//transform vertex
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ gl_Position = gl_ModelViewProjectionMatrix * vec4(gl_Vertex.xyz, 1.0);
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+ vary_texture_index = gl_Vertex.w;
vary_normal = normalize(gl_NormalMatrix * gl_Normal);
gl_FrontColor = gl_Color;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index 3429877397..d781e08548 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -5,60 +5,24 @@
* $/LicenseInfo$
*/
-#version 120
-#extension GL_ARB_texture_rectangle : enable
-
-uniform sampler2D diffuseMap;
-uniform sampler2DRect depthMap;
-uniform sampler2D noiseMap;
-uniform vec4 shadow_clip;
-uniform vec2 screen_res;
+#extension GL_ARB_texture_rectangle : enable
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 mat4 inv_proj;
-
-vec4 getPosition(vec2 pos_screen)
-{
- float depth = texture2DRect(depthMap, pos_screen.xy).a;
- vec2 sc = pos_screen.xy*2.0;
- sc /= screen_res;
- sc -= vec2(1.0,1.0);
- vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
- vec4 pos = inv_proj * ndc;
- pos /= pos.w;
- pos.w = 1.0;
- return pos;
-}
void main()
{
- vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
- frag *= screen_res;
-
- vec3 samp_pos = getPosition(frag).xyz;
-
float shadow = 1.0;
- vec4 pos = vary_position;
- vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy)*gl_Color;
+ vec4 color = diffuseLookup(gl_TexCoord[0].xy)*gl_Color;
color.rgb = fullbrightAtmosTransport(color.rgb);
color.rgb = fullbrightScaleSoftClip(color.rgb);
- //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
index 6c38d220e2..2eed044b7c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
void calcAtmospherics(vec3 inPositionEye);
@@ -14,30 +14,23 @@ vec3 atmosAffectDirectionalLight(float lightIntensity);
vec3 scaleDownLight(vec3 light);
vec3 scaleUpLight(vec3 light);
-varying vec3 vary_ambient;
-varying vec3 vary_directional;
-varying vec3 vary_normal;
-varying vec3 vary_fragcoord;
-uniform float near_clip;
-varying vec4 vary_position;
+varying float vary_texture_index;
void main()
{
//transform vertex
- gl_Position = ftransform();
+ vec4 vert = vec4(gl_Vertex.xyz, 1.0);
+ vary_texture_index = gl_Vertex.w;
+
+ gl_Position = gl_ModelViewProjectionMatrix*vert;
gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
- vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
- vary_position = pos;
-
+ vec4 pos = (gl_ModelViewMatrix * vert);
+
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/giF.glsl b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
index 75b555e8ae..41c149e774 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
#extension GL_ARB_texture_rectangle : enable
diff --git a/indra/newview/app_settings/shaders/class1/deferred/giV.glsl b/indra/newview/app_settings/shaders/class1/deferred/giV.glsl
index 8dc1410ea5..e86f2896da 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/giV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/giV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec2 vary_fragcoord;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
index e3c15a2ab2..fa811f0d55 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform sampler2D diffuseMap;
uniform sampler2D normalMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl b/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl
index 37148b3f1a..723777bd3a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/impostorV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
void main()
{
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
index 78df54d5dc..25e93ae266 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform sampler2DRect diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl b/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
index 0c820bfc6c..4baf1fc65a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec2 vary_fragcoord;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index 609fc4f14f..3c5c780d94 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
#extension GL_ARB_texture_rectangle : enable
@@ -36,7 +36,7 @@ uniform mat4 inv_proj;
vec4 getPosition(vec2 pos_screen)
{
- float depth = texture2DRect(depthMap, pos_screen.xy).a;
+ float depth = texture2DRect(depthMap, pos_screen.xy).r;
vec2 sc = pos_screen.xy*2.0;
sc /= screen_res;
sc -= vec2(1.0,1.0);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightMSF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightMSF.glsl
new file mode 100644
index 0000000000..6c43679acf
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightMSF.glsl
@@ -0,0 +1,137 @@
+/**
+ * @file multiPointLightF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+#extension GL_ARB_texture_rectangle : enable
+#extension GL_ARB_texture_multisample : enable
+
+uniform sampler2DMS depthMap;
+uniform sampler2DMS diffuseRect;
+uniform sampler2DMS specularRect;
+uniform sampler2DMS normalMap;
+uniform sampler2D noiseMap;
+uniform sampler2D lightFunc;
+
+
+uniform vec3 env_mat[3];
+uniform float sun_wash;
+
+uniform int light_count;
+
+#define MAX_LIGHT_COUNT 16
+uniform vec4 light[MAX_LIGHT_COUNT];
+uniform vec4 light_col[MAX_LIGHT_COUNT];
+
+varying vec4 vary_fragcoord;
+uniform vec2 screen_res;
+
+uniform float far_z;
+
+uniform mat4 inv_proj;
+
+vec4 getPosition(ivec2 pos_screen, int sample)
+{
+ float depth = texelFetch(depthMap, pos_screen, sample).r;
+ vec2 sc = vec2(pos_screen.xy)*2.0;
+ sc /= screen_res;
+ sc -= vec2(1.0,1.0);
+ vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+ vec4 pos = inv_proj * ndc;
+ pos /= pos.w;
+ pos.w = 1.0;
+ return pos;
+}
+
+void main()
+{
+ vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res;
+ ivec2 itc = ivec2(frag);
+
+ int wght = 0;
+ vec3 fcol = vec3(0,0,0);
+
+ for (int s = 0; s < samples; ++s)
+ {
+ vec3 pos = getPosition(itc, s).xyz;
+ if (pos.z >= far_z)
+ {
+ vec3 norm = texelFetch(normalMap, itc, s).xyz;
+ norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
+ norm = normalize(norm);
+ vec4 spec = texelFetch(specularRect, itc, s);
+ vec3 diff = texelFetch(diffuseRect, itc, s).rgb;
+ float noise = texture2D(noiseMap, frag.xy/128.0).b;
+ vec3 out_col = vec3(0,0,0);
+ vec3 npos = normalize(-pos);
+
+ // As of OSX 10.6.7 ATI Apple's crash when using a variable size loop
+ for (int i = 0; i < MAX_LIGHT_COUNT; ++i)
+ {
+ bool light_contrib = (i < light_count);
+
+ vec3 lv = light[i].xyz-pos;
+ float dist2 = dot(lv,lv);
+ dist2 /= light[i].w;
+ if (dist2 > 1.0)
+ {
+ light_contrib = false;
+ }
+
+ float da = dot(norm, lv);
+ if (da < 0.0)
+ {
+ light_contrib = false;
+ }
+
+ if (light_contrib)
+ {
+ lv = normalize(lv);
+ da = dot(norm, lv);
+
+ float fa = light_col[i].a+1.0;
+ float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ dist_atten *= noise;
+
+ float lit = da * dist_atten;
+
+ vec3 col = light_col[i].rgb*lit*diff;
+ //vec3 col = vec3(dist2, light_col[i].a, lit);
+
+ if (spec.a > 0.0)
+ {
+ //vec3 ref = dot(pos+lv, norm);
+
+ float sa = dot(normalize(lv+npos),norm);
+
+ if (sa > 0.0)
+ {
+ sa = texture2D(lightFunc,vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
+ sa *= noise;
+ col += da*sa*light_col[i].rgb*spec.rgb;
+ }
+ }
+
+ out_col += col;
+ }
+ }
+
+ fcol += out_col;
+ ++wght;
+ }
+ }
+
+ if (wght <= 0)
+ {
+ discard;
+ }
+
+ gl_FragColor.rgb = fcol/samples;
+ gl_FragColor.a = 0.0;
+
+
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl
index 2e3e84dd15..434fb6f534 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec4 vary_fragcoord;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index a9f03f7615..0d25d7792d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
//class 1 -- no shadows
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightMSF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightMSF.glsl
new file mode 100644
index 0000000000..c80a54346e
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightMSF.glsl
@@ -0,0 +1,232 @@
+/**
+ * @file multiSpotLightF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+//class 1 -- no shadows
+
+#extension GL_ARB_texture_rectangle : enable
+#extension GL_ARB_texture_multisample : enable
+
+uniform sampler2DMS diffuseRect;
+uniform sampler2DMS specularRect;
+uniform sampler2DMS depthMap;
+uniform sampler2DMS normalMap;
+uniform sampler2D noiseMap;
+uniform sampler2D lightFunc;
+uniform sampler2D projectionMap;
+
+uniform mat4 proj_mat; //screen space to light space
+uniform float proj_near; //near clip for projection
+uniform vec3 proj_p; //plane projection is emitting from (in screen space)
+uniform vec3 proj_n;
+uniform float proj_focus; //distance from plane to begin blurring
+uniform float proj_lod; //(number of mips in proj map)
+uniform float proj_range; //range between near clip and far clip plane of projection
+uniform float proj_ambient_lod;
+uniform float proj_ambiance;
+uniform float near_clip;
+uniform float far_clip;
+
+uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
+uniform float sun_wash;
+uniform float shadow_fade;
+
+varying vec4 vary_light;
+
+varying vec4 vary_fragcoord;
+uniform vec2 screen_res;
+
+uniform mat4 inv_proj;
+
+vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
+{
+ vec4 ret = texture2DLod(projectionMap, tc, lod);
+
+ vec2 dist = tc-vec2(0.5);
+
+ float det = max(1.0-lod/(proj_lod*0.5), 0.0);
+
+ float d = dot(dist,dist);
+
+ ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0)+det, 1.0);
+
+ return ret;
+}
+
+vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
+{
+ vec4 ret = texture2DLod(projectionMap, tc, lod);
+
+ vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
+
+ float det = min(lod/(proj_lod*0.5), 1.0);
+
+ float d = min(dist.x, dist.y);
+
+ float edge = 0.25*det;
+
+ ret *= clamp(d/edge, 0.0, 1.0);
+
+ return ret;
+}
+
+vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
+{
+ vec4 ret = texture2DLod(projectionMap, tc, lod);
+
+ vec2 dist = tc-vec2(0.5);
+
+ float d = dot(dist,dist);
+
+ ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0), 1.0);
+
+ return ret;
+}
+
+
+vec4 getPosition(ivec2 pos_screen, int sample)
+{
+ float depth = texelFetch(depthMap, pos_screen, sample).r;
+ vec2 sc = vec2(pos_screen.xy)*2.0;
+ sc /= screen_res;
+ sc -= vec2(1.0,1.0);
+ vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+ vec4 pos = inv_proj * ndc;
+ pos /= pos.w;
+ pos.w = 1.0;
+ return pos;
+}
+
+void main()
+{
+ int wght = 0;
+
+ vec3 fcol = vec3(0,0,0);
+
+ vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res;
+
+ ivec2 itc = ivec2(frag.xy);
+
+ for (int i = 0; i < samples; ++i)
+ {
+ vec3 pos = getPosition(itc, i).xyz;
+ vec3 lv = vary_light.xyz-pos.xyz;
+ float dist2 = dot(lv,lv);
+ dist2 /= vary_light.w;
+ if (dist2 <= 1.0)
+ {
+ vec3 norm = texelFetch(normalMap, itc, i).xyz*2.0-1.0;
+
+ norm = normalize(norm);
+ float l_dist = -dot(lv, proj_n);
+
+ vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
+ if (proj_tc.z >= 0.0)
+ {
+ proj_tc.xyz /= proj_tc.w;
+
+ float fa = gl_Color.a+1.0;
+ float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0);
+ if (dist_atten > 0.0)
+ {
+ lv = proj_origin-pos.xyz;
+ lv = normalize(lv);
+ float da = dot(norm, lv);
+
+ vec3 col = vec3(0,0,0);
+
+ vec3 diff_tex = texelFetch(diffuseRect, itc, i).rgb;
+
+ float noise = texture2D(noiseMap, frag.xy/128.0).b;
+ if (proj_tc.z > 0.0 &&
+ proj_tc.x < 1.0 &&
+ proj_tc.y < 1.0 &&
+ proj_tc.x > 0.0 &&
+ proj_tc.y > 0.0)
+ {
+ float lit = 0.0;
+ float amb_da = proj_ambiance;
+
+ if (da > 0.0)
+ {
+ float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
+ float lod = diff * proj_lod;
+
+ vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
+
+ vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a;
+
+ lit = da * dist_atten * noise;
+
+ col = lcol*lit*diff_tex;
+ amb_da += (da*0.5)*proj_ambiance;
+ }
+
+ //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
+ vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
+
+ amb_da += (da*da*0.5+0.5)*proj_ambiance;
+
+ amb_da *= dist_atten * noise;
+
+ amb_da = min(amb_da, 1.0-lit);
+
+ col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
+ }
+
+
+ vec4 spec = texelFetch(specularRect, itc, i);
+ if (spec.a > 0.0)
+ {
+ vec3 ref = reflect(normalize(pos), norm);
+
+ //project from point pos in direction ref to plane proj_p, proj_n
+ vec3 pdelta = proj_p-pos;
+ float ds = dot(ref, proj_n);
+
+ if (ds < 0.0)
+ {
+ vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
+
+ vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
+
+ if (stc.z > 0.0)
+ {
+ stc.xy /= stc.w;
+
+ float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0);
+
+ stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
+
+ if (stc.x < 1.0 &&
+ stc.y < 1.0 &&
+ stc.x > 0.0 &&
+ stc.y > 0.0)
+ {
+ vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
+ col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb;
+ }
+ }
+ }
+ }
+
+ fcol += col;
+ ++wght;
+ }
+ }
+ }
+ }
+
+ if (wght <= 0)
+ {
+ discard;
+ }
+
+ gl_FragColor.rgb = fcol/samples;
+ 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
index 22ed9dcd40..5efa3200d4 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
- #version 120
+
#extension GL_ARB_texture_rectangle : enable
@@ -30,7 +30,7 @@ uniform vec4 viewport;
vec4 getPosition(vec2 pos_screen)
{
- float depth = texture2DRect(depthMap, pos_screen.xy).a;
+ float depth = texture2DRect(depthMap, pos_screen.xy).r;
vec2 sc = (pos_screen.xy-viewport.xy)*2.0;
sc /= viewport.zw;
sc -= vec2(1.0,1.0);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightMSF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightMSF.glsl
new file mode 100644
index 0000000000..feaf38115d
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightMSF.glsl
@@ -0,0 +1,108 @@
+/**
+ * @file pointLightF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+#extension GL_ARB_texture_rectangle : enable
+#extension GL_ARB_texture_multisample : enable
+
+uniform sampler2DMS depthMap;
+uniform sampler2DMS diffuseRect;
+uniform sampler2DMS specularRect;
+uniform sampler2DMS normalMap;
+uniform sampler2D noiseMap;
+uniform sampler2D lightFunc;
+
+
+uniform vec3 env_mat[3];
+uniform float sun_wash;
+
+varying vec4 vary_light;
+
+varying vec4 vary_fragcoord;
+uniform vec2 screen_res;
+
+uniform mat4 inv_proj;
+uniform vec4 viewport;
+
+vec4 getPosition(ivec2 pos_screen, int sample)
+{
+ float depth = texelFetch(depthMap, pos_screen, sample).r;
+ vec2 sc = (vec2(pos_screen.xy)-viewport.xy)*2.0;
+ sc /= viewport.zw;
+ sc -= vec2(1.0,1.0);
+ vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+ vec4 pos = inv_proj * ndc;
+ pos /= pos.w;
+ pos.w = 1.0;
+ return pos;
+}
+
+void main()
+{
+ vec4 frag = vary_fragcoord;
+ frag.xyz /= frag.w;
+ frag.xyz = frag.xyz*0.5+0.5;
+ frag.xy *= screen_res;
+
+ ivec2 itc = ivec2(frag.xy);
+
+ int wght = 0;
+ vec3 fcol = vec3(0,0,0);
+
+ for (int s = 0; s < samples; ++s)
+ {
+ vec3 pos = getPosition(itc, s).xyz;
+ vec3 lv = vary_light.xyz-pos;
+ float dist2 = dot(lv,lv);
+ dist2 /= vary_light.w;
+ if (dist2 <= 1.0)
+ {
+ vec3 norm = texelFetch(normalMap, itc, s).xyz;
+ norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
+ float da = dot(norm, lv);
+ if (da >= 0.0)
+ {
+ norm = normalize(norm);
+ lv = normalize(lv);
+ da = dot(norm, lv);
+
+ float noise = texture2D(noiseMap, frag.xy/128.0).b;
+
+ vec3 col = texelFetch(diffuseRect, itc, s).rgb;
+ float fa = gl_Color.a+1.0;
+ float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ float lit = da * dist_atten * noise;
+
+ col = gl_Color.rgb*lit*col;
+
+ vec4 spec = texelFetch(specularRect, itc, s);
+ if (spec.a > 0.0)
+ {
+ float sa = dot(normalize(lv-normalize(pos)),norm);
+ if (sa > 0.0)
+ {
+ sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
+ sa *= noise;
+ col += da*sa*gl_Color.rgb*spec.rgb;
+ }
+ }
+
+ fcol += col;
+ ++wght;
+ }
+ }
+ }
+
+ if (wght <= 0)
+ {
+ discard;
+ }
+
+ gl_FragColor.rgb = fcol/samples;
+ 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
index 8e74feb615..c510d8ad77 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
@@ -5,19 +5,14 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec4 vary_light;
varying vec4 vary_fragcoord;
-uniform vec2 screen_res;
-uniform float near_clip;
-
void main()
{
//transform vertex
- gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
-
vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
vary_fragcoord = pos;
@@ -25,6 +20,8 @@ void main()
tex.w = 1.0;
vary_light = gl_MultiTexCoord0;
+
+ gl_Position = pos;
gl_FrontColor = gl_Color;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
index 77f1b2224c..f6b0402bb9 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
#extension GL_ARB_texture_rectangle : enable
@@ -29,7 +29,7 @@ varying vec2 vary_fragcoord;
float getDepth(vec2 pos_screen)
{
- float z = texture2DRect(depthMap, pos_screen.xy).a;
+ float z = texture2DRect(depthMap, pos_screen.xy).r;
z = z*2.0-1.0;
vec4 ndc = vec4(0.0, 0.0, z, 1.0);
vec4 p = inv_proj*ndc;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredMSF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredMSF.glsl
new file mode 100644
index 0000000000..62ae5f917a
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredMSF.glsl
@@ -0,0 +1,133 @@
+/**
+ * @file postDeferredF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+#extension GL_ARB_texture_rectangle : enable
+#extension GL_ARB_texture_multisample : enable
+
+uniform sampler2DMS diffuseRect;
+uniform sampler2DMS edgeMap;
+uniform sampler2DMS depthMap;
+uniform sampler2DMS normalMap;
+uniform sampler2D bloomMap;
+
+uniform float depth_cutoff;
+uniform float norm_cutoff;
+uniform float focal_distance;
+uniform float blur_constant;
+uniform float tan_pixel_angle;
+uniform float magnification;
+
+uniform mat4 inv_proj;
+uniform vec2 screen_res;
+
+varying vec2 vary_fragcoord;
+
+vec4 texture2DMS(sampler2DMS tex, ivec2 tc)
+{
+ vec4 ret = vec4(0,0,0,0);
+ for (int i = 0; i < samples; ++i)
+ {
+ ret += texelFetch(tex, tc, i);
+ }
+
+ return ret/samples;
+}
+
+float getDepth(ivec2 pos_screen)
+{
+ float z = texture2DMS(depthMap, pos_screen.xy).r;
+ z = z*2.0-1.0;
+ vec4 ndc = vec4(0.0, 0.0, z, 1.0);
+ vec4 p = inv_proj*ndc;
+ return p.z/p.w;
+}
+
+float calc_cof(float depth)
+{
+ float sc = abs(depth-focal_distance)/-depth*blur_constant;
+
+ sc /= magnification;
+
+ // tan_pixel_angle = pixel_length/-depth;
+ float pixel_length = tan_pixel_angle*-focal_distance;
+
+ sc = sc/pixel_length;
+ sc *= 1.414;
+
+ return sc;
+}
+
+void dofSample(inout vec4 diff, inout float w, float min_sc, float cur_depth, ivec2 tc)
+{
+ float d = getDepth(tc);
+
+ float sc = calc_cof(d);
+
+ if (sc > min_sc //sampled pixel is more "out of focus" than current sample radius
+ || d < cur_depth) //sampled pixel is further away than current pixel
+ {
+ float wg = 0.25;
+
+ vec4 s = texture2DMS(diffuseRect, tc);
+ // de-weight dull areas to make highlights 'pop'
+ wg += s.r+s.g+s.b;
+
+ diff += wg*s;
+
+ w += wg;
+ }
+}
+
+
+void main()
+{
+ ivec2 itc = ivec2(vary_fragcoord.xy);
+
+ vec3 norm = texture2DMS(normalMap, itc).xyz;
+ norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
+
+ float depth = getDepth(itc);
+
+ vec4 diff = texture2DMS(diffuseRect, itc);
+
+ {
+ float w = 1.0;
+
+ float sc = calc_cof(depth);
+ sc = min(abs(sc), 10.0);
+
+ float fd = depth*0.5f;
+
+ float PI = 3.14159265358979323846264;
+
+ int isc = int(sc);
+
+ // sample quite uniformly spaced points within a circle, for a circular 'bokeh'
+ //if (depth < focal_distance)
+ {
+ for (int x = -isc; x <= isc; x+=2)
+ {
+ for (int y = -isc; y <= isc; y+=2)
+ {
+ ivec2 cur_samp = ivec2(x,y);
+ float cur_sc = length(vec2(cur_samp));
+ if (cur_sc < sc)
+ {
+ dofSample(diff, w, cur_sc, depth, itc+cur_samp);
+ }
+ }
+ }
+ }
+
+ diff /= w;
+ }
+
+ vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
+ gl_FragColor = diff + bloom;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
index ab48d08bbb..bf829bfc56 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
#extension GL_ARB_texture_rectangle : enable
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFMSF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFMSF.glsl
new file mode 100644
index 0000000000..bf35dfe11c
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredNoDoFMSF.glsl
@@ -0,0 +1,37 @@
+/**
+ * @file postDeferredF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+#extension GL_ARB_texture_rectangle : enable
+#extension GL_ARB_texture_multisample : enable
+
+uniform sampler2DMS diffuseRect;
+uniform sampler2D bloomMap;
+
+uniform vec2 screen_res;
+varying vec2 vary_fragcoord;
+
+vec4 texture2DMS(sampler2DMS tex, ivec2 tc)
+{
+ vec4 ret = vec4(0,0,0,0);
+
+ for (int i = 0; i < samples; ++i)
+ {
+ ret += texelFetch(tex,tc,i);
+ }
+
+ return ret/samples;
+}
+
+void main()
+{
+ vec4 diff = texture2DMS(diffuseRect, ivec2(vary_fragcoord.xy));
+
+ vec4 bloom = texture2D(bloomMap, vary_fragcoord.xy/screen_res);
+ gl_FragColor = diff + bloom;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
index 12983baa94..876f65ee3a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec2 vary_fragcoord;
uniform vec2 screen_res;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
index 63b3c9f205..fa3f04bcc8 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform sampler2DRect depthMap;
uniform sampler2DRect normalMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl b/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl
index ae57227fe5..eebe930666 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec2 vary_fragcoord;
uniform vec2 screen_res;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
index 6674c4a5aa..e0c5406483 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
index db3bddc6be..9271a5115c 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec4 post_pos;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
new file mode 100644
index 0000000000..820c82ffd7
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl
@@ -0,0 +1,44 @@
+/**
+ * @file WLSkyF.glsl
+ *
+ * $LicenseInfo:firstyear=2005&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+/////////////////////////////////////////////////////////////////////////
+// The fragment shader for the sky
+/////////////////////////////////////////////////////////////////////////
+
+varying vec4 vary_HazeColor;
+
+uniform sampler2D cloud_noise_texture;
+uniform vec4 gamma;
+
+/// Soft clips the light with a gamma correction
+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()
+{
+ // Potential Fill-rate optimization. Add cloud calculation
+ // back in and output alpha of 0 (so that alpha culling kills
+ // the fragment) if the sky wouldn't show up because the clouds
+ // are fully opaque.
+
+ vec4 color;
+ color = vary_HazeColor;
+ color *= 2.;
+
+ /// Gamma correct for WL (soft clip effect).
+ gl_FragData[0] = vec4(scaleSoftClip(color.rgb), 1.0);
+ gl_FragData[1] = vec4(0.0,0.0,0.0,0.0);
+ gl_FragData[2] = vec4(0,0,1,0);
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
new file mode 100644
index 0000000000..1ea00f723a
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl
@@ -0,0 +1,140 @@
+/**
+ * @file WLSkyV.glsl
+ *
+ * $LicenseInfo:firstyear=2005&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+// SKY ////////////////////////////////////////////////////////////////////////
+// The vertex shader for creating the atmospheric sky
+///////////////////////////////////////////////////////////////////////////////
+
+// Output parameters
+varying vec4 vary_HazeColor;
+
+// Inputs
+uniform vec3 camPosLocal;
+
+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 max_y;
+
+uniform vec4 glow;
+
+uniform vec4 cloud_color;
+
+uniform vec4 cloud_scale;
+
+void main()
+{
+
+ // World / view / projection
+ gl_Position = ftransform();
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ // Get relative position
+ vec3 P = gl_Vertex.xyz - camPosLocal.xyz + vec3(0,50,0);
+ //vec3 P = gl_Vertex.xyz + vec3(0,50,0);
+
+ // Set altitude
+ if (P.y > 0.)
+ {
+ P *= (max_y.x / P.y);
+ }
+ else
+ {
+ P *= (-32000. / P.y);
+ }
+
+ // Can normalize then
+ vec3 Pn = normalize(P);
+ float Plen = length(P);
+
+ // Initialize temp variables
+ vec4 temp1 = vec4(0.);
+ vec4 temp2 = vec4(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 + haze_density.x * 0.25) * (density_multiplier.x * max_y.x);
+
+ // Calculate relative weights
+ temp1 = blue_density + haze_density.x;
+ blue_weight = blue_density / temp1;
+ haze_weight = haze_density.x / temp1;
+
+ // Compute sunlight from P & lightnorm (for long rays like sky)
+ temp2.y = max(0., max(0., Pn.y) * 1.0 + lightnorm.y );
+ temp2.y = 1. / temp2.y;
+ sunlight *= exp( - light_atten * temp2.y);
+
+ // Distance
+ temp2.z = Plen * density_multiplier.x;
+
+ // Transparency (-> temp1)
+ // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati
+ // compiler gets confused.
+ temp1 = exp(-temp1 * temp2.z);
+
+
+ // Compute haze glow
+ temp2.x = dot(Pn, lightnorm.xyz);
+ temp2.x = 1. - temp2.x;
+ // temp2.x is 0 at the sun and increases away from sun
+ temp2.x = max(temp2.x, .001);
+ // 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;
+
+
+ // Haze color above cloud
+ vary_HazeColor = ( blue_horizon * blue_weight * (sunlight + ambient)
+ + (haze_horizon.r * haze_weight) * (sunlight * temp2.x + ambient)
+ );
+
+
+ // Increase ambient when there are more clouds
+ vec4 tmpAmbient = ambient;
+ tmpAmbient += (1. - tmpAmbient) * cloud_shadow.x * 0.5;
+
+ // Dim sunlight by cloud shadow percentage
+ sunlight *= (1. - cloud_shadow.x);
+
+ // Haze color below cloud
+ vec4 additiveColorBelowCloud = ( blue_horizon * blue_weight * (sunlight + tmpAmbient)
+ + (haze_horizon.r * haze_weight) * (sunlight * temp2.x + tmpAmbient)
+ );
+
+ // Final atmosphere additive
+ vary_HazeColor *= (1. - temp1);
+
+ // Attenuate cloud color by atmosphere
+ temp1 = sqrt(temp1); //less atmos opacity (more transparency) below clouds
+
+ // At horizon, blend high altitude sky color towards the darker color below the clouds
+ vary_HazeColor += (additiveColorBelowCloud - vary_HazeColor) * (1. - sqrt(temp1));
+
+ // won't compile on mac without this being set
+ //vary_AtmosAttenuation = vec3(0.0,0.0,0.0);
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index 29340c7e9f..60082f40d6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
#extension GL_ARB_texture_rectangle : enable
@@ -259,7 +259,7 @@ vec3 scaleSoftClip(vec3 light)
void main()
{
vec2 tc = vary_fragcoord.xy;
- float depth = texture2DRect(depthMap, tc.xy).a;
+ float depth = texture2DRect(depthMap, tc.xy).r;
vec3 pos = getPosition_d(tc, depth).xyz;
vec3 norm = texture2DRect(normalMap, tc).xyz;
norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightMSF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightMSF.glsl
new file mode 100644
index 0000000000..9dfacfb520
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightMSF.glsl
@@ -0,0 +1,318 @@
+/**
+ * @file softenLightF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+#extension GL_ARB_texture_rectangle : enable
+#extension GL_ARB_texture_multisample : enable
+
+uniform sampler2DMS diffuseRect;
+uniform sampler2DMS specularRect;
+uniform sampler2DMS normalMap;
+uniform sampler2DMS depthMap;
+uniform sampler2D noiseMap;
+uniform samplerCube environmentMap;
+uniform sampler2D lightFunc;
+
+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;
+
+uniform mat4 inv_proj;
+uniform vec2 screen_res;
+
+vec4 getPosition_d(vec2 pos_screen, float depth)
+{
+ vec2 sc = pos_screen.xy*2.0;
+ sc /= screen_res;
+ sc -= vec2(1.0,1.0);
+ vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+ vec4 pos = inv_proj * ndc;
+ pos /= pos.w;
+ pos.w = 1.0;
+ return pos;
+}
+
+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;
+}
+
+vec4 texture2DMS(sampler2DMS tex, ivec2 tc)
+{
+ vec4 ret = vec4(0,0,0,0);
+
+ for (int i = 0; i < samples; ++i)
+ {
+ ret += texelFetch(tex,tc,i);
+ }
+
+ return ret/samples;
+}
+
+void main()
+{
+ vec2 tc = vary_fragcoord.xy;
+ ivec2 itc = ivec2(tc);
+
+ vec3 fcol = vec3(0,0,0);
+
+ for (int i = 0; i < samples; ++i)
+ {
+ float depth = texelFetch(depthMap, itc, i).r;
+ vec3 pos = getPosition_d(tc, depth).xyz;
+ vec3 norm = texelFetch(normalMap, itc, i).xyz;
+
+ norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
+ //vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
+
+ float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
+
+ vec4 diffuse = texelFetch(diffuseRect, itc, i);
+ if (diffuse.a >= 1.0)
+ {
+ fcol += diffuse.rgb;
+ }
+ else
+ {
+ vec4 spec = texelFetch(specularRect, itc, i);
+
+ calcAtmospherics(pos.xyz, 1.0);
+
+ vec3 col = atmosAmbient(vec3(0));
+ col += atmosAffectDirectionalLight(max(min(da, 1.0), diffuse.a));
+
+ col *= diffuse.rgb;
+
+ if (spec.a > 0.0) // specular reflection
+ {
+ // the old infinite-sky shiny reflection
+ //
+ vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+ float sa = dot(refnormpersp, vary_light.xyz);
+ vec3 dumbshiny = vary_SunlitColor*texture2D(lightFunc, vec2(sa, spec.a)).a;
+
+ // add the two types of shiny together
+ col += dumbshiny * spec.rgb;
+ }
+
+ col = atmosLighting(col);
+ col = scaleSoftClip(col);
+ fcol += col;
+ }
+ }
+
+ gl_FragColor.rgb = fcol.rgb/samples;
+ gl_FragColor.a = 0.0;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
index 8f0bcca76b..745cc01992 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform vec2 screen_res;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
index 29fac46bfe..9aaffc15bf 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
#extension GL_ARB_texture_rectangle : enable
diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightMSF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightMSF.glsl
new file mode 100644
index 0000000000..4bb9bad275
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightMSF.glsl
@@ -0,0 +1,234 @@
+/**
+ * @file multiSpotLightF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+//class 1 -- no shadows
+
+#extension GL_ARB_texture_rectangle : enable
+#extension GL_ARB_texture_multisample : enable
+
+uniform sampler2DMS diffuseRect;
+uniform sampler2DMS specularRect;
+uniform sampler2DMS depthMap;
+uniform sampler2DMS normalMap;
+uniform sampler2D noiseMap;
+uniform sampler2D lightFunc;
+uniform sampler2D projectionMap;
+
+uniform mat4 proj_mat; //screen space to light space
+uniform float proj_near; //near clip for projection
+uniform vec3 proj_p; //plane projection is emitting from (in screen space)
+uniform vec3 proj_n;
+uniform float proj_focus; //distance from plane to begin blurring
+uniform float proj_lod; //(number of mips in proj map)
+uniform float proj_range; //range between near clip and far clip plane of projection
+uniform float proj_ambient_lod;
+uniform float proj_ambiance;
+uniform float near_clip;
+uniform float far_clip;
+
+uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
+uniform float sun_wash;
+uniform int proj_shadow_idx;
+uniform float shadow_fade;
+
+varying vec4 vary_light;
+
+varying vec4 vary_fragcoord;
+uniform vec2 screen_res;
+
+uniform mat4 inv_proj;
+
+vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod)
+{
+ vec4 ret = texture2DLod(projectionMap, tc, lod);
+
+ vec2 dist = tc-vec2(0.5);
+
+ float det = max(1.0-lod/(proj_lod*0.5), 0.0);
+
+ float d = dot(dist,dist);
+
+ ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0)+det, 1.0);
+
+ return ret;
+}
+
+vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod)
+{
+ vec4 ret = texture2DLod(projectionMap, tc, lod);
+
+ vec2 dist = vec2(0.5) - abs(tc-vec2(0.5));
+
+ float det = min(lod/(proj_lod*0.5), 1.0);
+
+ float d = min(dist.x, dist.y);
+
+ float edge = 0.25*det;
+
+ ret *= clamp(d/edge, 0.0, 1.0);
+
+ return ret;
+}
+
+vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod)
+{
+ vec4 ret = texture2DLod(projectionMap, tc, lod);
+
+ vec2 dist = tc-vec2(0.5);
+
+ float d = dot(dist,dist);
+
+ ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0), 1.0);
+
+ return ret;
+}
+
+
+vec4 getPosition(ivec2 pos_screen, int sample)
+{
+ float depth = texelFetch(depthMap, pos_screen, sample).r;
+ vec2 sc = vec2(pos_screen.xy)*2.0;
+ sc /= screen_res;
+ sc -= vec2(1.0,1.0);
+ vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+ vec4 pos = inv_proj * ndc;
+ pos /= pos.w;
+ pos.w = 1.0;
+ return pos;
+}
+
+void main()
+{
+ vec4 frag = vary_fragcoord;
+ frag.xyz /= frag.w;
+ frag.xyz = frag.xyz*0.5+0.5;
+ frag.xy *= screen_res;
+ ivec2 itc = ivec2(frag.xy);
+
+ vec3 fcol = vec3(0,0,0);
+ int wght = 0;
+
+ for (int i = 0; i < samples; ++i)
+ {
+ vec3 pos = getPosition(itc, i).xyz;
+ vec3 lv = vary_light.xyz-pos.xyz;
+ float dist2 = dot(lv,lv);
+ dist2 /= vary_light.w;
+ if (dist2 <= 1.0)
+ {
+ vec3 norm = texelFetch(normalMap, itc, i).xyz*2.0-1.0;
+
+ norm = normalize(norm);
+ float l_dist = -dot(lv, proj_n);
+
+ vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
+ if (proj_tc.z >= 0.0)
+ {
+ proj_tc.xyz /= proj_tc.w;
+
+ float fa = gl_Color.a+1.0;
+ float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0);
+ if (dist_atten > 0.0)
+ {
+ lv = proj_origin-pos.xyz;
+ lv = normalize(lv);
+ float da = dot(norm, lv);
+
+ vec3 col = vec3(0,0,0);
+
+ vec3 diff_tex = texelFetch(diffuseRect, itc, i).rgb;
+
+ float noise = texture2D(noiseMap, frag.xy/128.0).b;
+ if (proj_tc.z > 0.0 &&
+ proj_tc.x < 1.0 &&
+ proj_tc.y < 1.0 &&
+ proj_tc.x > 0.0 &&
+ proj_tc.y > 0.0)
+ {
+ float lit = 0.0;
+ float amb_da = proj_ambiance;
+
+ if (da > 0.0)
+ {
+ float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
+ float lod = diff * proj_lod;
+
+ vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod);
+
+ vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a;
+
+ lit = da * dist_atten * noise;
+
+ col = lcol*lit*diff_tex;
+ amb_da += (da*0.5)*proj_ambiance;
+ }
+
+ //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
+ vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod);
+
+ amb_da += (da*da*0.5+0.5)*proj_ambiance;
+
+ amb_da *= dist_atten * noise;
+
+ amb_da = min(amb_da, 1.0-lit);
+
+ col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
+ }
+
+
+ vec4 spec = texelFetch(specularRect, itc, i);
+ if (spec.a > 0.0)
+ {
+ vec3 ref = reflect(normalize(pos), norm);
+
+ //project from point pos in direction ref to plane proj_p, proj_n
+ vec3 pdelta = proj_p-pos;
+ float ds = dot(ref, proj_n);
+
+ if (ds < 0.0)
+ {
+ vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
+
+ vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
+
+ if (stc.z > 0.0)
+ {
+ stc.xy /= stc.w;
+
+ float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0);
+
+ stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
+
+ if (stc.x < 1.0 &&
+ stc.y < 1.0 &&
+ stc.x > 0.0 &&
+ stc.y > 0.0)
+ {
+ vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
+ col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb;
+ }
+ }
+ }
+ }
+
+ fcol += col;
+ ++wght;
+ }
+ }
+ }
+ }
+
+ if (wght <= 0)
+ {
+ discard;
+ }
+
+ gl_FragColor.rgb = fcol/samples;
+ gl_FragColor.a = 0.0;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
new file mode 100644
index 0000000000..2cf7d194cc
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/starsF.glsl
@@ -0,0 +1,19 @@
+/**
+ * @file starsF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+uniform sampler2D diffuseMap;
+
+void main()
+{
+ vec4 col = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy);
+
+ gl_FragData[0] = col;
+ gl_FragData[1] = vec4(0,0,0,0);
+ gl_FragData[2] = vec4(0,0,1,0);
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl
new file mode 100644
index 0000000000..c43125dad9
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/starsV.glsl
@@ -0,0 +1,17 @@
+/**
+ * @file starsV.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+
+void main()
+{
+ //transform vertex
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+ gl_FrontColor = gl_Color;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
index 00093836a2..f20886565a 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
//class 1, no shadow, no SSAO, should never be called
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightMSF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightMSF.glsl
new file mode 100644
index 0000000000..f20886565a
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightMSF.glsl
@@ -0,0 +1,17 @@
+/**
+ * @file sunLightF.glsl
+ *
+ * $LicenseInfo:firstyear=2007&license=viewerlgpl$
+ * $/LicenseInfo$
+ */
+
+
+
+//class 1, no shadow, no SSAO, should never be called
+
+#extension GL_ARB_texture_rectangle : enable
+
+void main()
+{
+ gl_FragColor = vec4(0,0,0,0);
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
index cd91351ad4..665d8126a0 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOF.glsl
@@ -5,7 +5,7 @@
* $License$
*/
-#version 120
+
#extension GL_ARB_texture_rectangle : enable
@@ -35,7 +35,7 @@ uniform float shadow_offset;
vec4 getPosition(vec2 pos_screen)
{
- float depth = texture2DRect(depthMap, pos_screen.xy).a;
+ float depth = texture2DRect(depthMap, pos_screen.xy).r;
vec2 sc = pos_screen.xy*2.0;
sc /= screen_res;
sc -= vec2(1.0,1.0);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOMSF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOMSF.glsl
new file mode 100644
index 0000000000..32d1b2149a
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightSSAOMSF.glsl
@@ -0,0 +1,123 @@
+/**
+ * @file sunLightSSAOF.glsl
+ *
+ * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
+ * $License$
+ */
+
+
+
+#extension GL_ARB_texture_rectangle : enable
+#extension GL_ARB_texture_multisample : enable
+
+//class 1 -- no shadow, SSAO only
+
+uniform sampler2DMS depthMap;
+uniform sampler2DMS normalMap;
+uniform sampler2D noiseMap;
+
+
+// Inputs
+uniform mat4 shadow_matrix[6];
+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;
+
+uniform mat4 inv_proj;
+uniform vec2 screen_res;
+
+uniform float shadow_bias;
+uniform float shadow_offset;
+
+vec4 getPosition(ivec2 pos_screen, int sample)
+{
+ float depth = texelFetch(depthMap, pos_screen, sample).r;
+ vec2 sc = pos_screen.xy*2.0;
+ sc /= screen_res;
+ sc -= vec2(1.0,1.0);
+ vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
+ vec4 pos = inv_proj * ndc;
+ pos /= pos.w;
+ pos.w = 1.0;
+ return pos;
+}
+
+//calculate decreases in ambient lighting when crowded out (SSAO)
+float calcAmbientOcclusion(vec4 pos, vec3 norm, int sample)
+{
+ float ret = 1.0;
+
+ 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++)
+ {
+ ivec2 samppos_screen = ivec2(pos_screen + scale * reflect(kern[i], noise_reflect));
+ vec3 samppos_world = getPosition(samppos_screen, sample).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)
+
+ 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);
+
+ ret = (1.0 - (float(points != 0) * angle_hidden));
+
+ return min(ret, 1.0);
+}
+
+void main()
+{
+ vec2 pos_screen = vary_fragcoord.xy;
+ ivec2 itc = ivec2(pos_screen);
+
+ float col = 0;
+
+ for (int i = 0; i < samples; i++)
+ {
+ vec4 pos = getPosition(itc, i);
+ vec3 norm = texelFetch(normalMap, itc, i).xyz;
+ norm = vec3((norm.xy-0.5)*2.0,norm.z); // unpack norm
+ col += calcAmbientOcclusion(pos,norm,i);
+ }
+
+ col /= samples;
+
+ gl_FragColor[0] = 1.0;
+ gl_FragColor[1] = col;
+ gl_FragColor[2] = 1.0;
+ gl_FragColor[3] = 1.0;
+}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
index 9beb513ad8..814deb3677 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/sunLightV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec4 vary_light;
varying vec2 vary_fragcoord;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index 0edae47918..d005f67bf6 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform sampler2D detail_0;
uniform sampler2D detail_1;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
index a6163063be..3038fd2966 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec3 vary_normal;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
index c54d9a1e3e..de7e038402 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
uniform sampler2D diffuseMap;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl b/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
index 29689ecbaf..a9bef4292d 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
varying vec3 vary_normal;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index e76f598d09..2710422d32 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
#extension GL_ARB_texture_rectangle : enable
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
index 649e392630..5397290b11 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/waterV.glsl
@@ -5,7 +5,7 @@
* $/LicenseInfo$
*/
-#version 120
+
void calcAtmospherics(vec3 inPositionEye);