aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/app_settings/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/app_settings/shaders')
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl24
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl10
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl2
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl13
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl3
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl3
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl2
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl41
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl8
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl3
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl6
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl5
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl28
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl2
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/giF.glsl165
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/giV.glsl22
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl15
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl20
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl62
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl184
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl61
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl6
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl57
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl17
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl107
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl16
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl3
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl10
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl4
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl199
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl111
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl6
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl2
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl4
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl3
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl2
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/effects/colorFilterF.glsl31
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/effects/drawQuadV.glsl14
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/effects/nightVisionF.glsl42
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl112
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl75
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaF.glsl77
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl78
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl71
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/blurLightV.glsl17
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl188
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredF.glsl59
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredV.glsl17
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl294
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl24
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl199
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl203
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl25
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/waterF.glsl139
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl76
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/avatarF.glsl18
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/bumpF.glsl27
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/diffuseF.glsl18
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl84
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl17
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/giF.glsl219
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/giV.glsl22
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl16
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl20
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl76
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl17
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl87
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl17
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl312
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl24
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl18
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl139
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/effects/blurF.glsl31
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/effects/blurV.glsl35
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/effects/colorFilterF.glsl31
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/effects/drawQuadV.glsl14
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/effects/extractF.glsl22
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/effects/nightVisionF.glsl42
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/effects/simpleF.glsl14
79 files changed, 4159 insertions, 128 deletions
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index a91e9fa..f90d91f 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -13,9 +13,9 @@ uniform sampler2DShadow shadowMap1;
13uniform sampler2DShadow shadowMap2; 13uniform sampler2DShadow shadowMap2;
14uniform sampler2DShadow shadowMap3; 14uniform sampler2DShadow shadowMap3;
15uniform sampler2D noiseMap; 15uniform sampler2D noiseMap;
16uniform sampler2DRect positionMap; 16uniform sampler2DRect depthMap;
17 17
18uniform mat4 shadow_matrix[4]; 18uniform mat4 shadow_matrix[6];
19uniform vec4 shadow_clip; 19uniform vec4 shadow_clip;
20uniform vec2 screen_res; 20uniform vec2 screen_res;
21 21
@@ -26,15 +26,31 @@ varying vec3 vary_ambient;
26varying vec3 vary_directional; 26varying vec3 vary_directional;
27varying vec3 vary_fragcoord; 27varying vec3 vary_fragcoord;
28varying vec3 vary_position; 28varying vec3 vary_position;
29varying vec3 vary_light;
29 30
30uniform float alpha_soften; 31uniform float alpha_soften;
31 32
33uniform mat4 inv_proj;
34
35vec4 getPosition(vec2 pos_screen)
36{
37 float depth = texture2DRect(depthMap, pos_screen.xy).a;
38 vec2 sc = pos_screen.xy*2.0;
39 sc /= screen_res;
40 sc -= vec2(1.0,1.0);
41 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
42 vec4 pos = inv_proj * ndc;
43 pos /= pos.w;
44 pos.w = 1.0;
45 return pos;
46}
47
32void main() 48void main()
33{ 49{
34 vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; 50 vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
35 frag *= screen_res; 51 frag *= screen_res;
36 52
37 vec3 samp_pos = texture2DRect(positionMap, frag).xyz; 53 vec3 samp_pos = getPosition(frag).xyz;
38 54
39 float shadow = 1.0; 55 float shadow = 1.0;
40 vec4 pos = vec4(vary_position, 1.0); 56 vec4 pos = vec4(vary_position, 1.0);
@@ -82,7 +98,7 @@ void main()
82 98
83 //gl_FragColor = gl_Color; 99 //gl_FragColor = gl_Color;
84 gl_FragColor = color; 100 gl_FragColor = color;
85 //gl_FragColor = vec4(1,0,1,1); 101 //gl_FragColor = vec4(1,0,1,1)*shadow;
86 102
87} 103}
88 104
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index b496bd6..48baf77 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -20,8 +20,11 @@ varying vec3 vary_ambient;
20varying vec3 vary_directional; 20varying vec3 vary_directional;
21varying vec3 vary_fragcoord; 21varying vec3 vary_fragcoord;
22varying vec3 vary_position; 22varying vec3 vary_position;
23varying vec3 vary_light;
23 24
24uniform float near_clip; 25uniform float near_clip;
26uniform float shadow_offset;
27uniform float shadow_bias;
25 28
26void main() 29void main()
27{ 30{
@@ -32,8 +35,9 @@ void main()
32 35
33 vec4 pos = (gl_ModelViewMatrix * gl_Vertex); 36 vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
34 vec3 norm = normalize(gl_NormalMatrix * gl_Normal); 37 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
35 vary_position = pos.xyz; 38 // KL this works around ATI not compiling the shader but maintains shadow offset and bias vec3 not vec4
36 39 vary_position = pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias);
40
37 calcAtmospherics(pos.xyz); 41 calcAtmospherics(pos.xyz);
38 42
39 //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.)); 43 //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
@@ -54,6 +58,8 @@ void main()
54 col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz); 58 col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
55 col.rgb = scaleDownLight(col.rgb); 59 col.rgb = scaleDownLight(col.rgb);
56 60
61 vary_light = gl_LightSource[0].position.xyz;
62
57 vary_ambient = col.rgb*gl_Color.rgb; 63 vary_ambient = col.rgb*gl_Color.rgb;
58 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))); 64 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)));
59 65
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl
index 6c94f5c..ff64a6b 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaF.glsl
@@ -12,7 +12,7 @@ uniform sampler2DShadow shadowMap2;
12uniform sampler2DShadow shadowMap3; 12uniform sampler2DShadow shadowMap3;
13uniform sampler2D noiseMap; 13uniform sampler2D noiseMap;
14 14
15uniform mat4 shadow_matrix[4]; 15uniform mat4 shadow_matrix[6];
16uniform vec4 shadow_clip; 16uniform vec4 shadow_clip;
17 17
18vec3 atmosLighting(vec3 light); 18vec3 atmosLighting(vec3 light);
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
index 58aa5a9..4b9cca2 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarF.glsl
@@ -8,13 +8,18 @@
8uniform sampler2D diffuseMap; 8uniform sampler2D diffuseMap;
9 9
10varying vec3 vary_normal; 10varying vec3 vary_normal;
11varying vec4 vary_position;
12 11
13void main() 12void main()
14{ 13{
15 gl_FragData[0] = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy); 14 vec4 diff = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy);
15 // Viewer 2.0 uses 0.2 but for KL's viewer if i want a complete avatar need this to be 0.0 for now.
16 if (diff.a < 0.0)
17 {
18 discard;
19 }
20
21 gl_FragData[0] = vec4(diff.rgb, 1.0);
16 gl_FragData[1] = vec4(0,0,0,0); 22 gl_FragData[1] = vec4(0,0,0,0);
17 gl_FragData[2] = vec4(normalize(vary_normal), 0.0); 23 gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
18 gl_FragData[3] = vary_position;
19} 24}
20 25
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
index 27c09db..00083eb 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowF.glsl
@@ -10,6 +10,7 @@ uniform sampler2D diffuseMap;
10 10
11void main() 11void main()
12{ 12{
13 gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy)); 13 gl_FragColor = vec4(1,1,1,gl_Color.a * texture2D(diffuseMap, gl_TexCoord[0].xy).a);
14 //gl_FragColor = vec4(1,1,1,1);
14} 15}
15 16
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
index 14da6b1..8c8489d 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarShadowV.glsl
@@ -28,8 +28,7 @@ void main()
28 norm = normalize(norm); 28 norm = normalize(norm);
29 29
30 pos = gl_ProjectionMatrix * pos; 30 pos = gl_ProjectionMatrix * pos;
31 //smash geometry against near clip plane 31 pos.z = max(pos.z, -pos.w+0.01);
32 pos.z = max(pos.z, -1.0);
33 gl_Position = pos; 32 gl_Position = pos;
34 33
35 gl_FrontColor = gl_Color; 34 gl_FrontColor = gl_Color;
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl
index 12a7ff7..471a1f0 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/avatarV.glsl
@@ -10,7 +10,6 @@ mat4 getSkinnedTransform();
10attribute vec4 weight; 10attribute vec4 weight;
11 11
12varying vec3 vary_normal; 12varying vec3 vary_normal;
13varying vec4 vary_position;
14 13
15void main() 14void main()
16{ 15{
@@ -30,7 +29,6 @@ void main()
30 norm.z = dot(trans[2].xyz, gl_Normal); 29 norm.z = dot(trans[2].xyz, gl_Normal);
31 norm = normalize(norm); 30 norm = normalize(norm);
32 31
33 vary_position = pos;
34 vary_normal = norm; 32 vary_normal = norm;
35 33
36 gl_Position = gl_ProjectionMatrix * pos; 34 gl_Position = gl_ProjectionMatrix * pos;
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
index 3c6700a..1713fe9 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/blurLightF.glsl
@@ -7,10 +7,11 @@
7 7
8#extension GL_ARB_texture_rectangle : enable 8#extension GL_ARB_texture_rectangle : enable
9 9
10uniform sampler2DRect positionMap; 10uniform sampler2DRect depthMap;
11uniform sampler2DRect normalMap; 11uniform sampler2DRect normalMap;
12uniform sampler2DRect lightMap; 12uniform sampler2DRect lightMap;
13 13
14uniform float dist_factor;
14uniform float blur_size; 15uniform float blur_size;
15uniform vec2 delta; 16uniform vec2 delta;
16uniform vec3 kern[32]; 17uniform vec3 kern[32];
@@ -19,30 +20,52 @@ uniform float kern_scale;
19 20
20varying vec2 vary_fragcoord; 21varying vec2 vary_fragcoord;
21 22
23uniform mat4 inv_proj;
24uniform vec2 screen_res;
25
26vec4 getPosition(vec2 pos_screen)
27{
28 float depth = texture2DRect(depthMap, pos_screen.xy).a;
29 vec2 sc = pos_screen.xy*2.0;
30 sc /= screen_res;
31 sc -= vec2(1.0,1.0);
32 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
33 vec4 pos = inv_proj * ndc;
34 pos /= pos.w;
35 pos.w = 1.0;
36 return pos;
37}
38
22void main() 39void main()
23{ 40{
24 vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz; 41 vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
25 vec3 pos = texture2DRect(positionMap, vary_fragcoord.xy).xyz; 42 vec3 pos = getPosition(vary_fragcoord.xy).xyz;
26 vec2 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rg; 43 vec4 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rgba;
27 44
28 vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy); 45 vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy);
29 46
47 dlt /= max(-pos.z*dist_factor, 1.0);
48
30 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' 49 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'
31 vec2 col = defined_weight * ccol; 50 vec4 col = defined_weight.xyxx * ccol;
32 51
33 for (int i = 1; i < kern_length; i++) 52 for (int i = 1; i < kern_length; i++)
34 { 53 {
35 vec2 tc = vary_fragcoord.xy + kern[i].z*dlt; 54 vec2 tc = vary_fragcoord.xy + kern[i].z*dlt;
36 vec3 samppos = texture2DRect(positionMap, tc).xyz; 55 vec3 samppos = getPosition(tc).xyz;
37 float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane 56 float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
38 if (d*d <= 0.003) 57 if (d*d <= 0.003)
39 { 58 {
40 col += texture2DRect(lightMap, tc).rg*kern[i].xy; 59 col += texture2DRect(lightMap, tc)*kern[i].xyxx;
41 defined_weight += kern[i].xy; 60 defined_weight += kern[i].xy;
42 } 61 }
43 } 62 }
44 63
45 col /= defined_weight;
46 64
47 gl_FragColor = vec4(col.r, col.g, 0.0, 1.0); 65
66 col /= defined_weight.xyxx;
67
68 gl_FragColor = col;
69
70 //gl_FragColor = ccol;
48} 71}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
index a8712bc..1c29dae 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpF.glsl
@@ -11,7 +11,6 @@ uniform sampler2D bumpMap;
11varying vec3 vary_mat0; 11varying vec3 vary_mat0;
12varying vec3 vary_mat1; 12varying vec3 vary_mat1;
13varying vec3 vary_mat2; 13varying vec3 vary_mat2;
14varying vec4 vary_position;
15 14
16void main() 15void main()
17{ 16{
@@ -22,8 +21,7 @@ void main()
22 dot(norm,vary_mat1), 21 dot(norm,vary_mat1),
23 dot(norm,vary_mat2)); 22 dot(norm,vary_mat2));
24 23
25 gl_FragData[0].rgb = gl_Color.rgb*col; 24 gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0);
26 gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a); 25 gl_FragData[1] = vec4(col*gl_Color.a, gl_Color.a);
27 gl_FragData[2] = vec4(normalize(tnorm), 0.0); 26 gl_FragData[2] = vec4(normalize(tnorm)*0.5+0.5, 0.0);
28 gl_FragData[3] = vary_position;
29} 27}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
index ba18092..9589912 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/bumpV.glsl
@@ -8,7 +8,6 @@
8varying vec3 vary_mat0; 8varying vec3 vary_mat0;
9varying vec3 vary_mat1; 9varying vec3 vary_mat1;
10varying vec3 vary_mat2; 10varying vec3 vary_mat2;
11varying vec4 vary_position;
12 11
13void main() 12void main()
14{ 13{
@@ -16,8 +15,6 @@ void main()
16 gl_Position = ftransform(); 15 gl_Position = ftransform();
17 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; 16 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
18 17
19 vary_position = gl_ModelViewMatrix * gl_Vertex;
20
21 vec3 n = normalize(gl_NormalMatrix * gl_Normal); 18 vec3 n = normalize(gl_NormalMatrix * gl_Normal);
22 vec3 b = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz); 19 vec3 b = normalize(gl_NormalMatrix * gl_MultiTexCoord2.xyz);
23 vec3 t = cross(b, n); 20 vec3 t = cross(b, n);
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
index f2ba2df..919dd5d 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseF.glsl
@@ -8,13 +8,11 @@
8uniform sampler2D diffuseMap; 8uniform sampler2D diffuseMap;
9 9
10varying vec3 vary_normal; 10varying vec3 vary_normal;
11varying vec4 vary_position;
12 11
13void main() 12void main()
14{ 13{
15 vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb; 14 vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
16 gl_FragData[0] = vec4(gl_Color.rgb*col, 1.0); 15 gl_FragData[0] = vec4(gl_Color.rgb*col, 1.0); // KL viewer 2.0 has 0.0 but this is not working right yet besides i like to see my eyes :)
17 gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a); 16 gl_FragData[1] = vec4(col*(gl_Color.a*1.5), gl_Color.a);
18 gl_FragData[2] = vec4(normalize(vary_normal), 0.0); 17 gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
19 gl_FragData[3] = vary_position;
20} 18}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
index 3413a7f..44468cd 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/diffuseV.glsl
@@ -6,16 +6,13 @@
6 */ 6 */
7 7
8varying vec3 vary_normal; 8varying vec3 vary_normal;
9varying vec4 vary_position;
10 9
11void main() 10void main()
12{ 11{
13 //transform vertex 12 //transform vertex
14 gl_Position = ftransform(); 13 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
15 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; 14 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
16 15
17 vary_position = gl_ModelViewMatrix * gl_Vertex;
18
19 vary_normal = normalize(gl_NormalMatrix * gl_Normal); 16 vary_normal = normalize(gl_NormalMatrix * gl_Normal);
20 17
21 gl_FrontColor = gl_Color; 18 gl_FrontColor = gl_Color;
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index 2a811c5..e518bdd 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -8,14 +8,9 @@
8#extension GL_ARB_texture_rectangle : enable 8#extension GL_ARB_texture_rectangle : enable
9 9
10uniform sampler2D diffuseMap; 10uniform sampler2D diffuseMap;
11uniform sampler2DShadow shadowMap0; 11uniform sampler2DRect depthMap;
12uniform sampler2DShadow shadowMap1;
13uniform sampler2DShadow shadowMap2;
14uniform sampler2DShadow shadowMap3;
15uniform sampler2D noiseMap; 12uniform sampler2D noiseMap;
16uniform sampler2DRect positionMap;
17 13
18uniform mat4 shadow_matrix[4];
19uniform vec4 shadow_clip; 14uniform vec4 shadow_clip;
20uniform vec2 screen_res; 15uniform vec2 screen_res;
21 16
@@ -30,12 +25,27 @@ varying vec3 vary_fragcoord;
30 25
31uniform float alpha_soften; 26uniform float alpha_soften;
32 27
28uniform mat4 inv_proj;
29
30vec4 getPosition(vec2 pos_screen)
31{
32 float depth = texture2DRect(depthMap, pos_screen.xy).a;
33 vec2 sc = pos_screen.xy*2.0;
34 sc /= screen_res;
35 sc -= vec2(1.0,1.0);
36 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
37 vec4 pos = inv_proj * ndc;
38 pos /= pos.w;
39 pos.w = 1.0;
40 return pos;
41}
42
33void main() 43void main()
34{ 44{
35 vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; 45 vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
36 frag *= screen_res; 46 frag *= screen_res;
37 47
38 vec3 samp_pos = texture2DRect(positionMap, frag).xyz; 48 vec3 samp_pos = getPosition(frag).xyz;
39 49
40 float shadow = 1.0; 50 float shadow = 1.0;
41 vec4 pos = vary_position; 51 vec4 pos = vary_position;
@@ -46,10 +56,10 @@ void main()
46 56
47 color.rgb = fullbrightScaleSoftClip(color.rgb); 57 color.rgb = fullbrightScaleSoftClip(color.rgb);
48 58
49 if (samp_pos.z != 0.0) 59 if (samp_pos.z != 0.0 && color.a < 1.0)
50 { 60 {
51 float dist_factor = alpha_soften; 61 float dist_factor = alpha_soften;
52 float a = gl_Color.a; 62 float a = color.a;
53 a *= a; 63 a *= a;
54 dist_factor *= 1.0/(1.0-a); 64 dist_factor *= 1.0/(1.0-a);
55 color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0); 65 color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0);
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl
index 6381a1c..aff5117 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/fullbrightV.glsl
@@ -12,12 +12,12 @@ vec3 atmosAffectDirectionalLight(float lightIntensity);
12vec3 scaleDownLight(vec3 light); 12vec3 scaleDownLight(vec3 light);
13vec3 scaleUpLight(vec3 light); 13vec3 scaleUpLight(vec3 light);
14 14
15varying vec4 vary_position;
16varying vec3 vary_ambient; 15varying vec3 vary_ambient;
17varying vec3 vary_directional; 16varying vec3 vary_directional;
18varying vec3 vary_normal; 17varying vec3 vary_normal;
19varying vec3 vary_fragcoord; 18varying vec3 vary_fragcoord;
20uniform float near_clip; 19uniform float near_clip;
20varying vec4 vary_position;
21 21
22void main() 22void main()
23{ 23{
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/giF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
new file mode 100644
index 0000000..b351eec
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/giF.glsl
@@ -0,0 +1,165 @@
1/**
2 * @file giF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#extension GL_ARB_texture_rectangle : enable
9
10uniform sampler2DRect depthMap;
11uniform sampler2DRect normalMap;
12uniform sampler2D noiseMap;
13
14uniform sampler2D diffuseGIMap;
15uniform sampler2D normalGIMap;
16uniform sampler2D depthGIMap;
17
18uniform sampler2D lightFunc;
19
20// Inputs
21varying vec2 vary_fragcoord;
22
23uniform vec2 screen_res;
24
25uniform mat4 inv_proj;
26uniform mat4 gi_mat; //gPipeline.mGIMatrix - eye space to sun space
27uniform mat4 gi_mat_proj; //gPipeline.mGIMatrixProj - eye space to projected sun space
28uniform mat4 gi_norm_mat; //gPipeline.mGINormalMatrix - eye space normal to sun space normal matrix
29uniform mat4 gi_inv_proj; //gPipeline.mGIInvProj - projected sun space to sun space
30uniform float gi_radius;
31uniform float gi_intensity;
32uniform int gi_samples;
33uniform vec2 gi_kern[25];
34uniform vec2 gi_scale;
35uniform vec3 gi_quad;
36uniform vec3 gi_spec;
37uniform float gi_direction_weight;
38uniform float gi_light_offset;
39
40vec4 getPosition(vec2 pos_screen)
41{
42 float depth = texture2DRect(depthMap, pos_screen.xy).a;
43 vec2 sc = pos_screen.xy*2.0;
44 sc /= screen_res;
45 sc -= vec2(1.0,1.0);
46 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
47 vec4 pos = inv_proj * ndc;
48 pos /= pos.w;
49 pos.w = 1.0;
50 return pos;
51}
52
53vec4 getGIPosition(vec2 gi_tc)
54{
55 float depth = texture2D(depthGIMap, gi_tc).a;
56 vec2 sc = gi_tc*2.0;
57 sc -= vec2(1.0, 1.0);
58 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
59 vec4 pos = gi_inv_proj*ndc;
60 pos.xyz /= pos.w;
61 pos.w = 1.0;
62 return pos;
63}
64
65vec3 giAmbient(vec3 pos, vec3 norm)
66{
67 vec4 gi_c = gi_mat_proj * vec4(pos, 1.0);
68 gi_c.xyz /= gi_c.w;
69
70 vec4 gi_pos = gi_mat*vec4(pos,1.0);
71 vec3 gi_norm = (gi_norm_mat*vec4(norm,1.0)).xyz;
72 gi_norm = normalize(gi_norm);
73
74 vec2 tcx = gi_norm.xy;
75 vec2 tcy = gi_norm.yx;
76
77 vec4 eye_pos = gi_mat*vec4(0,0,0,1.0);
78
79 vec3 eye_dir = normalize(gi_pos.xyz-eye_pos.xyz/eye_pos.w);
80
81 //vec3 eye_dir = vec3(0,0,-1);
82 //eye_dir = (gi_norm_mat*vec4(eye_dir, 1.0)).xyz;
83 //eye_dir = normalize(eye_dir);
84
85 //float round_x = gi_scale.x;
86 //float round_y = gi_scale.y;
87
88 vec3 debug = texture2D(normalGIMap, gi_c.xy).rgb*0.5+0.5;
89 debug.xz = vec2(0.0,0.0);
90 //debug = fract(debug);
91
92 float round_x = 1.0/64.0;
93 float round_y = 1.0/64.0;
94
95 //gi_c.x = floor(gi_c.x/round_x+0.5)*round_x;
96 //gi_c.y = floor(gi_c.y/round_y+0.5)*round_y;
97
98 float fda = 0.0;
99 vec3 fdiff = vec3(0,0,0);
100
101 vec3 rcol = vec3(0,0,0);
102
103 float fsa = 0.0;
104
105 for (int i = -1; i < 2; i+=2 )
106 {
107 for (int j = -1; j < 2; j+=2)
108 {
109 vec2 tc = vec2(i, j)*0.75;
110 vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0+tc*0.5).xyz;
111 //tc += gi_norm.xy*nz.z;
112 tc += nz.xy*2.0;
113 tc /= gi_samples;
114 tc += gi_c.xy;
115
116 vec3 lnorm = -normalize(texture2D(normalGIMap, tc.xy).xyz*2.0-1.0);
117 vec3 lpos = getGIPosition(tc.xy).xyz;
118
119 vec3 at = lpos-gi_pos.xyz;
120 float dist = dot(at,at);
121 float da = clamp(1.0/(gi_spec.x*dist), 0.0, 1.0);
122
123 if (da > 0.0)
124 {
125 //add angular attenuation
126 vec3 ldir = at;
127 float ang_atten = clamp(dot(ldir, gi_norm), 0.0, 1.0);
128
129 float ld = -dot(ldir, lnorm);
130
131 if (ang_atten > 0.0 && ld < 0.0)
132 {
133 vec3 diff = texture2D(diffuseGIMap, tc.xy).xyz;
134 da = da*ang_atten;
135 fda += da;
136 fdiff += diff*da;
137 }
138 }
139 }
140 }
141
142 fdiff /= max(gi_spec.y*fda, gi_quad.z);
143 fdiff = clamp(fdiff, vec3(0), vec3(1));
144
145 vec3 ret = fda*fdiff;
146 //ret = ret*ret*gi_quad.x+ret*gi_quad.y+gi_quad.z;
147
148 //fda *= nz.z;
149
150 //rcol.rgb *= gi_intensity;
151 //return rcol.rgb+vary_AmblitColor.rgb*0.25;
152 //return vec4(debug, 0.0);
153 //return vec4(fda*fdiff, 0.0);
154 return clamp(ret,vec3(0.0), vec3(1.0));
155 //return debug.xyz;
156}
157
158void main()
159{
160 vec2 pos_screen = vary_fragcoord.xy;
161 vec4 pos = getPosition(pos_screen);
162 vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
163
164 gl_FragData[0].xyz = giAmbient(pos, norm);
165}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/giV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/giV.glsl
new file mode 100644
index 0000000..71dcea9
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/giV.glsl
@@ -0,0 +1,22 @@
1/**
2 * @file giV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec2 vary_fragcoord;
9
10uniform vec2 screen_res;
11
12void main()
13{
14 //transform vertex
15 gl_Position = ftransform();
16 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
17 vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
18 vec4 tex = gl_MultiTexCoord0;
19 tex.w = 1.0;
20
21 gl_FrontColor = gl_Color;
22}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
new file mode 100644
index 0000000..e8b53b0
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceF.glsl
@@ -0,0 +1,15 @@
1/**
2 * @file luminanceF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect diffuseMap;
9
10varying vec2 vary_fragcoord;
11
12void main()
13{
14 gl_FragColor = texture2DRect(diffuseMap, vary_fragcoord.xy);
15}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
new file mode 100644
index 0000000..db8775f
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/luminanceV.glsl
@@ -0,0 +1,20 @@
1/**
2 * @file giV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec2 vary_fragcoord;
9
10uniform vec2 screen_res;
11
12void main()
13{
14 //transform vertex
15 gl_Position = ftransform();
16 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
17 vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
18
19 gl_FrontColor = gl_Color;
20}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index 3689d12..ce0494c 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -7,13 +7,15 @@
7 7
8#extension GL_ARB_texture_rectangle : enable 8#extension GL_ARB_texture_rectangle : enable
9 9
10uniform sampler2DRect depthMap;
10uniform sampler2DRect diffuseRect; 11uniform sampler2DRect diffuseRect;
11uniform sampler2DRect specularRect; 12uniform sampler2DRect specularRect;
12uniform sampler2DRect positionMap;
13uniform sampler2DRect normalMap; 13uniform sampler2DRect normalMap;
14uniform samplerCube environmentMap; 14uniform samplerCube environmentMap;
15uniform sampler2DRect lightMap; 15uniform sampler2DRect lightMap;
16uniform sampler2D noiseMap; 16uniform sampler2D noiseMap;
17uniform sampler2D lightFunc;
18
17 19
18uniform vec3 env_mat[3]; 20uniform vec3 env_mat[3];
19uniform float sun_wash; 21uniform float sun_wash;
@@ -23,24 +25,48 @@ uniform int light_count;
23uniform vec4 light[16]; 25uniform vec4 light[16];
24uniform vec4 light_col[16]; 26uniform vec4 light_col[16];
25 27
26varying vec3 vary_fragcoord; 28varying vec4 vary_fragcoord;
27uniform vec2 screen_res; 29uniform vec2 screen_res;
28 30
31uniform float far_z;
32
33uniform mat4 inv_proj;
34
35vec4 getPosition(vec2 pos_screen)
36{
37 float depth = texture2DRect(depthMap, pos_screen.xy).a;
38 vec2 sc = pos_screen.xy*2.0;
39 sc /= screen_res;
40 sc -= vec2(1.0,1.0);
41 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
42 vec4 pos = inv_proj * ndc;
43 pos /= pos.w;
44 pos.w = 1.0;
45 return pos;
46}
47
29void main() 48void main()
30{ 49{
31 vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res; 50 vec2 frag = (vary_fragcoord.xy*0.5+0.5)*screen_res;
32 vec3 pos = texture2DRect(positionMap, frag.xy).xyz; 51 vec3 pos = getPosition(frag.xy).xyz;
33 vec3 norm = normalize(texture2DRect(normalMap, frag.xy).xyz); 52 if (pos.z < far_z)
53 {
54 discard;
55 }
56
57 vec3 norm = normalize(texture2DRect(normalMap, frag.xy).xyz*2.0-1.0);
34 vec4 spec = texture2DRect(specularRect, frag.xy); 58 vec4 spec = texture2DRect(specularRect, frag.xy);
35 vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb; 59 vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb;
36 float noise = texture2D(noiseMap, frag.xy/128.0).b; 60 float noise = texture2D(noiseMap, frag.xy/128.0).b;
37 vec3 out_col = vec3(0,0,0); 61 vec3 out_col = vec3(0,0,0);
62 vec3 npos = normalize(-pos);
38 63
39 for (int i = 0; i < light_count; ++i) 64 for (int i = 0; i < light_count; ++i)
40 { 65 {
41 vec3 lv = light[i].xyz-pos; 66 vec3 lv = light[i].xyz-pos;
42 float dist2 = dot(lv,lv); 67 float dist2 = dot(lv,lv);
43 if (dist2 > light[i].w) 68 dist2 /= light[i].w;
69 if (dist2 > 1.0)
44 { 70 {
45 continue; 71 continue;
46 } 72 }
@@ -55,29 +81,41 @@ void main()
55 da = dot(norm, lv); 81 da = dot(norm, lv);
56 82
57 float fa = light_col[i].a+1.0; 83 float fa = light_col[i].a+1.0;
58 float dist_atten = clamp(1.0-(dist2-light[i].w*(1.0-fa))/(light[i].w*fa), 0.0, 1.0); 84 float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
59 dist_atten *= noise; 85 dist_atten *= noise;
60 86
61 float lit = da * dist_atten; 87 float lit = da * dist_atten;
62 88
63 vec3 col = light_col[i].rgb*lit*diff; 89 vec3 col = light_col[i].rgb*lit*diff;
90 //vec3 col = vec3(dist2, light_col[i].a, lit);
64 91
65 if (spec.a > 0.0) 92 if (spec.a > 0.0)
66 { 93 {
67 vec3 ref = reflect(normalize(pos), norm); 94 //vec3 ref = dot(pos+lv, norm);
68 float sa = dot(ref,lv); 95
69 sa = max(sa, 0.0); 96 float sa = dot(normalize(lv+npos),norm);
70 sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0); 97
71 sa *= noise; 98 if (sa > 0)
72 col += da*sa*light_col[i].rgb*spec.rgb; 99 {
100 sa = texture2D(lightFunc,vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
101 sa *= noise;
102 col += da*sa*light_col[i].rgb*spec.rgb;
103 }
73 } 104 }
74 105
75 out_col += col; 106 out_col += col;
76 } 107 }
77 108
109 if (dot(out_col, out_col) <= 0.0)
110 {
111 discard;
112 }
113
78 //attenuate point light contribution by SSAO component 114 //attenuate point light contribution by SSAO component
79 out_col *= texture2DRect(lightMap, frag.xy).g; 115 out_col *= texture2DRect(lightMap, frag.xy).g;
80 116
81 gl_FragColor.rgb = out_col; 117 gl_FragColor.rgb = out_col;
82 gl_FragColor.a = 0.0; 118 gl_FragColor.a = 0.0;
119
120 //gl_FragColor = vec4(0.1, 0.025, 0.025/4.0, 0.0);
83} 121}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
new file mode 100644
index 0000000..021e8a2
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -0,0 +1,184 @@
1/**
2 * @file multiSpotLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#version 120
9
10#extension GL_ARB_texture_rectangle : enable
11
12uniform sampler2DRect diffuseRect;
13uniform sampler2DRect specularRect;
14uniform sampler2DRect depthMap;
15uniform sampler2DRect normalMap;
16uniform samplerCube environmentMap;
17uniform sampler2DRect lightMap;
18uniform sampler2D noiseMap;
19uniform sampler2D lightFunc;
20uniform sampler2D projectionMap;
21
22uniform mat4 proj_mat; //screen space to light space
23uniform float proj_near; //near clip for projection
24uniform vec3 proj_p; //plane projection is emitting from (in screen space)
25uniform vec3 proj_n;
26uniform float proj_focus; //distance from plane to begin blurring
27uniform float proj_lod; //(number of mips in proj map)
28uniform float proj_range; //range between near clip and far clip plane of projection
29uniform float proj_ambient_lod;
30uniform float proj_ambiance;
31uniform float near_clip;
32uniform float far_clip;
33
34uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
35uniform float sun_wash;
36uniform int proj_shadow_idx;
37uniform float shadow_fade;
38
39varying vec4 vary_light;
40
41varying vec4 vary_fragcoord;
42uniform vec2 screen_res;
43
44uniform mat4 inv_proj;
45
46vec4 getPosition(vec2 pos_screen)
47{
48 float depth = texture2DRect(depthMap, pos_screen.xy).a;
49 vec2 sc = pos_screen.xy*2.0;
50 sc /= screen_res;
51 sc -= vec2(1.0,1.0);
52 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
53 vec4 pos = inv_proj * ndc;
54 pos /= pos.w;
55 pos.w = 1.0;
56 return pos;
57}
58
59void main()
60{
61 vec4 frag = vary_fragcoord;
62 frag.xyz /= frag.w;
63 frag.xyz = frag.xyz*0.5+0.5;
64 frag.xy *= screen_res;
65
66 vec3 pos = getPosition(frag.xy).xyz;
67 vec3 lv = vary_light.xyz-pos.xyz;
68 float dist2 = dot(lv,lv);
69 dist2 /= vary_light.w;
70 if (dist2 > 1.0)
71 {
72 discard;
73 }
74
75 float shadow = 1.0;
76
77 if (proj_shadow_idx >= 0)
78 {
79 vec4 shd = texture2DRect(lightMap, frag.xy);
80 float sh[2];
81 sh[0] = shd.b;
82 sh[1] = shd.a;
83 shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
84 }
85
86 vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
87
88 norm = normalize(norm);
89 float l_dist = -dot(lv, proj_n);
90
91 vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
92 if (proj_tc.z < 0.0)
93 {
94 discard;
95 }
96
97 proj_tc.xyz /= proj_tc.w;
98
99 float fa = gl_Color.a+1.0;
100 float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
101
102 lv = proj_origin-pos.xyz;
103 lv = normalize(lv);
104 float da = dot(norm, lv);
105
106 vec3 col = vec3(0,0,0);
107
108 vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
109
110 float noise = texture2D(noiseMap, frag.xy/128.0).b;
111 if (proj_tc.z > 0.0 &&
112 proj_tc.x < 1.0 &&
113 proj_tc.y < 1.0 &&
114 proj_tc.x > 0.0 &&
115 proj_tc.y > 0.0)
116 {
117 float lit = 0.0;
118 float amb_da = proj_ambiance;
119
120 if (da > 0.0)
121 {
122 float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
123 float lod = diff * proj_lod;
124
125 vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
126
127 vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a;
128
129 lit = da * dist_atten * noise;
130
131 col = lcol*lit*diff_tex*shadow;
132 amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
133 }
134
135 //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
136 vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, proj_ambient_lod);
137
138 amb_da += (da*da*0.5+0.5)*proj_ambiance;
139
140 amb_da *= dist_atten * noise;
141
142 amb_da = min(amb_da, 1.0-lit);
143
144 col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
145 }
146
147
148 vec4 spec = texture2DRect(specularRect, frag.xy);
149 if (spec.a > 0.0)
150 {
151 vec3 ref = reflect(normalize(pos), norm);
152
153 //project from point pos in direction ref to plane proj_p, proj_n
154 vec3 pdelta = proj_p-pos;
155 float ds = dot(ref, proj_n);
156
157 if (ds < 0.0)
158 {
159 vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
160
161 vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
162
163 if (stc.z > 0.0)
164 {
165 stc.xy /= stc.w;
166
167 if (stc.x < 1.0 &&
168 stc.y < 1.0 &&
169 stc.x > 0.0 &&
170 stc.y > 0.0)
171 {
172 vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
173 col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow;
174 }
175 }
176 }
177 }
178
179 //attenuate point light contribution by SSAO component
180 col *= texture2DRect(lightMap, frag.xy).g;
181
182 gl_FragColor.rgb = col;
183 gl_FragColor.a = 0.0;
184}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
index 52bad1f..d8ccfd4 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl
@@ -9,33 +9,54 @@
9 9
10uniform sampler2DRect diffuseRect; 10uniform sampler2DRect diffuseRect;
11uniform sampler2DRect specularRect; 11uniform sampler2DRect specularRect;
12uniform sampler2DRect positionMap;
13uniform sampler2DRect normalMap; 12uniform sampler2DRect normalMap;
14uniform samplerCube environmentMap; 13uniform samplerCube environmentMap;
15uniform sampler2DRect lightMap; 14uniform sampler2DRect lightMap;
16uniform sampler2D noiseMap; 15uniform sampler2D noiseMap;
16uniform sampler2D lightFunc;
17uniform sampler2DRect depthMap;
17 18
18uniform vec3 env_mat[3]; 19uniform vec3 env_mat[3];
19uniform float sun_wash; 20uniform float sun_wash;
20 21
21varying vec4 vary_light; 22varying vec4 vary_light;
22 23
23varying vec3 vary_fragcoord; 24varying vec4 vary_fragcoord;
24uniform vec2 screen_res; 25uniform vec2 screen_res;
25 26
27uniform mat4 inv_proj;
28uniform vec4 viewport;
29
30vec4 getPosition(vec2 pos_screen)
31{
32 float depth = texture2DRect(depthMap, pos_screen.xy).a;
33 vec2 sc = (pos_screen.xy-viewport.xy)*2.0;
34 sc /= viewport.zw;
35 sc -= vec2(1.0,1.0);
36 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
37 vec4 pos = inv_proj * ndc;
38 pos /= pos.w;
39 pos.w = 1.0;
40 return pos;
41}
42
26void main() 43void main()
27{ 44{
28 vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5; 45 vec4 frag = vary_fragcoord;
29 frag *= screen_res; 46 frag.xyz /= frag.w;
30 vec3 pos = texture2DRect(positionMap, frag).xyz; 47 frag.xyz = frag.xyz*0.5+0.5;
48 frag.xy *= screen_res;
49
50 vec3 pos = getPosition(frag.xy).xyz;
31 vec3 lv = vary_light.xyz-pos; 51 vec3 lv = vary_light.xyz-pos;
32 float dist2 = dot(lv,lv); 52 float dist2 = dot(lv,lv);
33 if (dist2 > vary_light.w) 53 dist2 /= vary_light.w;
54 if (dist2 > 1.0)
34 { 55 {
35 discard; 56 discard;
36 } 57 }
37 58
38 vec3 norm = texture2DRect(normalMap, frag).xyz; 59 vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
39 float da = dot(norm, lv); 60 float da = dot(norm, lv);
40 if (da < 0.0) 61 if (da < 0.0)
41 { 62 {
@@ -46,24 +67,30 @@ void main()
46 lv = normalize(lv); 67 lv = normalize(lv);
47 da = dot(norm, lv); 68 da = dot(norm, lv);
48 69
49 float noise = texture2D(noiseMap, frag/128.0).b; 70 float noise = texture2D(noiseMap, frag.xy/128.0).b;
50 71
51 vec3 col = texture2DRect(diffuseRect, frag).rgb; 72 vec3 col = texture2DRect(diffuseRect, frag.xy).rgb;
52 float fa = gl_Color.a+1.0; 73 float fa = gl_Color.a+1.0;
53 float dist_atten = clamp(1.0-(dist2-vary_light.w*(1.0-fa))/(vary_light.w*fa), 0.0, 1.0); 74 float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
54 float lit = da * dist_atten * noise; 75 float lit = da * dist_atten * noise;
55 76
56 col = gl_Color.rgb*lit*col; 77 col = gl_Color.rgb*lit*col;
57 78
58 vec4 spec = texture2DRect(specularRect, frag); 79 vec4 spec = texture2DRect(specularRect, frag.xy);
59 if (spec.a > 0.0) 80 if (spec.a > 0.0)
60 { 81 {
61 vec3 ref = reflect(normalize(pos), norm); 82 float sa = dot(normalize(lv-normalize(pos)),norm);
62 float sa = dot(ref,lv); 83 if (sa > 0.0)
63 sa = max(sa, 0.0); 84 {
64 sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0); 85 sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
65 sa *= noise; 86 sa *= noise;
66 col += da*sa*gl_Color.rgb*spec.rgb; 87 col += da*sa*gl_Color.rgb*spec.rgb;
88 }
89 }
90
91 if (dot(col, col) <= 0.0)
92 {
93 discard;
67 } 94 }
68 95
69 //attenuate point light contribution by SSAO component 96 //attenuate point light contribution by SSAO component
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
index a4edb88..e815ca2 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/pointLightV.glsl
@@ -6,7 +6,7 @@
6 */ 6 */
7 7
8varying vec4 vary_light; 8varying vec4 vary_light;
9varying vec3 vary_fragcoord; 9varying vec4 vary_fragcoord;
10 10
11uniform vec2 screen_res; 11uniform vec2 screen_res;
12uniform float near_clip; 12uniform float near_clip;
@@ -14,10 +14,10 @@ uniform float near_clip;
14void main() 14void main()
15{ 15{
16 //transform vertex 16 //transform vertex
17 gl_Position = ftransform(); 17 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
18 18
19 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex; 19 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
20 vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip); 20 vary_fragcoord = pos;
21 21
22 vec4 tex = gl_MultiTexCoord0; 22 vec4 tex = gl_MultiTexCoord0;
23 tex.w = 1.0; 23 tex.w = 1.0;
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
new file mode 100644
index 0000000..71de036
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredF.glsl
@@ -0,0 +1,57 @@
1/**
2 * @file postDeferredF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#extension GL_ARB_texture_rectangle : enable
9
10uniform sampler2DRect diffuseRect;
11uniform sampler2DRect localLightMap;
12uniform sampler2DRect sunLightMap;
13uniform sampler2DRect giLightMap;
14uniform sampler2D luminanceMap;
15uniform sampler2DRect lightMap;
16
17uniform vec3 lum_quad;
18uniform float lum_lod;
19uniform vec4 ambient;
20
21uniform vec3 gi_quad;
22
23uniform vec2 screen_res;
24varying vec2 vary_fragcoord;
25
26void main()
27{
28 vec2 tc = vary_fragcoord.xy;
29 vec3 lum = texture2DLod(luminanceMap, tc/screen_res, lum_lod).rgb;
30 float luminance = lum.r;
31 luminance = luminance*lum_quad.y+lum_quad.z;
32
33 vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
34
35 float ambocc = texture2DRect(lightMap, vary_fragcoord.xy).g;
36
37 vec3 gi_col = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
38 gi_col = gi_col*gi_col*gi_quad.x + gi_col*gi_quad.y+gi_quad.z*ambocc*ambient.rgb;
39 gi_col *= diff;
40
41 vec4 sun_col = texture2DRect(sunLightMap, vary_fragcoord.xy);
42
43 vec3 local_col = texture2DRect(localLightMap, vary_fragcoord.xy).rgb;
44
45
46 sun_col *= 1.0/min(luminance, 1.0);
47 gi_col *= 1.0/luminance;
48
49 vec3 col = sun_col.rgb+gi_col+local_col;
50
51 gl_FragColor.rgb = col.rgb;
52 col.rgb = max(col.rgb-vec3(1.0,1.0,1.0), vec3(0.0, 0.0, 0.0));
53
54 gl_FragColor.a = 0.0; // max(dot(col.rgb,col.rgb)*lum_quad.x, sun_col.a);
55
56 //gl_FragColor.rgb = vec3(lum_lod);
57}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
new file mode 100644
index 0000000..9819232
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postDeferredV.glsl
@@ -0,0 +1,17 @@
1/**
2 * @file postDeferredV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec2 vary_fragcoord;
9uniform vec2 screen_res;
10
11void main()
12{
13 //transform vertex
14 gl_Position = ftransform();
15 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
16 vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
17}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
new file mode 100644
index 0000000..3556c7b
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiF.glsl
@@ -0,0 +1,107 @@
1/**
2 * @file postgiF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2D diffuseGIMap;
9uniform sampler2D normalGIMap;
10uniform sampler2D depthGIMap;
11uniform sampler2D diffuseMap;
12
13uniform sampler2D lastDiffuseGIMap;
14uniform sampler2D lastNormalGIMap;
15uniform sampler2D lastMinpGIMap;
16uniform sampler2D lastMaxpGIMap;
17
18uniform float gi_blend;
19
20uniform mat4 gi_mat; //gPipeline.mGIMatrix - eye space to sun space
21uniform mat4 gi_mat_proj; //gPipeline.mGIMatrixProj - eye space to projected sun space
22uniform mat4 gi_norm_mat; //gPipeline.mGINormalMatrix - eye space normal to sun space normal matrix
23uniform mat4 gi_inv_proj; //gPipeline.mGIInvProj - projected sun space to sun space
24uniform float gi_radius;
25uniform float gi_intensity;
26uniform vec2 gi_kern[16];
27uniform vec2 gi_scale;
28
29
30vec4 getGIPosition(vec2 gi_tc)
31{
32 float depth = texture2D(depthGIMap, gi_tc).a;
33 vec2 sc = gi_tc*2.0;
34 sc -= vec2(1.0, 1.0);
35 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
36 vec4 pos = gi_inv_proj*ndc;
37 pos.xyz /= pos.w;
38 pos.w = 1.0;
39 return pos;
40}
41
42
43void main()
44{
45 vec2 c_tc = gl_TexCoord[0].xy;
46
47 vec3 diff = vec3(0,0,0);
48 vec3 minp = vec3(1024,1024,1024);
49 vec3 maxp = vec3(-1024,-1024,-1024);
50 vec3 norm = vec3(0,0,0);
51
52 float dweight = 0.0;
53
54 vec3 cnorm = normalize(texture2D(normalGIMap, c_tc).rgb*2.0-1.0);
55
56 vec3 cpos = vec3(0,0,0);
57 float tweight = 0.0;
58
59 for (int i = 0; i < 8; ++i)
60 {
61 for (int j = 0; j < 8; ++j)
62 {
63 vec2 tc = vec2(i-4+0.5, j-4+0.5);
64 float weight = 1.0-length(tc)/6.0;
65 tc *= 1.0/(256.0);
66 tc += c_tc;
67
68 vec3 n = texture2D(normalGIMap, tc).rgb*2.0-1.0;
69 tweight += weight;
70
71 diff += weight*texture2D(diffuseGIMap, tc).rgb;
72
73 norm += n*weight;
74
75 dweight += dot(n, cnorm);
76
77 vec3 pos = getGIPosition(tc).xyz;
78 cpos += pos*weight;
79
80 minp = min(pos, minp);
81 maxp = max(pos, maxp);
82 }
83 }
84
85 dweight = abs(1.0-dweight/64.0);
86 float mind = min(sqrt(dweight+0.5), 1.0);
87
88 dweight *= dweight;
89
90 cpos /= tweight;
91
92 diff = clamp(diff/tweight, vec3(1.0/2.2), vec3(1,1,1));
93 norm = normalize(norm);
94 maxp = cpos;
95 minp = vec3(dweight, mind, cpos.z-minp.z);
96
97 //float blend = 1.0;
98 //diff = mix(texture2D(lastDiffuseGIMap, c_tc).rgb, diff, blend);
99 //norm = mix(texture2D(lastNormalGIMap, c_tc).rgb, norm, blend);
100 //maxp = mix(texture2D(lastMaxpGIMap, c_tc).rgb, maxp, blend);
101 //minp = mix(texture2D(lastMinpGIMap, c_tc).rgb, minp, blend);
102
103 gl_FragData[0].rgb = diff;
104 gl_FragData[2].xyz = normalize(norm);
105 gl_FragData[1].xyz = maxp;
106 gl_FragData[3].xyz = minp;
107}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl
new file mode 100644
index 0000000..5a8eb65
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/postgiV.glsl
@@ -0,0 +1,16 @@
1/**
2 * @file postgiV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec3 vary_normal;
9
10void main()
11{
12 //transform vertex
13 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
14 gl_Position = pos;
15 gl_TexCoord[0].xy = pos.xy*0.5+0.5;
16}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
index b3758c3..b0b31fd 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowF.glsl
@@ -7,8 +7,11 @@
7 7
8uniform sampler2D diffuseMap; 8uniform sampler2D diffuseMap;
9 9
10varying vec4 post_pos;
10 11
11void main() 12void main()
12{ 13{
13 gl_FragColor = vec4(1,1,1,texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a); 14 gl_FragColor = vec4(1,1,1,texture2D(diffuseMap, gl_TexCoord[0].xy).a * gl_Color.a);
15
16 gl_FragDepth = max(post_pos.z/post_pos.w*0.5+0.5, 0.0);
14} 17}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
index aae1bee..7214d24 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/shadowV.glsl
@@ -5,13 +5,17 @@
5 * $License$ 5 * $License$
6 */ 6 */
7 7
8varying vec4 post_pos;
9
8void main() 10void main()
9{ 11{
10 //transform vertex 12 //transform vertex
11 vec4 pos = gl_ModelViewProjectionMatrix*gl_Vertex; 13 vec4 pos = gl_ModelViewProjectionMatrix*gl_Vertex;
12 //smash geometry against the near clip plane (great for ortho projections) 14
13 pos.z = max(pos.z, -1.0); 15 post_pos = pos;
14 gl_Position = pos; 16
17 gl_Position = vec4(pos.x, pos.y, pos.w*0.5, pos.w);
18
15 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; 19 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
16 gl_FrontColor = gl_Color; 20 gl_FrontColor = gl_Color;
17} 21}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
index d5671a6..64e263a 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl
@@ -272,8 +272,4 @@ void main()
272 272
273 gl_FragColor.rgb = col; 273 gl_FragColor.rgb = col;
274 gl_FragColor.a = 0.0; 274 gl_FragColor.a = 0.0;
275 //gl_FragColor.rg = scol_ambocc.rg;
276 //gl_FragColor.rgb = norm.rgb*0.5+0.5;
277 //gl_FragColor.rgb = vec3(ambocc);
278 //gl_FragColor.rgb = vec3(scol);
279} 275}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
new file mode 100644
index 0000000..d653408
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl
@@ -0,0 +1,199 @@
1/**
2 * @file spotLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#version 120
9
10#extension GL_ARB_texture_rectangle : enable
11
12uniform sampler2DRect diffuseRect;
13uniform sampler2DRect specularRect;
14uniform sampler2DRect depthMap;
15uniform sampler2DRect normalMap;
16uniform samplerCube environmentMap;
17uniform sampler2DRect lightMap;
18uniform sampler2D noiseMap;
19uniform sampler2D lightFunc;
20uniform sampler2D projectionMap;
21
22uniform mat4 proj_mat; //screen space to light space
23uniform float proj_near; //near clip for projection
24uniform vec3 proj_p; //plane projection is emitting from (in screen space)
25uniform vec3 proj_n;
26uniform float proj_focus; //distance from plane to begin blurring
27uniform float proj_lod; //(number of mips in proj map)
28uniform float proj_range; //range between near clip and far clip plane of projection
29uniform float proj_ambiance;
30uniform float near_clip;
31uniform float far_clip;
32
33uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
34uniform float sun_wash;
35uniform int proj_shadow_idx;
36uniform float shadow_fade;
37
38varying vec4 vary_light;
39
40varying vec4 vary_fragcoord;
41uniform vec2 screen_res;
42
43uniform mat4 inv_proj;
44
45vec4 getPosition(vec2 pos_screen)
46{
47 float depth = texture2DRect(depthMap, pos_screen.xy).a;
48 vec2 sc = pos_screen.xy*2.0;
49 sc /= screen_res;
50 sc -= vec2(1.0,1.0);
51 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
52 vec4 pos = inv_proj * ndc;
53 pos /= pos.w;
54 pos.w = 1.0;
55 return pos;
56}
57
58void main()
59{
60 vec4 frag = vary_fragcoord;
61 frag.xyz /= frag.w;
62 frag.xyz = frag.xyz*0.5+0.5;
63 frag.xy *= screen_res;
64
65 float shadow = 1.0;
66
67 if (proj_shadow_idx >= 0)
68 {
69 vec4 shd = texture2DRect(lightMap, frag.xy);
70 float sh[2];
71 sh[0] = shd.b;
72 sh[1] = shd.a;
73 shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
74 }
75
76 vec3 pos = getPosition(frag.xy).xyz;
77 vec3 lv = vary_light.xyz-pos.xyz;
78 float dist2 = dot(lv,lv);
79 dist2 /= vary_light.w;
80 if (dist2 > 1.0)
81 {
82 discard;
83 }
84
85 vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
86
87 norm = normalize(norm);
88 float l_dist = -dot(lv, proj_n);
89
90 vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
91 if (proj_tc.z < 0.0)
92 {
93 discard;
94 }
95
96 proj_tc.xyz /= proj_tc.w;
97
98 float fa = gl_Color.a+1.0;
99 float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
100
101 lv = proj_origin-pos.xyz;
102 lv = normalize(lv);
103 float da = dot(norm, lv);
104
105 vec3 col = vec3(0,0,0);
106
107 vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
108
109 float noise = texture2D(noiseMap, frag.xy/128.0).b;
110 if (proj_tc.z > 0.0 &&
111 proj_tc.x < 1.0 &&
112 proj_tc.y < 1.0 &&
113 proj_tc.x > 0.0 &&
114 proj_tc.y > 0.0)
115 {
116 float lit = 0.0;
117 if (da > 0.0)
118 {
119 float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
120 float lod = diff * proj_lod;
121
122 vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
123
124 vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a;
125
126 lit = da * dist_atten * noise;
127
128 col = lcol*lit*diff_tex*shadow;
129 }
130
131 float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
132 float lod = diff * proj_lod;
133 vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
134 //float amb_da = mix(proj_ambiance, proj_ambiance*max(-da, 0.0), max(da, 0.0));
135 float amb_da = proj_ambiance;
136 if (da > 0.0)
137 {
138 amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
139 }
140
141 amb_da += (da*da*0.5+0.5)*proj_ambiance;
142
143 amb_da *= dist_atten * noise;
144
145 amb_da = min(amb_da, 1.0-lit);
146
147 col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
148 }
149
150
151 vec4 spec = texture2DRect(specularRect, frag.xy);
152 if (spec.a > 0.0)
153 {
154 vec3 ref = reflect(normalize(pos), norm);
155
156 //project from point pos in direction ref to plane proj_p, proj_n
157 vec3 pdelta = proj_p-pos;
158 float ds = dot(ref, proj_n);
159
160 if (ds < 0.0)
161 {
162 vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
163
164 vec3 stc = (proj_mat * vec4(pfinal.xyz, 1.0)).xyz;
165
166 if (stc.z > 0.0)
167 {
168 stc.xy /= stc.z+proj_near;
169
170 if (stc.x < 1.0 &&
171 stc.y < 1.0 &&
172 stc.x > 0.0 &&
173 stc.y > 0.0)
174 {
175 vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
176 col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow;
177 }
178 }
179 }
180 }
181
182 /*if (spec.a > 0.0)
183 {
184 //vec3 ref = reflect(normalize(pos), norm);
185 float sa = dot(normalize(lv-normalize(pos)),norm);;
186 //sa = max(sa, 0.0);
187 //sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
188 sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
189 sa *= noise;
190 col += da*sa*lcol*spec.rgb;
191 }*/
192
193 //attenuate point light contribution by SSAO component
194 col *= texture2DRect(lightMap, frag.xy).g;
195
196
197 gl_FragColor.rgb = col;
198 gl_FragColor.a = 0.0;
199}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
index d43fe6c..22bdd2c 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/sunLightF.glsl
@@ -7,17 +7,21 @@
7 7
8#extension GL_ARB_texture_rectangle : enable 8#extension GL_ARB_texture_rectangle : enable
9 9
10uniform sampler2DRect positionMap;
11uniform sampler2DRect normalMap;
12uniform sampler2DRect depthMap; 10uniform sampler2DRect depthMap;
13uniform sampler2DShadow shadowMap0; 11uniform sampler2DRect normalMap;
14uniform sampler2DShadow shadowMap1; 12uniform sampler2DRectShadow shadowMap0;
15uniform sampler2DShadow shadowMap2; 13uniform sampler2DRectShadow shadowMap1;
16uniform sampler2DShadow shadowMap3; 14uniform sampler2DRectShadow shadowMap2;
15uniform sampler2DRectShadow shadowMap3;
16uniform sampler2DRectShadow shadowMap4;
17uniform sampler2DRectShadow shadowMap5;
17uniform sampler2D noiseMap; 18uniform sampler2D noiseMap;
18 19
20uniform sampler2D lightFunc;
21
22
19// Inputs 23// Inputs
20uniform mat4 shadow_matrix[4]; 24uniform mat4 shadow_matrix[6];
21uniform vec4 shadow_clip; 25uniform vec4 shadow_clip;
22uniform float ssao_radius; 26uniform float ssao_radius;
23uniform float ssao_max_radius; 27uniform float ssao_max_radius;
@@ -27,6 +31,25 @@ uniform float ssao_factor_inv;
27varying vec2 vary_fragcoord; 31varying vec2 vary_fragcoord;
28varying vec4 vary_light; 32varying vec4 vary_light;
29 33
34uniform mat4 inv_proj;
35uniform vec2 screen_res;
36
37uniform float shadow_bias;
38uniform float shadow_offset;
39
40vec4 getPosition(vec2 pos_screen)
41{
42 float depth = texture2DRect(depthMap, pos_screen.xy).a;
43 vec2 sc = pos_screen.xy*2.0;
44 sc /= screen_res;
45 sc -= vec2(1.0,1.0);
46 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
47 vec4 pos = inv_proj * ndc;
48 pos /= pos.w;
49 pos.w = 1.0;
50 return pos;
51}
52
30//calculate decreases in ambient lighting when crowded out (SSAO) 53//calculate decreases in ambient lighting when crowded out (SSAO)
31float calcAmbientOcclusion(vec4 pos, vec3 norm) 54float calcAmbientOcclusion(vec4 pos, vec3 norm)
32{ 55{
@@ -54,7 +77,7 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm)
54 for (int i = 0; i < 8; i++) 77 for (int i = 0; i < 8; i++)
55 { 78 {
56 vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect); 79 vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
57 vec3 samppos_world = texture2DRect(positionMap, samppos_screen).xyz; 80 vec3 samppos_world = getPosition(samppos_screen).xyz;
58 81
59 vec3 diff = pos_world - samppos_world; 82 vec3 diff = pos_world - samppos_world;
60 float dist2 = dot(diff, diff); 83 float dist2 = dot(diff, diff);
@@ -74,14 +97,18 @@ float calcAmbientOcclusion(vec4 pos, vec3 norm)
74 97
75 angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0); 98 angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
76 99
77 return 1.0 - (float(points != 0) * angle_hidden); 100 return (1.0 - (float(points != 0) * angle_hidden));
78} 101}
79 102
80void main() 103void main()
81{ 104{
82 vec2 pos_screen = vary_fragcoord.xy; 105 vec2 pos_screen = vary_fragcoord.xy;
83 vec4 pos = vec4(texture2DRect(positionMap, pos_screen).xyz, 1.0); 106
84 vec3 norm = texture2DRect(normalMap, pos_screen).xyz; 107 //try doing an unproject here
108
109 vec4 pos = getPosition(pos_screen);
110
111 vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
85 112
86 /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL 113 /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
87 { 114 {
@@ -90,35 +117,45 @@ void main()
90 }*/ 117 }*/
91 118
92 float shadow = 1.0; 119 float shadow = 1.0;
93 float dp_directional_light = max(0.0, dot(norm, vary_light.xyz)); 120 float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
94 121
122 vec4 spos = vec4(pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias), 1.0);
123
124 //vec3 debug = vec3(0,0,0);
125
95 if (dp_directional_light == 0.0) 126 if (dp_directional_light == 0.0)
96 { 127 {
97 // 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 128 // 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
98 shadow = 0.0; 129 shadow = 0.0;
99 } 130 }
100 else if (pos.z > -shadow_clip.w) 131 else if (spos.z > -shadow_clip.w)
101 { 132 {
102 if (pos.z < -shadow_clip.z) 133 vec4 lpos;
134
135 if (spos.z < -shadow_clip.z)
103 { 136 {
104 vec4 lpos = shadow_matrix[3]*pos; 137 lpos = shadow_matrix[3]*spos;
105 shadow = shadow2DProj(shadowMap3, lpos).x; 138 lpos.xy *= screen_res;
139 shadow = shadow2DRectProj(shadowMap3, lpos).x;
106 shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); 140 shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
107 } 141 }
108 else if (pos.z < -shadow_clip.y) 142 else if (spos.z < -shadow_clip.y)
109 { 143 {
110 vec4 lpos = shadow_matrix[2]*pos; 144 lpos = shadow_matrix[2]*spos;
111 shadow = shadow2DProj(shadowMap2, lpos).x; 145 lpos.xy *= screen_res;
146 shadow = shadow2DRectProj(shadowMap2, lpos).x;
112 } 147 }
113 else if (pos.z < -shadow_clip.x) 148 else if (spos.z < -shadow_clip.x)
114 { 149 {
115 vec4 lpos = shadow_matrix[1]*pos; 150 lpos = shadow_matrix[1]*spos;
116 shadow = shadow2DProj(shadowMap1, lpos).x; 151 lpos.xy *= screen_res;
152 shadow = shadow2DRectProj(shadowMap1, lpos).x;
117 } 153 }
118 else 154 else
119 { 155 {
120 vec4 lpos = shadow_matrix[0]*pos; 156 lpos = shadow_matrix[0]*spos;
121 shadow = shadow2DProj(shadowMap0, lpos).x; 157 lpos.xy *= screen_res;
158 shadow = shadow2DRectProj(shadowMap0, lpos).x;
122 } 159 }
123 160
124 // take the most-shadowed value out of these two: 161 // take the most-shadowed value out of these two:
@@ -126,6 +163,17 @@ void main()
126 // * an unblurred dot product between the sun and this norm 163 // * an unblurred dot product between the sun and this norm
127 // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting 164 // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting
128 shadow = min(shadow, dp_directional_light); 165 shadow = min(shadow, dp_directional_light);
166
167 /*debug.r = lpos.y / (lpos.w*screen_res.y);
168
169 lpos.xy /= lpos.w*32.0;
170 if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1)
171 {
172 debug.gb = vec2(0.5, 0.5);
173 }
174
175 debug += (1.0-shadow)*0.5;*/
176
129 } 177 }
130 else 178 else
131 { 179 {
@@ -135,5 +183,18 @@ void main()
135 183
136 gl_FragColor[0] = shadow; 184 gl_FragColor[0] = shadow;
137 gl_FragColor[1] = calcAmbientOcclusion(pos, norm); 185 gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
138 //gl_FragColor[2] is unused as of August 2008, may be used for debugging 186
187 //spotlight shadow 1
188 vec4 lpos = shadow_matrix[4]*spos;
189 lpos.xy *= screen_res;
190 gl_FragColor[2] = shadow2DRectProj(shadowMap4, lpos).x;
191
192 //spotlight shadow 2
193 lpos = shadow_matrix[5]*spos;
194 lpos.xy *= screen_res;
195 gl_FragColor[3] = shadow2DRectProj(shadowMap5, lpos).x;
196
197 //gl_FragColor.rgb = pos.xyz;
198 //gl_FragColor.b = shadow;
199 //gl_FragColor.rgb = debug;
139} 200}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
index 211b2e0..308b9b1 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl
@@ -12,7 +12,6 @@ uniform sampler2D detail_3;
12uniform sampler2D alpha_ramp; 12uniform sampler2D alpha_ramp;
13 13
14varying vec3 vary_normal; 14varying vec3 vary_normal;
15varying vec4 vary_position;
16 15
17void main() 16void main()
18{ 17{
@@ -28,9 +27,8 @@ void main()
28 float alphaFinal = texture2D(alpha_ramp, gl_TexCoord[1].zw).a; 27 float alphaFinal = texture2D(alpha_ramp, gl_TexCoord[1].zw).a;
29 vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal ); 28 vec4 outColor = mix( mix(color3, color2, alpha2), mix(color1, color0, alpha1), alphaFinal );
30 29
31 gl_FragData[0] = vec4(outColor.rgb, 1.0); 30 gl_FragData[0] = vec4(outColor.rgb, 0.0); // Kl 0.0 looks fine atm however check grass above waterline when GI enabled in future releases!
32 gl_FragData[1] = vec4(outColor.rgb*0.2, 0.2); 31 gl_FragData[1] = vec4(outColor.rgb*0.2, 0.2);
33 gl_FragData[2] = vec4(normalize(vary_normal), 0.0); 32 gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
34 gl_FragData[3] = vary_position;
35} 33}
36 34
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
index e9d6dca..3038b14 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/terrainV.glsl
@@ -6,7 +6,6 @@
6 */ 6 */
7 7
8varying vec3 vary_normal; 8varying vec3 vary_normal;
9varying vec4 vary_position;
10 9
11vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1) 10vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
12{ 11{
@@ -27,7 +26,6 @@ void main()
27 //transform vertex 26 //transform vertex
28 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 27 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
29 28
30 vary_position = gl_ModelViewMatrix * gl_Vertex;
31 vary_normal = normalize(gl_NormalMatrix * gl_Normal); 29 vary_normal = normalize(gl_NormalMatrix * gl_Normal);
32 30
33 // Transform and pass tex coords 31 // Transform and pass tex coords
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
index bc2c981..49c65f1 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/treeF.glsl
@@ -8,13 +8,11 @@
8uniform sampler2D diffuseMap; 8uniform sampler2D diffuseMap;
9 9
10varying vec3 vary_normal; 10varying vec3 vary_normal;
11varying vec4 vary_position;
12 11
13void main() 12void main()
14{ 13{
15 vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy); 14 vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
16 gl_FragData[0] = gl_Color*col; 15 gl_FragData[0] = gl_Color*col;
17 gl_FragData[1] = vec4(0,0,0,0); 16 gl_FragData[1] = vec4(0,0,0,0);
18 gl_FragData[2] = vec4(normalize(vary_normal), 0.0); 17 gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
19 gl_FragData[3] = vary_position;
20} 18}
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
index 9131d7c..6b9dc2d 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/treeV.glsl
@@ -6,7 +6,6 @@
6 */ 6 */
7 7
8varying vec3 vary_normal; 8varying vec3 vary_normal;
9varying vec4 vary_position;
10 9
11void main() 10void main()
12{ 11{
@@ -14,8 +13,6 @@ void main()
14 gl_Position = ftransform(); 13 gl_Position = ftransform();
15 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0; 14 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
16 15
17 vary_position = gl_ModelViewMatrix * gl_Vertex;
18
19 vary_normal = normalize(gl_NormalMatrix * gl_Normal); 16 vary_normal = normalize(gl_NormalMatrix * gl_Normal);
20 17
21 gl_FrontColor = gl_Color; 18 gl_FrontColor = gl_Color;
diff --git a/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
index 0a1f019..6eea656 100644
--- a/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl
@@ -17,7 +17,7 @@ uniform sampler2DShadow shadowMap2;
17uniform sampler2DShadow shadowMap3; 17uniform sampler2DShadow shadowMap3;
18uniform sampler2D noiseMap; 18uniform sampler2D noiseMap;
19 19
20uniform mat4 shadow_matrix[4]; 20uniform mat4 shadow_matrix[6];
21uniform vec4 shadow_clip; 21uniform vec4 shadow_clip;
22 22
23uniform float sunAngle; 23uniform float sunAngle;
diff --git a/linden/indra/newview/app_settings/shaders/class1/effects/colorFilterF.glsl b/linden/indra/newview/app_settings/shaders/class1/effects/colorFilterF.glsl
new file mode 100644
index 0000000..623ef7a
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/effects/colorFilterF.glsl
@@ -0,0 +1,31 @@
1/**
2 * @file colorFilterF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect RenderTexture;
9uniform float brightness;
10uniform float contrast;
11uniform vec3 contrastBase;
12uniform float saturation;
13uniform vec3 lumWeights;
14
15const float gamma = 2.0;
16
17void main(void)
18{
19 vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st));
20
21 /// Modulate brightness
22 color *= brightness;
23
24 /// Modulate contrast
25 color = mix(contrastBase, color, contrast);
26
27 /// Modulate saturation
28 color = mix(vec3(dot(color, lumWeights)), color, saturation);
29
30 gl_FragColor = vec4(color, 1.0);
31}
diff --git a/linden/indra/newview/app_settings/shaders/class1/effects/drawQuadV.glsl b/linden/indra/newview/app_settings/shaders/class1/effects/drawQuadV.glsl
new file mode 100644
index 0000000..29c2a09
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/effects/drawQuadV.glsl
@@ -0,0 +1,14 @@
1/**
2 * @file drawQuadV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8void main(void)
9{
10 //transform vertex
11 gl_Position = ftransform();
12 gl_TexCoord[0] = gl_MultiTexCoord0;
13 gl_TexCoord[1] = gl_MultiTexCoord1;
14}
diff --git a/linden/indra/newview/app_settings/shaders/class1/effects/nightVisionF.glsl b/linden/indra/newview/app_settings/shaders/class1/effects/nightVisionF.glsl
new file mode 100644
index 0000000..271d5cf
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/effects/nightVisionF.glsl
@@ -0,0 +1,42 @@
1/**
2 * @file nightVisionF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect RenderTexture;
9uniform sampler2D NoiseTexture;
10uniform float brightMult;
11uniform float noiseStrength;
12
13float luminance(vec3 color)
14{
15 /// CALCULATING LUMINANCE (Using NTSC lum weights)
16 /// http://en.wikipedia.org/wiki/Luma_%28video%29
17 return dot(color, vec3(0.299, 0.587, 0.114));
18}
19
20void main(void)
21{
22 /// Get scene color
23 vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st));
24
25 /// Extract luminance and scale up by night vision brightness
26 float lum = luminance(color) * brightMult;
27
28 /// Convert into night vision color space
29 /// Newer NVG colors (crisper and more saturated)
30 vec3 outColor = (lum * vec3(0.91, 1.21, 0.9)) + vec3(-0.07, 0.1, -0.12);
31
32 /// Add noise
33 float noiseValue = texture2D(NoiseTexture, gl_TexCoord[1].st).r;
34 noiseValue = (noiseValue - 0.5) * noiseStrength;
35
36 /// Older NVG colors (more muted)
37 // vec3 outColor = (lum * vec3(0.82, 0.75, 0.83)) + vec3(0.05, 0.32, -0.11);
38
39 outColor += noiseValue;
40
41 gl_FragColor = vec4(outColor, 1.0);
42}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
new file mode 100644
index 0000000..0055a73
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/alphaF.glsl
@@ -0,0 +1,112 @@
1/**
2 * @file alphaF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#extension GL_ARB_texture_rectangle : enable
9
10uniform sampler2D diffuseMap;
11uniform sampler2DRectShadow shadowMap0;
12uniform sampler2DRectShadow shadowMap1;
13uniform sampler2DRectShadow shadowMap2;
14uniform sampler2DRectShadow shadowMap3;
15uniform sampler2D noiseMap;
16uniform sampler2DRect depthMap;
17
18uniform mat4 shadow_matrix[6];
19uniform vec4 shadow_clip;
20uniform vec2 screen_res;
21
22vec3 atmosLighting(vec3 light);
23vec3 scaleSoftClip(vec3 light);
24
25varying vec3 vary_ambient;
26varying vec3 vary_directional;
27varying vec3 vary_fragcoord;
28varying vec3 vary_position;
29varying vec3 vary_light;
30
31uniform float alpha_soften;
32
33uniform mat4 inv_proj;
34
35vec4 getPosition(vec2 pos_screen)
36{
37 float depth = texture2DRect(depthMap, pos_screen.xy).a;
38 vec2 sc = pos_screen.xy*2.0;
39 sc /= screen_res;
40 sc -= vec2(1.0,1.0);
41 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
42 vec4 pos = inv_proj * ndc;
43 pos /= pos.w;
44 pos.w = 1.0;
45 return pos;
46}
47
48void main()
49{
50 vec2 frag = vary_fragcoord.xy/vary_fragcoord.z*0.5+0.5;
51 frag *= screen_res;
52
53 vec3 samp_pos = getPosition(frag).xyz;
54
55 float shadow = 1.0;
56 vec4 pos = vec4(vary_position, 1.0);
57
58 vec4 spos = pos;
59
60 if (spos.z > -shadow_clip.w)
61 {
62 vec4 lpos;
63
64 if (spos.z < -shadow_clip.z)
65 {
66 lpos = shadow_matrix[3]*spos;
67 lpos.xy *= screen_res;
68 shadow = shadow2DRectProj(shadowMap3, lpos).x;
69 shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
70 }
71 else if (spos.z < -shadow_clip.y)
72 {
73 lpos = shadow_matrix[2]*spos;
74 lpos.xy *= screen_res;
75 shadow = shadow2DRectProj(shadowMap2, lpos).x;
76 }
77 else if (spos.z < -shadow_clip.x)
78 {
79 lpos = shadow_matrix[1]*spos;
80 lpos.xy *= screen_res;
81 shadow = shadow2DRectProj(shadowMap1, lpos).x;
82 }
83 else
84 {
85 lpos = shadow_matrix[0]*spos;
86 lpos.xy *= screen_res;
87 shadow = shadow2DRectProj(shadowMap0, lpos).x;
88 }
89 }
90
91 vec4 col = vec4(vary_ambient + vary_directional.rgb*shadow, gl_Color.a);
92 vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * col;
93
94 color.rgb = atmosLighting(color.rgb);
95
96 color.rgb = scaleSoftClip(color.rgb);
97
98 if (samp_pos.z != 0.0)
99 {
100 float dist_factor = alpha_soften;
101 float a = gl_Color.a;
102 a *= a;
103 dist_factor *= 1.0/(1.0-a);
104 color.a *= min((pos.z-samp_pos.z)*dist_factor, 1.0);
105 }
106
107 //gl_FragColor = gl_Color;
108 gl_FragColor = color;
109 //gl_FragColor = vec4(1,0,1,1)*shadow;
110
111}
112
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
new file mode 100644
index 0000000..ab60b65
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -0,0 +1,75 @@
1/**
2 * @file alphaV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
9void calcAtmospherics(vec3 inPositionEye);
10
11float calcDirectionalLight(vec3 n, vec3 l);
12float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
13
14vec3 atmosAmbient(vec3 light);
15vec3 atmosAffectDirectionalLight(float lightIntensity);
16vec3 scaleDownLight(vec3 light);
17vec3 scaleUpLight(vec3 light);
18
19varying vec3 vary_ambient;
20varying vec3 vary_directional;
21varying vec3 vary_fragcoord;
22varying vec3 vary_position;
23varying vec3 vary_light;
24
25uniform float near_clip;
26uniform float shadow_offset;
27uniform float shadow_bias;
28
29void main()
30{
31 //transform vertex
32 gl_Position = ftransform();
33
34 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
35
36 vec4 pos = (gl_ModelViewMatrix * gl_Vertex);
37 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
38
39 vary_position = vec4(pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias), 1.0);
40
41 calcAtmospherics(pos.xyz);
42
43 //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
44 vec4 col;
45 col.a = gl_Color.a;
46
47 // Add windlight lights
48 col.rgb = atmosAmbient(vec3(0.));
49 col.rgb = scaleUpLight(col.rgb);
50
51 // Collect normal lights (need to be divided by two, as we later multiply by 2)
52 col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
53 col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
54 col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
55 col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
56 col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
57 col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
58 col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
59 col.rgb = scaleDownLight(col.rgb);
60
61 vary_light = gl_LightSource[0].position.xyz;
62
63 vary_ambient = col.rgb*gl_Color.rgb;
64 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)));
65
66 col.rgb = min(col.rgb*gl_Color.rgb, 1.0);
67
68 gl_FrontColor = col;
69
70 gl_FogFragCoord = pos.z;
71
72 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
73 vary_fragcoord.xyz = pos.xyz + vec3(0,0,near_clip);
74
75}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaF.glsl
new file mode 100644
index 0000000..fe83c3c
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaF.glsl
@@ -0,0 +1,77 @@
1/**
2 * @file avatarAlphaF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2D diffuseMap;
9uniform sampler2DRectShadow shadowMap0;
10uniform sampler2DRectShadow shadowMap1;
11uniform sampler2DRectShadow shadowMap2;
12uniform sampler2DRectShadow shadowMap3;
13uniform sampler2D noiseMap;
14
15uniform mat4 shadow_matrix[6];
16uniform vec4 shadow_clip;
17uniform vec2 screen_res;
18
19vec3 atmosLighting(vec3 light);
20vec3 scaleSoftClip(vec3 light);
21
22varying vec3 vary_ambient;
23varying vec3 vary_directional;
24varying vec4 vary_position;
25varying vec3 vary_normal;
26
27void main()
28{
29 float shadow = 1.0;
30 vec4 pos = vary_position;
31 vec3 norm = normalize(vary_normal);
32
33 vec3 nz = texture2D(noiseMap, gl_FragCoord.xy/128.0).xyz;
34
35 vec4 spos = pos;
36
37 if (spos.z > -shadow_clip.w)
38 {
39 vec4 lpos;
40
41 if (spos.z < -shadow_clip.z)
42 {
43 lpos = shadow_matrix[3]*spos;
44 lpos.xy *= screen_res;
45 shadow = shadow2DRectProj(shadowMap3, lpos).x;
46 shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
47 }
48 else if (spos.z < -shadow_clip.y)
49 {
50 lpos = shadow_matrix[2]*spos;
51 lpos.xy *= screen_res;
52 shadow = shadow2DRectProj(shadowMap2, lpos).x;
53 }
54 else if (spos.z < -shadow_clip.x)
55 {
56 lpos = shadow_matrix[1]*spos;
57 lpos.xy *= screen_res;
58 shadow = shadow2DRectProj(shadowMap1, lpos).x;
59 }
60 else
61 {
62 lpos = shadow_matrix[0]*spos;
63 lpos.xy *= screen_res;
64 shadow = shadow2DRectProj(shadowMap0, lpos).x;
65 }
66 }
67
68
69 vec4 col = vec4(vary_ambient + vary_directional*shadow, gl_Color.a);
70 vec4 color = texture2D(diffuseMap, gl_TexCoord[0].xy) * col;
71
72 color.rgb = atmosLighting(color.rgb);
73
74 color.rgb = scaleSoftClip(color.rgb);
75
76 gl_FragColor = color;
77}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
new file mode 100644
index 0000000..c1988d3
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -0,0 +1,78 @@
1/**
2 * @file avatarAlphaV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
9mat4 getSkinnedTransform();
10void calcAtmospherics(vec3 inPositionEye);
11
12float calcDirectionalLight(vec3 n, vec3 l);
13float calcPointLight(vec3 v, vec3 n, vec4 lp, float la);
14
15vec3 atmosAmbient(vec3 light);
16vec3 atmosAffectDirectionalLight(float lightIntensity);
17vec3 scaleDownLight(vec3 light);
18vec3 scaleUpLight(vec3 light);
19
20varying vec4 vary_position;
21varying vec3 vary_ambient;
22varying vec3 vary_directional;
23varying vec3 vary_normal;
24
25void main()
26{
27 gl_TexCoord[0] = gl_MultiTexCoord0;
28
29 vec4 pos;
30 vec3 norm;
31
32 mat4 trans = getSkinnedTransform();
33 pos.x = dot(trans[0], gl_Vertex);
34 pos.y = dot(trans[1], gl_Vertex);
35 pos.z = dot(trans[2], gl_Vertex);
36 pos.w = 1.0;
37
38 norm.x = dot(trans[0].xyz, gl_Normal);
39 norm.y = dot(trans[1].xyz, gl_Normal);
40 norm.z = dot(trans[2].xyz, gl_Normal);
41 norm = normalize(norm);
42
43 gl_Position = gl_ProjectionMatrix * pos;
44 vary_position = pos;
45 vary_normal = norm;
46
47 calcAtmospherics(pos.xyz);
48
49 //vec4 color = calcLighting(pos.xyz, norm, gl_Color, vec4(0.));
50 vec4 col;
51 col.a = gl_Color.a;
52
53 // Add windlight lights
54 col.rgb = atmosAmbient(vec3(0.));
55 col.rgb = scaleUpLight(col.rgb);
56
57 // Collect normal lights (need to be divided by two, as we later multiply by 2)
58 col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
59 col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
60 col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
61 col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
62 col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
63 col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos.xyz, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
64 col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
65 col.rgb = scaleDownLight(col.rgb);
66
67 vary_ambient = col.rgb*gl_Color.rgb;
68 vary_directional = gl_Color.rgb*atmosAffectDirectionalLight(max(calcDirectionalLight(norm, gl_LightSource[0].position.xyz), (1.0-gl_Color.a)*(1.0-gl_Color.a)));
69
70 col.rgb = min(col.rgb*gl_Color.rgb, 1.0);
71
72 gl_FrontColor = col;
73
74 gl_FogFragCoord = pos.z;
75
76}
77
78
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
new file mode 100644
index 0000000..1713fe9
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightF.glsl
@@ -0,0 +1,71 @@
1/**
2 * @file blurLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#extension GL_ARB_texture_rectangle : enable
9
10uniform sampler2DRect depthMap;
11uniform sampler2DRect normalMap;
12uniform sampler2DRect lightMap;
13
14uniform float dist_factor;
15uniform float blur_size;
16uniform vec2 delta;
17uniform vec3 kern[32];
18uniform int kern_length;
19uniform float kern_scale;
20
21varying vec2 vary_fragcoord;
22
23uniform mat4 inv_proj;
24uniform vec2 screen_res;
25
26vec4 getPosition(vec2 pos_screen)
27{
28 float depth = texture2DRect(depthMap, pos_screen.xy).a;
29 vec2 sc = pos_screen.xy*2.0;
30 sc /= screen_res;
31 sc -= vec2(1.0,1.0);
32 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
33 vec4 pos = inv_proj * ndc;
34 pos /= pos.w;
35 pos.w = 1.0;
36 return pos;
37}
38
39void main()
40{
41 vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
42 vec3 pos = getPosition(vary_fragcoord.xy).xyz;
43 vec4 ccol = texture2DRect(lightMap, vary_fragcoord.xy).rgba;
44
45 vec2 dlt = kern_scale * delta / (1.0+norm.xy*norm.xy);
46
47 dlt /= max(-pos.z*dist_factor, 1.0);
48
49 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'
50 vec4 col = defined_weight.xyxx * ccol;
51
52 for (int i = 1; i < kern_length; i++)
53 {
54 vec2 tc = vary_fragcoord.xy + kern[i].z*dlt;
55 vec3 samppos = getPosition(tc).xyz;
56 float d = dot(norm.xyz, samppos.xyz-pos.xyz);// dist from plane
57 if (d*d <= 0.003)
58 {
59 col += texture2DRect(lightMap, tc)*kern[i].xyxx;
60 defined_weight += kern[i].xy;
61 }
62 }
63
64
65
66 col /= defined_weight.xyxx;
67
68 gl_FragColor = col;
69
70 //gl_FragColor = ccol;
71}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightV.glsl
new file mode 100644
index 0000000..b7f07e5
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/blurLightV.glsl
@@ -0,0 +1,17 @@
1/**
2 * @file blurLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec2 vary_fragcoord;
9uniform vec2 screen_res;
10
11void main()
12{
13 //transform vertex
14 gl_Position = ftransform();
15 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
16 vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
17}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
new file mode 100644
index 0000000..6519594
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -0,0 +1,188 @@
1/**
2 * @file multiSpotLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#version 120
9
10#extension GL_ARB_texture_rectangle : enable
11
12uniform sampler2DRect diffuseRect;
13uniform sampler2DRect specularRect;
14uniform sampler2DRect depthMap;
15uniform sampler2DRect normalMap;
16uniform samplerCube environmentMap;
17uniform sampler2DRect lightMap;
18uniform sampler2D noiseMap;
19uniform sampler2D lightFunc;
20uniform sampler2D projectionMap;
21
22uniform mat4 proj_mat; //screen space to light space
23uniform float proj_near; //near clip for projection
24uniform vec3 proj_p; //plane projection is emitting from (in screen space)
25uniform vec3 proj_n;
26uniform float proj_focus; //distance from plane to begin blurring
27uniform float proj_lod; //(number of mips in proj map)
28uniform float proj_range; //range between near clip and far clip plane of projection
29uniform float proj_ambient_lod;
30uniform float proj_ambiance;
31uniform float near_clip;
32uniform float far_clip;
33
34uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
35uniform float sun_wash;
36uniform int proj_shadow_idx;
37uniform float shadow_fade;
38
39varying vec4 vary_light;
40
41varying vec4 vary_fragcoord;
42uniform vec2 screen_res;
43
44uniform mat4 inv_proj;
45
46vec4 getPosition(vec2 pos_screen)
47{
48 float depth = texture2DRect(depthMap, pos_screen.xy).a;
49 vec2 sc = pos_screen.xy*2.0;
50 sc /= screen_res;
51 sc -= vec2(1.0,1.0);
52 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
53 vec4 pos = inv_proj * ndc;
54 pos /= pos.w;
55 pos.w = 1.0;
56 return pos;
57}
58
59void main()
60{
61 vec4 frag = vary_fragcoord;
62 frag.xyz /= frag.w;
63 frag.xyz = frag.xyz*0.5+0.5;
64 frag.xy *= screen_res;
65
66 vec3 pos = getPosition(frag.xy).xyz;
67 vec3 lv = vary_light.xyz-pos.xyz;
68 float dist2 = dot(lv,lv);
69 dist2 /= vary_light.w;
70 if (dist2 > 1.0)
71 {
72 discard;
73 }
74
75 float shadow = 1.0;
76
77 if (proj_shadow_idx >= 0)
78 {
79 vec4 shd = texture2DRect(lightMap, frag.xy);
80 float sh[2];
81 sh[0] = shd.b;
82 sh[1] = shd.a;
83 shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
84 }
85
86 vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
87
88 norm = normalize(norm);
89 float l_dist = -dot(lv, proj_n);
90
91 vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
92 if (proj_tc.z < 0.0)
93 {
94 discard;
95 }
96
97 proj_tc.xyz /= proj_tc.w;
98
99 float fa = gl_Color.a+1.0;
100 float dist_atten = min(1.0-(dist2-1.0*(1.0-fa))/fa, 1.0);
101 if (dist_atten <= 0.0)
102 {
103 discard;
104 }
105
106 lv = proj_origin-pos.xyz;
107 lv = normalize(lv);
108 float da = dot(norm, lv);
109
110 vec3 col = vec3(0,0,0);
111
112 vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
113
114 float noise = texture2D(noiseMap, frag.xy/128.0).b;
115 if (proj_tc.z > 0.0 &&
116 proj_tc.x < 1.0 &&
117 proj_tc.y < 1.0 &&
118 proj_tc.x > 0.0 &&
119 proj_tc.y > 0.0)
120 {
121 float lit = 0.0;
122 float amb_da = proj_ambiance;
123
124 if (da > 0.0)
125 {
126 float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
127 float lod = diff * proj_lod;
128
129 vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
130
131 vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a;
132
133 lit = da * dist_atten * noise;
134
135 col = lcol*lit*diff_tex*shadow;
136 amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
137 }
138
139 //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
140 vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, proj_ambient_lod);
141
142 amb_da += (da*da*0.5+0.5)*proj_ambiance;
143
144 amb_da *= dist_atten * noise;
145
146 amb_da = min(amb_da, 1.0-lit);
147
148 col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
149 }
150
151
152 vec4 spec = texture2DRect(specularRect, frag.xy);
153 if (spec.a > 0.0)
154 {
155 vec3 ref = reflect(normalize(pos), norm);
156
157 //project from point pos in direction ref to plane proj_p, proj_n
158 vec3 pdelta = proj_p-pos;
159 float ds = dot(ref, proj_n);
160
161 if (ds < 0.0)
162 {
163 vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
164
165 vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0));
166
167 if (stc.z > 0.0)
168 {
169 stc.xy /= stc.w;
170
171 if (stc.x < 1.0 &&
172 stc.y < 1.0 &&
173 stc.x > 0.0 &&
174 stc.y > 0.0)
175 {
176 vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
177 col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow;
178 }
179 }
180 }
181 }
182
183 //attenuate point light contribution by SSAO component
184 col *= texture2DRect(lightMap, frag.xy).g;
185
186 gl_FragColor.rgb = col;
187 gl_FragColor.a = 0.0;
188}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredF.glsl
new file mode 100644
index 0000000..ee0e9d6
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredF.glsl
@@ -0,0 +1,59 @@
1/**
2 * @file postDeferredF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect diffuseRect;
9uniform sampler2DRect localLightMap;
10uniform sampler2DRect sunLightMap;
11uniform sampler2DRect giLightMap;
12uniform sampler2D luminanceMap;
13uniform sampler2DRect lightMap;
14
15uniform vec3 gi_lum_quad;
16uniform vec3 sun_lum_quad;
17uniform vec3 lum_quad;
18uniform float lum_lod;
19uniform vec4 ambient;
20
21uniform vec3 gi_quad;
22
23uniform vec2 screen_res;
24varying vec2 vary_fragcoord;
25
26void main()
27{
28 vec2 tc = vary_fragcoord.xy;
29 vec3 lcol = texture2DLod(luminanceMap, tc/screen_res, lum_lod).rgb;
30
31 float lum = sqrt(lcol.r)*lum_quad.x+lcol.r*lcol.r*lum_quad.y+lcol.r*lum_quad.z;
32
33 vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
34
35 float ambocc = texture2DRect(lightMap, vary_fragcoord.xy).g;
36
37 vec3 gi_col = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
38 gi_col = gi_col*gi_col*gi_quad.x + gi_col*gi_quad.y+gi_quad.z*ambocc*ambient.rgb;
39 gi_col *= diff;
40
41 vec4 sun_col = texture2DRect(sunLightMap, vary_fragcoord.xy);
42
43 vec3 local_col = texture2DRect(localLightMap, vary_fragcoord.xy).rgb;
44
45
46 float sun_lum = 1.0-lum;
47 sun_lum = sun_lum*sun_lum*sun_lum_quad.x + sun_lum*sun_lum_quad.y+sun_lum_quad.z;
48
49 float gi_lum = lum;
50 gi_lum = gi_lum*gi_lum*gi_lum_quad.x+gi_lum*gi_lum_quad.y+gi_lum_quad.z;
51 gi_col *= 1.0/gi_lum;
52
53 vec3 col = sun_col.rgb*(1.0+max(sun_lum,0.0))+gi_col+local_col;
54
55 gl_FragColor.rgb = col.rgb;
56 gl_FragColor.a = max(sun_lum*min(sun_col.r+sun_col.g+sun_col.b, 1.0), sun_col.a);
57
58 //gl_FragColor.rgb = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
59}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredV.glsl
new file mode 100644
index 0000000..9819232
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/postDeferredV.glsl
@@ -0,0 +1,17 @@
1/**
2 * @file postDeferredV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec2 vary_fragcoord;
9uniform vec2 screen_res;
10
11void main()
12{
13 //transform vertex
14 gl_Position = ftransform();
15 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
16 vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
17}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
new file mode 100644
index 0000000..52b79e3
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -0,0 +1,294 @@
1/**
2 * @file softenLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#extension GL_ARB_texture_rectangle : enable
9
10uniform sampler2DRect diffuseRect;
11uniform sampler2DRect specularRect;
12uniform sampler2DRect normalMap;
13uniform sampler2DRect lightMap;
14uniform sampler2D noiseMap;
15uniform samplerCube environmentMap;
16uniform sampler2D lightFunc;
17uniform vec3 gi_quad;
18
19uniform float blur_size;
20uniform float blur_fidelity;
21
22// Inputs
23uniform vec4 morphFactor;
24uniform vec3 camPosLocal;
25//uniform vec4 camPosWorld;
26uniform vec4 gamma;
27uniform vec4 lightnorm;
28uniform vec4 sunlight_color;
29uniform vec4 ambient;
30uniform vec4 blue_horizon;
31uniform vec4 blue_density;
32uniform vec4 haze_horizon;
33uniform vec4 haze_density;
34uniform vec4 cloud_shadow;
35uniform vec4 density_multiplier;
36uniform vec4 distance_multiplier;
37uniform vec4 max_y;
38uniform vec4 glow;
39uniform float scene_light_strength;
40uniform vec3 env_mat[3];
41uniform vec4 shadow_clip;
42uniform mat3 ssao_effect_mat;
43
44uniform sampler2DRect depthMap;
45uniform mat4 inv_proj;
46uniform vec2 screen_res;
47
48varying vec4 vary_light;
49varying vec2 vary_fragcoord;
50
51vec3 vary_PositionEye;
52
53vec3 vary_SunlitColor;
54vec3 vary_AmblitColor;
55vec3 vary_AdditiveColor;
56vec3 vary_AtmosAttenuation;
57
58vec4 getPosition(vec2 pos_screen)
59{ //get position in screen space (world units) given window coordinate and depth map
60 float depth = texture2DRect(depthMap, pos_screen.xy).a;
61 vec2 sc = pos_screen.xy*2.0;
62 sc /= screen_res;
63 sc -= vec2(1.0,1.0);
64 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
65 vec4 pos = inv_proj * ndc;
66 pos /= pos.w;
67 pos.w = 1.0;
68 return pos;
69}
70
71vec3 getPositionEye()
72{
73 return vary_PositionEye;
74}
75vec3 getSunlitColor()
76{
77 return vary_SunlitColor;
78}
79vec3 getAmblitColor()
80{
81 return vary_AmblitColor;
82}
83vec3 getAdditiveColor()
84{
85 return vary_AdditiveColor;
86}
87vec3 getAtmosAttenuation()
88{
89 return vary_AtmosAttenuation;
90}
91
92
93void setPositionEye(vec3 v)
94{
95 vary_PositionEye = v;
96}
97
98void setSunlitColor(vec3 v)
99{
100 vary_SunlitColor = v;
101}
102
103void setAmblitColor(vec3 v)
104{
105 vary_AmblitColor = v;
106}
107
108void setAdditiveColor(vec3 v)
109{
110 vary_AdditiveColor = v;
111}
112
113void setAtmosAttenuation(vec3 v)
114{
115 vary_AtmosAttenuation = v;
116}
117
118void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
119
120 vec3 P = inPositionEye;
121 setPositionEye(P);
122
123 //(TERRAIN) limit altitude
124 if (P.y > max_y.x) P *= (max_y.x / P.y);
125 if (P.y < -max_y.x) P *= (-max_y.x / P.y);
126
127 vec3 tmpLightnorm = lightnorm.xyz;
128
129 vec3 Pn = normalize(P);
130 float Plen = length(P);
131
132 vec4 temp1 = vec4(0);
133 vec3 temp2 = vec3(0);
134 vec4 blue_weight;
135 vec4 haze_weight;
136 vec4 sunlight = sunlight_color;
137 vec4 light_atten;
138
139 //sunlight attenuation effect (hue and brightness) due to atmosphere
140 //this is used later for sunlight modulation at various altitudes
141 light_atten = (blue_density * 1.0 + vec4(haze_density.r) * 0.25) * (density_multiplier.x * max_y.x);
142 //I had thought blue_density and haze_density should have equal weighting,
143 //but attenuation due to haze_density tends to seem too strong
144
145 temp1 = blue_density + vec4(haze_density.r);
146 blue_weight = blue_density / temp1;
147 haze_weight = vec4(haze_density.r) / temp1;
148
149 //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain)
150 temp2.y = max(0.0, tmpLightnorm.y);
151 temp2.y = 1. / temp2.y;
152 sunlight *= exp( - light_atten * temp2.y);
153
154 // main atmospheric scattering line integral
155 temp2.z = Plen * density_multiplier.x;
156
157 // Transparency (-> temp1)
158 // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier.x in a variable because the ati
159 // compiler gets confused.
160 temp1 = exp(-temp1 * temp2.z * distance_multiplier.x);
161
162 //final atmosphere attenuation factor
163 setAtmosAttenuation(temp1.rgb);
164
165 //compute haze glow
166 //(can use temp2.x as temp because we haven't used it yet)
167 temp2.x = dot(Pn, tmpLightnorm.xyz);
168 temp2.x = 1. - temp2.x;
169 //temp2.x is 0 at the sun and increases away from sun
170 temp2.x = max(temp2.x, .03); //was glow.y
171 //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
172 temp2.x *= glow.x;
173 //higher glow.x gives dimmer glow (because next step is 1 / "angle")
174 temp2.x = pow(temp2.x, glow.z);
175 //glow.z should be negative, so we're doing a sort of (1 / "angle") function
176
177 //add "minimum anti-solar illumination"
178 temp2.x += .25;
179
180 //increase ambient when there are more clouds
181 vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5;
182
183 /* decrease value and saturation (that in HSV, not HSL) for occluded areas
184 * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html
185 * // The following line of code performs the equivalent of:
186 * float ambAlpha = tmpAmbient.a;
187 * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis
188 * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue);
189 * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha);
190 */
191 tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
192
193 //haze color
194 setAdditiveColor(
195 vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow.x) + tmpAmbient)
196 + (haze_horizon.r * haze_weight) * (sunlight*(1.-cloud_shadow.x) * temp2.x
197 + tmpAmbient)));
198
199 //brightness of surface both sunlight and ambient
200 setSunlitColor(vec3(sunlight * .5));
201 setAmblitColor(vec3(tmpAmbient * .25));
202 setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1));
203}
204
205vec3 atmosLighting(vec3 light)
206{
207 light *= getAtmosAttenuation().r;
208 light += getAdditiveColor();
209 return (2.0 * light);
210}
211
212vec3 atmosTransport(vec3 light) {
213 light *= getAtmosAttenuation().r;
214 light += getAdditiveColor() * 2.0;
215 return light;
216}
217vec3 atmosGetDiffuseSunlightColor()
218{
219 return getSunlitColor();
220}
221
222vec3 scaleDownLight(vec3 light)
223{
224 return (light / scene_light_strength );
225}
226
227vec3 scaleUpLight(vec3 light)
228{
229 return (light * scene_light_strength);
230}
231
232vec3 atmosAmbient(vec3 light)
233{
234 return getAmblitColor() + light / 2.0;
235}
236
237vec3 atmosAffectDirectionalLight(float lightIntensity)
238{
239 return getSunlitColor() * lightIntensity;
240}
241
242vec3 scaleSoftClip(vec3 light)
243{
244 //soft clip effect:
245 light = 1. - clamp(light, vec3(0.), vec3(1.));
246 light = 1. - pow(light, gamma.xxx);
247
248 return light;
249}
250
251void main()
252{
253 vec2 tc = vary_fragcoord.xy;
254 vec3 pos = getPosition(tc).xyz;
255 vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
256 vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
257
258 float da = max(dot(norm.xyz, vary_light.xyz), 0.0);
259
260 vec4 diffuse = texture2DRect(diffuseRect, tc);
261 vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
262
263 vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
264 float scol = max(scol_ambocc.r, diffuse.a);
265 float ambocc = scol_ambocc.g;
266
267 calcAtmospherics(pos.xyz, ambocc);
268
269 vec3 col = atmosAmbient(vec3(0));
270 col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a));
271
272 col *= diffuse.rgb;
273
274 if (spec.a > 0.0)
275 {
276 vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
277 float sa = dot(ref, vary_light.xyz);
278 col.rgb += vary_SunlitColor*scol*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
279 }
280
281 col = atmosLighting(col);
282 col = scaleSoftClip(col);
283
284 gl_FragColor.rgb = col;
285
286 //gl_FragColor.rgb = gi_col.rgb;
287 gl_FragColor.a = 0.0;
288
289 //gl_FragColor.rg = scol_ambocc.rg;
290 //gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb;
291 //gl_FragColor.rgb = norm.rgb*0.5+0.5;
292 //gl_FragColor.rgb = vec3(ambocc);
293 //gl_FragColor.rgb = vec3(scol);
294}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
new file mode 100644
index 0000000..ad8af47
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/softenLightV.glsl
@@ -0,0 +1,24 @@
1/**
2 * @file softenLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform vec2 screen_res;
9
10varying vec4 vary_light;
11varying vec2 vary_fragcoord;
12void main()
13{
14 //transform vertex
15 gl_Position = ftransform();
16
17 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
18 vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
19
20 vec4 tex = gl_MultiTexCoord0;
21 tex.w = 1.0;
22
23 vary_light = gl_MultiTexCoord0;
24}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
new file mode 100644
index 0000000..d653408
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -0,0 +1,199 @@
1/**
2 * @file spotLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#version 120
9
10#extension GL_ARB_texture_rectangle : enable
11
12uniform sampler2DRect diffuseRect;
13uniform sampler2DRect specularRect;
14uniform sampler2DRect depthMap;
15uniform sampler2DRect normalMap;
16uniform samplerCube environmentMap;
17uniform sampler2DRect lightMap;
18uniform sampler2D noiseMap;
19uniform sampler2D lightFunc;
20uniform sampler2D projectionMap;
21
22uniform mat4 proj_mat; //screen space to light space
23uniform float proj_near; //near clip for projection
24uniform vec3 proj_p; //plane projection is emitting from (in screen space)
25uniform vec3 proj_n;
26uniform float proj_focus; //distance from plane to begin blurring
27uniform float proj_lod; //(number of mips in proj map)
28uniform float proj_range; //range between near clip and far clip plane of projection
29uniform float proj_ambiance;
30uniform float near_clip;
31uniform float far_clip;
32
33uniform vec3 proj_origin; //origin of projection to be used for angular attenuation
34uniform float sun_wash;
35uniform int proj_shadow_idx;
36uniform float shadow_fade;
37
38varying vec4 vary_light;
39
40varying vec4 vary_fragcoord;
41uniform vec2 screen_res;
42
43uniform mat4 inv_proj;
44
45vec4 getPosition(vec2 pos_screen)
46{
47 float depth = texture2DRect(depthMap, pos_screen.xy).a;
48 vec2 sc = pos_screen.xy*2.0;
49 sc /= screen_res;
50 sc -= vec2(1.0,1.0);
51 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
52 vec4 pos = inv_proj * ndc;
53 pos /= pos.w;
54 pos.w = 1.0;
55 return pos;
56}
57
58void main()
59{
60 vec4 frag = vary_fragcoord;
61 frag.xyz /= frag.w;
62 frag.xyz = frag.xyz*0.5+0.5;
63 frag.xy *= screen_res;
64
65 float shadow = 1.0;
66
67 if (proj_shadow_idx >= 0)
68 {
69 vec4 shd = texture2DRect(lightMap, frag.xy);
70 float sh[2];
71 sh[0] = shd.b;
72 sh[1] = shd.a;
73 shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0);
74 }
75
76 vec3 pos = getPosition(frag.xy).xyz;
77 vec3 lv = vary_light.xyz-pos.xyz;
78 float dist2 = dot(lv,lv);
79 dist2 /= vary_light.w;
80 if (dist2 > 1.0)
81 {
82 discard;
83 }
84
85 vec3 norm = texture2DRect(normalMap, frag.xy).xyz*2.0-1.0;
86
87 norm = normalize(norm);
88 float l_dist = -dot(lv, proj_n);
89
90 vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0));
91 if (proj_tc.z < 0.0)
92 {
93 discard;
94 }
95
96 proj_tc.xyz /= proj_tc.w;
97
98 float fa = gl_Color.a+1.0;
99 float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
100
101 lv = proj_origin-pos.xyz;
102 lv = normalize(lv);
103 float da = dot(norm, lv);
104
105 vec3 col = vec3(0,0,0);
106
107 vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
108
109 float noise = texture2D(noiseMap, frag.xy/128.0).b;
110 if (proj_tc.z > 0.0 &&
111 proj_tc.x < 1.0 &&
112 proj_tc.y < 1.0 &&
113 proj_tc.x > 0.0 &&
114 proj_tc.y > 0.0)
115 {
116 float lit = 0.0;
117 if (da > 0.0)
118 {
119 float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0);
120 float lod = diff * proj_lod;
121
122 vec4 plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
123
124 vec3 lcol = gl_Color.rgb * plcol.rgb * plcol.a;
125
126 lit = da * dist_atten * noise;
127
128 col = lcol*lit*diff_tex*shadow;
129 }
130
131 float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0);
132 float lod = diff * proj_lod;
133 vec4 amb_plcol = texture2DLod(projectionMap, proj_tc.xy, lod);
134 //float amb_da = mix(proj_ambiance, proj_ambiance*max(-da, 0.0), max(da, 0.0));
135 float amb_da = proj_ambiance;
136 if (da > 0.0)
137 {
138 amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
139 }
140
141 amb_da += (da*da*0.5+0.5)*proj_ambiance;
142
143 amb_da *= dist_atten * noise;
144
145 amb_da = min(amb_da, 1.0-lit);
146
147 col += amb_da*gl_Color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a;
148 }
149
150
151 vec4 spec = texture2DRect(specularRect, frag.xy);
152 if (spec.a > 0.0)
153 {
154 vec3 ref = reflect(normalize(pos), norm);
155
156 //project from point pos in direction ref to plane proj_p, proj_n
157 vec3 pdelta = proj_p-pos;
158 float ds = dot(ref, proj_n);
159
160 if (ds < 0.0)
161 {
162 vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds;
163
164 vec3 stc = (proj_mat * vec4(pfinal.xyz, 1.0)).xyz;
165
166 if (stc.z > 0.0)
167 {
168 stc.xy /= stc.z+proj_near;
169
170 if (stc.x < 1.0 &&
171 stc.y < 1.0 &&
172 stc.x > 0.0 &&
173 stc.y > 0.0)
174 {
175 vec4 scol = texture2DLod(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
176 col += dist_atten*scol.rgb*gl_Color.rgb*scol.a*spec.rgb*shadow;
177 }
178 }
179 }
180 }
181
182 /*if (spec.a > 0.0)
183 {
184 //vec3 ref = reflect(normalize(pos), norm);
185 float sa = dot(normalize(lv-normalize(pos)),norm);;
186 //sa = max(sa, 0.0);
187 //sa = pow(sa, 128.0 * spec.a*spec.a/dist_atten)*min(dist_atten*4.0, 1.0);
188 sa = texture2D(lightFunc, vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
189 sa *= noise;
190 col += da*sa*lcol*spec.rgb;
191 }*/
192
193 //attenuate point light contribution by SSAO component
194 col *= texture2DRect(lightMap, frag.xy).g;
195
196
197 gl_FragColor.rgb = col;
198 gl_FragColor.a = 0.0;
199}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
new file mode 100644
index 0000000..8ced94e
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -0,0 +1,203 @@
1/**
2 * @file sunLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#extension GL_ARB_texture_rectangle : enable
9
10uniform sampler2DRect depthMap;
11uniform sampler2DRect normalMap;
12uniform sampler2DRectShadow shadowMap0;
13uniform sampler2DRectShadow shadowMap1;
14uniform sampler2DRectShadow shadowMap2;
15uniform sampler2DRectShadow shadowMap3;
16uniform sampler2DRectShadow shadowMap4;
17uniform sampler2DRectShadow shadowMap5;
18uniform sampler2D noiseMap;
19
20uniform sampler2D lightFunc;
21
22
23// Inputs
24uniform mat4 shadow_matrix[6];
25uniform vec4 shadow_clip;
26uniform float ssao_radius;
27uniform float ssao_max_radius;
28uniform float ssao_factor;
29uniform float ssao_factor_inv;
30
31varying vec2 vary_fragcoord;
32varying vec4 vary_light;
33
34uniform mat4 inv_proj;
35uniform vec2 screen_res;
36
37uniform float shadow_bias;
38uniform float shadow_offset;
39
40vec4 getPosition(vec2 pos_screen)
41{
42 float depth = texture2DRect(depthMap, pos_screen.xy).a;
43 vec2 sc = pos_screen.xy*2.0;
44 sc /= screen_res;
45 sc -= vec2(1.0,1.0);
46 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
47 vec4 pos = inv_proj * ndc;
48 pos /= pos.w;
49 pos.w = 1.0;
50 return pos;
51}
52
53//calculate decreases in ambient lighting when crowded out (SSAO)
54float calcAmbientOcclusion(vec4 pos, vec3 norm)
55{
56 vec2 kern[8];
57 // exponentially (^2) distant occlusion samples spread around origin
58 kern[0] = vec2(-1.0, 0.0) * 0.125*0.125;
59 kern[1] = vec2(1.0, 0.0) * 0.250*0.250;
60 kern[2] = vec2(0.0, 1.0) * 0.375*0.375;
61 kern[3] = vec2(0.0, -1.0) * 0.500*0.500;
62 kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625;
63 kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750;
64 kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875;
65 kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000;
66
67 vec2 pos_screen = vary_fragcoord.xy;
68 vec3 pos_world = pos.xyz;
69 vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy;
70
71 float angle_hidden = 0.0;
72 int points = 0;
73
74 float scale = min(ssao_radius / -pos_world.z, ssao_max_radius);
75
76 // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?)
77 for (int i = 0; i < 8; i++)
78 {
79 vec2 samppos_screen = pos_screen + scale * reflect(kern[i], noise_reflect);
80 vec3 samppos_world = getPosition(samppos_screen).xyz;
81
82 vec3 diff = pos_world - samppos_world;
83 float dist2 = dot(diff, diff);
84
85 // assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area
86 // --> solid angle shrinking by the square of distance
87 //radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2
88 //(k should vary inversely with # of samples, but this is taken care of later)
89
90 //if (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) // -0.05*norm to shift sample point back slightly for flat surfaces
91 // angle_hidden += min(1.0/dist2, ssao_factor_inv); // dist != 0 follows from conditional. max of 1.0 (= ssao_factor_inv * ssao_factor)
92 angle_hidden = angle_hidden + float(dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) * min(1.0/dist2, ssao_factor_inv);
93
94 // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion"
95 points = points + int(diff.z > -1.0);
96 }
97
98 angle_hidden = min(ssao_factor*angle_hidden/float(points), 1.0);
99
100 return (1.0 - (float(points != 0) * angle_hidden));
101}
102
103void main()
104{
105 vec2 pos_screen = vary_fragcoord.xy;
106
107 //try doing an unproject here
108
109 vec4 pos = getPosition(pos_screen);
110
111 vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
112
113 /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL
114 {
115 gl_FragColor = vec4(0.0); // doesn't matter
116 return;
117 }*/
118
119 float shadow = 1.0;
120 float dp_directional_light = max(0.0, dot(norm, vary_light.xyz));
121
122 vec4 spos = vec4(pos.xyz + norm.xyz * (-pos.z/64.0*shadow_offset+shadow_bias), 1.0);
123
124 //vec3 debug = vec3(0,0,0);
125
126 if (spos.z > -shadow_clip.w)
127 {
128 if (dp_directional_light == 0.0)
129 {
130 // 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
131 shadow = 0.0;
132 }
133 else
134 {
135 vec4 lpos;
136
137 if (spos.z < -shadow_clip.z)
138 {
139 lpos = shadow_matrix[3]*spos;
140 lpos.xy *= screen_res;
141 shadow = shadow2DRectProj(shadowMap3, lpos).x;
142 shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0);
143 }
144 else if (spos.z < -shadow_clip.y)
145 {
146 lpos = shadow_matrix[2]*spos;
147 lpos.xy *= screen_res;
148 shadow = shadow2DRectProj(shadowMap2, lpos).x;
149 }
150 else if (spos.z < -shadow_clip.x)
151 {
152 lpos = shadow_matrix[1]*spos;
153 lpos.xy *= screen_res;
154 shadow = shadow2DRectProj(shadowMap1, lpos).x;
155 }
156 else
157 {
158 lpos = shadow_matrix[0]*spos;
159 lpos.xy *= screen_res;
160 shadow = shadow2DRectProj(shadowMap0, lpos).x;
161 }
162
163 // take the most-shadowed value out of these two:
164 // * the blurred sun shadow in the light (shadow) map
165 // * an unblurred dot product between the sun and this norm
166 // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting
167 shadow = min(shadow, dp_directional_light);
168 }
169
170 /*debug.r = lpos.y / (lpos.w*screen_res.y);
171
172 lpos.xy /= lpos.w*32.0;
173 if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1)
174 {
175 debug.gb = vec2(0.5, 0.5);
176 }
177
178 debug += (1.0-shadow)*0.5;*/
179
180 }
181 else
182 {
183 // more distant than the shadow map covers
184 shadow = 1.0;
185 }
186
187 gl_FragColor[0] = shadow;
188 gl_FragColor[1] = calcAmbientOcclusion(pos, norm);
189
190 //spotlight shadow 1
191 vec4 lpos = shadow_matrix[4]*spos;
192 lpos.xy *= screen_res;
193 gl_FragColor[2] = shadow2DRectProj(shadowMap4, lpos).x;
194
195 //spotlight shadow 2
196 lpos = shadow_matrix[5]*spos;
197 lpos.xy *= screen_res;
198 gl_FragColor[3] = shadow2DRectProj(shadowMap5, lpos).x;
199
200 //gl_FragColor.rgb = pos.xyz;
201 //gl_FragColor.b = shadow;
202 //gl_FragColor.rgb = debug;
203}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl
new file mode 100644
index 0000000..5081485
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/sunLightV.glsl
@@ -0,0 +1,25 @@
1/**
2 * @file sunLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec4 vary_light;
9varying vec2 vary_fragcoord;
10
11uniform vec2 screen_res;
12
13void main()
14{
15 //transform vertex
16 gl_Position = ftransform();
17 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
18 vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
19 vec4 tex = gl_MultiTexCoord0;
20 tex.w = 1.0;
21
22 vary_light = gl_MultiTexCoord0;
23
24 gl_FrontColor = gl_Color;
25}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/waterF.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/waterF.glsl
new file mode 100644
index 0000000..7342186
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/waterF.glsl
@@ -0,0 +1,139 @@
1/**
2 * @file waterF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8vec3 scaleSoftClip(vec3 inColor);
9vec3 atmosTransport(vec3 inColor);
10
11uniform sampler2D bumpMap;
12uniform sampler2D screenTex;
13uniform sampler2D refTex;
14uniform sampler2DRectShadow shadowMap0;
15uniform sampler2DRectShadow shadowMap1;
16uniform sampler2DRectShadow shadowMap2;
17uniform sampler2DRectShadow shadowMap3;
18uniform sampler2D noiseMap;
19
20uniform mat4 shadow_matrix[6];
21uniform vec4 shadow_clip;
22
23uniform float sunAngle;
24uniform float sunAngle2;
25uniform vec3 lightDir;
26uniform vec3 specular;
27uniform float lightExp;
28uniform float refScale;
29uniform float kd;
30uniform vec2 screenRes;
31uniform vec3 normScale;
32uniform float fresnelScale;
33uniform float fresnelOffset;
34uniform float blurMultiplier;
35uniform vec2 screen_res;
36uniform mat4 norm_mat; //region space to screen space
37
38//bigWave is (refCoord.w, view.w);
39varying vec4 refCoord;
40varying vec4 littleWave;
41varying vec4 view;
42varying vec4 vary_position;
43
44void main()
45{
46 vec4 color;
47 float dist = length(view.xy);
48
49 //normalize view vector
50 vec3 viewVec = normalize(view.xyz);
51
52 //get wave normals
53 vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0;
54 vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0;
55 vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0;
56 //get base fresnel components
57
58 vec3 df = vec3(
59 dot(viewVec, wave1),
60 dot(viewVec, (wave2 + wave3) * 0.5),
61 dot(viewVec, wave3)
62 ) * fresnelScale + fresnelOffset;
63 df *= df;
64
65 vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5;
66
67 float dist2 = dist;
68 dist = max(dist, 5.0);
69
70 float dmod = sqrt(dist);
71
72 vec2 dmod_scale = vec2(dmod*dmod, dmod);
73
74 //get reflected color
75 vec2 refdistort1 = wave1.xy*normScale.x;
76 vec2 refvec1 = distort+refdistort1/dmod_scale;
77 vec4 refcol1 = texture2D(refTex, refvec1);
78
79 vec2 refdistort2 = wave2.xy*normScale.y;
80 vec2 refvec2 = distort+refdistort2/dmod_scale;
81 vec4 refcol2 = texture2D(refTex, refvec2);
82
83 vec2 refdistort3 = wave3.xy*normScale.z;
84 vec2 refvec3 = distort+refdistort3/dmod_scale;
85 vec4 refcol3 = texture2D(refTex, refvec3);
86
87 vec4 refcol = refcol1 + refcol2 + refcol3;
88 float df1 = df.x + df.y + df.z;
89 refcol *= df1 * 0.333;
90
91 vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5;
92 //wavef.z *= max(-viewVec.z, 0.1);
93 wavef = normalize(wavef);
94
95 float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset;
96
97 vec2 refdistort4 = wavef.xy*0.125;
98 refdistort4.y -= abs(refdistort4.y);
99 vec2 refvec4 = distort+refdistort4/dmod;
100 float dweight = min(dist2*blurMultiplier, 1.0);
101 vec4 baseCol = texture2D(refTex, refvec4);
102 refcol = mix(baseCol*df2, refcol, dweight);
103
104 //get specular component
105 //float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0);
106
107 //harden specular
108 //spec = pow(spec, 128.0);
109
110 //figure out distortion vector (ripply)
111 vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0);
112
113 vec4 fb = texture2D(screenTex, distort2);
114
115 //mix with reflection
116 // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug
117 color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999);
118
119 float shadow = 1.0;
120 vec4 pos = vary_position;
121
122 vec3 nz = texture2D(noiseMap, gl_FragCoord.xy/128.0).xyz;
123 vec4 spos = pos;
124
125 //spec *= shadow;
126 //color.rgb += spec * specular;
127
128 //color.rgb = atmosTransport(color.rgb);
129 //color.rgb = scaleSoftClip(color.rgb);
130 //color.a = spec * sunAngle2;
131
132 //wavef.z *= 0.1f;
133 wavef = normalize(wavef);
134 wavef = (norm_mat*vec4(wavef, 1.0)).xyz;
135
136 gl_FragData[0] = vec4(color.rgb, 0.75);
137 gl_FragData[1] = vec4(1,1,1, 0.8);
138 gl_FragData[2] = vec4(wavef*0.5+0.5, 0.f);
139}
diff --git a/linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl b/linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl
new file mode 100644
index 0000000..b45e5c5
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/deferred/waterV.glsl
@@ -0,0 +1,76 @@
1/**
2 * @file waterV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8void calcAtmospherics(vec3 inPositionEye);
9
10uniform vec2 d1;
11uniform vec2 d2;
12uniform float time;
13uniform vec3 eyeVec;
14uniform float waterHeight;
15
16varying vec4 refCoord;
17varying vec4 littleWave;
18varying vec4 view;
19
20varying vec4 vary_position;
21
22float wave(vec2 v, float t, float f, vec2 d, float s)
23{
24 return (dot(d, v)*f + t*s)*f;
25}
26
27void main()
28{
29 //transform vertex
30 vec4 position = gl_Vertex;
31 mat4 modelViewProj = gl_ModelViewProjectionMatrix;
32
33 vec4 oPosition;
34
35 //get view vector
36 vec3 oEyeVec;
37 oEyeVec.xyz = position.xyz-eyeVec;
38
39 float d = length(oEyeVec.xy);
40 float ld = min(d, 2560.0);
41
42 position.xy = eyeVec.xy + oEyeVec.xy/d*ld;
43 view.xyz = oEyeVec;
44
45 d = clamp(ld/1536.0-0.5, 0.0, 1.0);
46 d *= d;
47
48 oPosition = position;
49 oPosition.z = mix(oPosition.z, max(eyeVec.z*0.75, 0.0), d);
50 vary_position = gl_ModelViewMatrix * oPosition;
51 oPosition = modelViewProj * oPosition;
52
53 refCoord.xyz = oPosition.xyz + vec3(0,0,0.2);
54
55 //get wave position parameter (create sweeping horizontal waves)
56 vec3 v = position.xyz;
57 v.x += (cos(v.x*0.08/*+time*0.01*/)+sin(v.y*0.02))*6.0;
58
59 //push position for further horizon effect.
60 position.xyz = oEyeVec.xyz*(waterHeight/oEyeVec.z);
61 position.w = 1.0;
62 position = position*gl_ModelViewMatrix;
63
64 calcAtmospherics((gl_ModelViewMatrix * gl_Vertex).xyz);
65
66
67 //pass wave parameters to pixel shader
68 vec2 bigWave = (v.xy) * vec2(0.04,0.04) + d1 * time * 0.055;
69 //get two normal map (detail map) texture coordinates
70 littleWave.xy = (v.xy) * vec2(0.45, 0.9) + d2 * time * 0.13;
71 littleWave.zw = (v.xy) * vec2(0.1, 0.2) + d1 * time * 0.1;
72 view.w = bigWave.y;
73 refCoord.w = bigWave.x;
74
75 gl_Position = oPosition;
76}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/avatarF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/avatarF.glsl
new file mode 100644
index 0000000..9cc71a7
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/avatarF.glsl
@@ -0,0 +1,18 @@
1/**
2 * @file avatarF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2D diffuseMap;
9
10varying vec3 vary_normal;
11
12void main()
13{
14 gl_FragData[0] = vec4(gl_Color.rgb * texture2D(diffuseMap, gl_TexCoord[0].xy).rgb, 0.0);
15 gl_FragData[1] = vec4(0,0,0,0);
16 gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
17}
18
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/bumpF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/bumpF.glsl
new file mode 100644
index 0000000..6eb4a51
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/bumpF.glsl
@@ -0,0 +1,27 @@
1/**
2 * @file bumpF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2D diffuseMap;
9uniform sampler2D bumpMap;
10
11varying vec3 vary_mat0;
12varying vec3 vary_mat1;
13varying vec3 vary_mat2;
14
15void main()
16{
17 vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
18 vec3 norm = texture2D(bumpMap, gl_TexCoord[0].xy).rgb * 2.0 - 1.0;
19
20 vec3 tnorm = vec3(dot(norm,vary_mat0),
21 dot(norm,vary_mat1),
22 dot(norm,vary_mat2));
23
24 gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0);
25 gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a);
26 gl_FragData[2] = vec4(normalize(tnorm)*0.5+0.5, 0.0);
27}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/diffuseF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/diffuseF.glsl
new file mode 100644
index 0000000..c9f75f7
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/diffuseF.glsl
@@ -0,0 +1,18 @@
1/**
2 * @file diffuseF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2D diffuseMap;
9
10varying vec3 vary_normal;
11
12void main()
13{
14 vec3 col = texture2D(diffuseMap, gl_TexCoord[0].xy).rgb;
15 gl_FragData[0] = vec4(gl_Color.rgb*col, 0.0);
16 gl_FragData[1] = vec4(vec3(gl_Color.a), gl_Color.a+(1.0-gl_Color.a)*gl_Color.a);
17 gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
18}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl
new file mode 100644
index 0000000..7325825
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleF.glsl
@@ -0,0 +1,84 @@
1/**
2 * @file giDownsampleF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect giLightMap;
9
10uniform vec2 kern[32];
11uniform float dist_factor;
12uniform float blur_size;
13uniform vec2 delta;
14uniform int kern_length;
15uniform float kern_scale;
16uniform vec3 blur_quad;
17
18varying vec2 vary_fragcoord;
19
20uniform mat4 inv_proj;
21uniform vec2 screen_res;
22
23vec4 getPosition(vec2 pos_screen)
24{
25 float depth = texture2DRect(depthMap, pos_screen.xy).a;
26 vec2 sc = pos_screen.xy*2.0;
27 sc /= screen_res;
28 sc -= vec2(1.0,1.0);
29 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
30 vec4 pos = inv_proj * ndc;
31 pos /= pos.w;
32 pos.w = 1.0;
33 return pos;
34}
35
36float getDepth(vec2 pos_screen)
37{
38 float z = texture2DRect(depthMap, pos_screen.xy).a;
39 z = z*2.0-1.0;
40 vec4 ndc = vec4(0.0, 0.0, z, 1.0);
41 vec4 p = inv_proj*ndc;
42 return p.z/p.w;
43}
44
45void main()
46{
47 vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
48 float depth = getDepth(vary_fragcoord.xy);
49
50 vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
51 vec2 dlt = kern_scale * delta/(vec2(1.0,1.0)+norm.xy*norm.xy);
52 dlt /= clamp(-depth*blur_quad.x, 1.0, 3.0);
53 float defined_weight = kern[0].x;
54 vec3 col = ccol*kern[0].x;
55
56 for (int i = 0; i < kern_length; i++)
57 {
58 vec2 tc = vary_fragcoord.xy + kern[i].y*dlt;
59 vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz*2.0-1.0;
60
61 float d = dot(norm.xyz, sampNorm);
62
63 if (d > 0.5)
64 {
65 float sampdepth = getDepth(tc.xy);
66 sampdepth -= depth;
67 if (sampdepth*sampdepth < blur_quad.z)
68 {
69 col += texture2DRect(giLightMap, tc).rgb*kern[i].x;
70 defined_weight += kern[i].x;
71 }
72 }
73 }
74
75 col /= defined_weight;
76
77 //col = ccol;
78
79 col = col*blur_quad.y;
80
81 gl_FragData[0].xyz = col;
82
83 //gl_FragColor = ccol;
84}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl
new file mode 100644
index 0000000..6adcda8
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/giDownsampleV.glsl
@@ -0,0 +1,17 @@
1/**
2 * @file postgiV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec2 vary_fragcoord;
9uniform vec2 screen_res;
10
11void main()
12{
13 //transform vertex
14 gl_Position = ftransform();
15 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
16 vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
17}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/giF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/giF.glsl
new file mode 100644
index 0000000..43da836
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/giF.glsl
@@ -0,0 +1,219 @@
1/**
2 * @file giF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#extension GL_ARB_texture_rectangle : enable
9
10uniform sampler2DRect depthMap;
11uniform sampler2DRect normalMap;
12uniform sampler2DRect lightMap;
13uniform sampler2DRect specularRect;
14
15uniform sampler2D noiseMap;
16
17uniform sampler2D diffuseGIMap;
18uniform sampler2D specularGIMap;
19uniform sampler2D normalGIMap;
20uniform sampler2D depthGIMap;
21
22uniform sampler2D lightFunc;
23
24// Inputs
25varying vec2 vary_fragcoord;
26
27uniform vec2 screen_res;
28
29uniform vec4 sunlight_color;
30
31uniform mat4 inv_proj;
32uniform mat4 gi_mat; //gPipeline.mGIMatrix - eye space to sun space
33uniform mat4 gi_mat_proj; //gPipeline.mGIMatrixProj - eye space to projected sun space
34uniform mat4 gi_norm_mat; //gPipeline.mGINormalMatrix - eye space normal to sun space normal matrix
35uniform mat4 gi_inv_proj; //gPipeline.mGIInvProj - projected sun space to sun space
36uniform float gi_radius;
37uniform float gi_intensity;
38uniform int gi_samples;
39uniform vec2 gi_kern[25];
40uniform vec2 gi_scale;
41uniform vec3 gi_quad;
42uniform vec3 gi_spec;
43uniform float gi_direction_weight;
44uniform float gi_light_offset;
45uniform float gi_range;
46
47vec4 getPosition(vec2 pos_screen)
48{
49 float depth = texture2DRect(depthMap, pos_screen.xy).a;
50 vec2 sc = pos_screen.xy*2.0;
51 sc /= screen_res;
52 sc -= vec2(1.0,1.0);
53 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
54 vec4 pos = inv_proj * ndc;
55 pos /= pos.w;
56 pos.w = 1.0;
57 return pos;
58}
59
60vec4 getGIPosition(vec2 gi_tc)
61{
62 float depth = texture2D(depthGIMap, gi_tc).a;
63 vec2 sc = gi_tc*2.0;
64 sc -= vec2(1.0, 1.0);
65 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
66 vec4 pos = gi_inv_proj*ndc;
67 pos.xyz /= pos.w;
68 pos.w = 1.0;
69 return pos;
70}
71
72vec3 giAmbient(vec3 pos, vec3 norm)
73{
74 vec4 gi_c = gi_mat_proj * vec4(pos, 1.0);
75 gi_c.xyz /= gi_c.w;
76
77 vec4 gi_pos = gi_mat*vec4(pos,1.0);
78 vec3 gi_norm = (gi_norm_mat*vec4(norm,1.0)).xyz;
79 gi_norm = normalize(gi_norm);
80
81 vec4 c_spec = texture2DRect(specularRect, vary_fragcoord.xy);
82 gi_pos.xyz += (texture2D(noiseMap, vary_fragcoord.xy/128.0).x)*gi_spec.z*gi_norm.xyz;
83 vec2 tcx = gi_norm.xy;
84 vec2 tcy = gi_norm.yx;
85
86 vec4 eye_pos = gi_mat*vec4(0,0,0,1.0);
87
88 vec3 eye_dir = normalize(gi_pos.xyz-eye_pos.xyz);
89 vec3 eye_ref = reflect(eye_dir, gi_norm);
90
91 //vec3 eye_dir = vec3(0,0,-1);
92 //eye_dir = (gi_norm_mat*vec4(eye_dir, 1.0)).xyz;
93 //eye_dir = normalize(eye_dir);
94
95 //float round_x = gi_scale.x;
96 //float round_y = gi_scale.y;
97
98 vec3 debug = texture2D(normalGIMap, gi_c.xy).rgb;
99 //debug.xz = vec2(0.0,0.0);
100 //debug = fract(debug);
101
102 float round_x = 1.0/64.0;
103 float round_y = 1.0/64.0;
104
105 //gi_c.x = floor(gi_c.x/round_x+0.5)*round_x;
106 //gi_c.y = floor(gi_c.y/round_y+0.5)*round_y;
107
108 float da = texture2DRect(lightMap, vary_fragcoord.xy).r;
109
110 vec3 fdiff = vec3(da);
111
112 if (da > 0.0)
113 {
114 vec3 ha = -eye_dir;
115 ha.z += 1.0;
116 ha = normalize(ha);
117
118 float sa = dot(ha,gi_norm);
119 da = min(da, texture2D(lightFunc, vec2(sa, c_spec.a)).a);
120 fdiff += da*(c_spec.rgb*c_spec.a*2.0);
121 }
122
123 float fda = da;
124
125 vec3 rcol = vec3(0,0,0);
126
127 float fsa = 0.0;
128
129
130 for (int i = -1; i <= 1; i += 1 )
131 {
132 for (int j = -1; j <= 1; j+= 1)
133 {
134 vec2 tc = vec2(i, j)*0.75+gi_norm.xy;
135 vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0+tc*0.5).xyz;
136 tc += gi_norm.xy*nz.z;
137 tc += nz.xy*2.0;
138 tc /= gi_samples;
139 tc += gi_c.xy;
140
141 vec3 lnorm = -normalize(texture2D(normalGIMap, tc.xy).xyz*2.0-1.0);
142 vec3 lpos = getGIPosition(tc.xy).xyz;
143
144 vec3 at = lpos-gi_pos.xyz;
145 float dist = dot(at,at);
146 float da = clamp(1.0/(gi_spec.x*dist), 0.0, 1.0);
147
148
149 if (da > 0.01)
150 { //possible contribution of indirect light to this surface
151 vec3 ldir = at;
152
153 float ld = -dot(ldir, lnorm);
154
155 if (ld < 0.0)
156 {
157 float ang_atten = dot(ldir, gi_norm);
158
159 if (ang_atten > 0.0)
160 {
161 vec4 spec = texture2D(specularGIMap, tc.xy);
162 at = normalize(at);
163 vec3 diff;
164
165 { //contribution from indirect source to visible pixel
166 vec3 ha = at;
167 ha.z -= 1.0;
168 ha = normalize(ha);
169 float sa = dot(ha,lnorm);
170 da = min(da, texture2D(lightFunc, vec2(sa, spec.a)).a);
171
172 diff = texture2D(diffuseGIMap, tc.xy).rgb+spec.rgb*spec.a*2.0;
173 }
174
175 if (da > 0.0)
176 { //contribution from visible pixel to eye
177 vec3 ha = normalize(at-eye_dir);
178 float sa = dot(ha, gi_norm);
179 da = min(da, texture2D(lightFunc, vec2(sa, c_spec.a)).a);
180 fda += da;
181 fdiff += da*(c_spec.rgb*c_spec.a*2.0+vec3(1,1,1))*diff.rgb;
182 }
183 }
184 }
185 }
186 }
187 }
188
189 //fdiff /= max(gi_spec.y*fda, gi_quad.z);
190 //fdiff = clamp(fdiff, vec3(0), vec3(1));
191 fdiff *= 64.0;
192 fdiff *= sunlight_color.rgb;
193
194 vec3 ret = fda*fdiff;
195 //ret = ret*ret*gi_quad.x+ret*gi_quad.y+gi_quad.z;
196
197 //fda *= nz.z;
198
199 //rcol.rgb *= gi_intensity;
200 //return rcol.rgb+vary_AmblitColor.rgb*0.25;
201 //return vec4(debug, 0.0);
202 //return vec4(fda*fdiff, 0.0);
203 return clamp(ret,vec3(0.0), vec3(1.0));
204 //return debug.xyz;
205}
206
207void main()
208{
209 vec2 pos_screen = vary_fragcoord.xy;
210 vec4 pos = getPosition(pos_screen);
211
212 float rad = gi_range*0.5;
213
214 vec3 norm = texture2DRect(normalMap, pos_screen).xyz*2.0-1.0;
215 float dist = max(length(pos.xyz)-rad, 0.0);
216
217 float da = clamp(1.0-dist/rad, 0.0, 1.0);
218 gl_FragData[0].xyz = da > 0.0 ? giAmbient(pos, norm)*da : vec3(0,0,0);
219}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/giV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/giV.glsl
new file mode 100644
index 0000000..71dcea9
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/giV.glsl
@@ -0,0 +1,22 @@
1/**
2 * @file giV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec2 vary_fragcoord;
9
10uniform vec2 screen_res;
11
12void main()
13{
14 //transform vertex
15 gl_Position = ftransform();
16 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
17 vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
18 vec4 tex = gl_MultiTexCoord0;
19 tex.w = 1.0;
20
21 gl_FrontColor = gl_Color;
22}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl
new file mode 100644
index 0000000..0de0d11
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceF.glsl
@@ -0,0 +1,16 @@
1/**
2 * @file luminanceF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect diffuseMap;
9
10varying vec2 vary_fragcoord;
11uniform float fade;
12void main()
13{
14 gl_FragColor.rgb = texture2DRect(diffuseMap, vary_fragcoord.xy).rgb;
15 gl_FragColor.a = fade;
16}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl
new file mode 100644
index 0000000..db8775f
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/luminanceV.glsl
@@ -0,0 +1,20 @@
1/**
2 * @file giV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec2 vary_fragcoord;
9
10uniform vec2 screen_res;
11
12void main()
13{
14 //transform vertex
15 gl_Position = ftransform();
16 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
17 vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res;
18
19 gl_FrontColor = gl_Color;
20}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl
new file mode 100644
index 0000000..609fb1d
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredF.glsl
@@ -0,0 +1,76 @@
1/**
2 * @file postDeferredF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect diffuseRect;
9uniform sampler2DRect specularRect;
10uniform sampler2DRect localLightMap;
11uniform sampler2DRect sunLightMap;
12uniform sampler2DRect giLightMap;
13uniform sampler2D luminanceMap;
14uniform sampler2DRect lightMap;
15uniform sampler2D lightFunc;
16
17
18uniform vec3 gi_lum_quad;
19uniform vec3 sun_lum_quad;
20uniform vec3 lum_quad;
21uniform float lum_lod;
22uniform vec4 ambient;
23
24uniform vec3 gi_quad;
25
26uniform vec2 screen_res;
27varying vec2 vary_fragcoord;
28
29void main()
30{
31 vec2 tc = vary_fragcoord.xy;
32 vec3 lcol = texture2DLod(luminanceMap, tc/screen_res, lum_lod).rgb;
33
34 float lum = sqrt(lcol.r)*lum_quad.x+lcol.r*lcol.r*lum_quad.y+lcol.r*lum_quad.z;
35
36 vec4 diff = texture2DRect(diffuseRect, vary_fragcoord.xy);
37 vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
38
39 float ambocc = texture2DRect(lightMap, vary_fragcoord.xy).g;
40
41 vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
42 vec3 gi_col = ccol;
43 /*for (int i = -1; i <= 1; i+=1)
44 {
45 for (int j = -1; j <= 1; j+=1)
46 {
47 vec2 tc = vec2(i,j);
48 float wght = 1.0/(length(tc)+1.0);
49 gi_col += texture2DRect(giLightMap, vary_fragcoord.xy+vec2(i,j)).rgb * wght;
50 }
51 }*/
52
53 //gi_col *= 1.0+spec.a*4.0;
54 gi_col = (sqrt(gi_col)*gi_quad.x + gi_col*gi_quad.y)*(diff.rgb+spec.rgb*spec.a)+gi_quad.z*ambocc*ambient.rgb*diff.rgb;
55
56 vec4 sun_col = texture2DRect(sunLightMap, vary_fragcoord.xy);
57
58 vec3 local_col = texture2DRect(localLightMap, vary_fragcoord.xy).rgb;
59
60
61 float sun_lum = 1.0-lum;
62 sun_lum = sun_lum*sun_lum*sun_lum_quad.x + sun_lum*sun_lum_quad.y+sun_lum_quad.z;
63
64 float gi_lum = lum;
65 gi_lum = gi_lum*gi_lum*gi_lum_quad.x+gi_lum*gi_lum_quad.y+gi_lum_quad.z;
66 gi_col *= 1.0/gi_lum;
67
68
69 vec3 col = sun_col.rgb*(1.0+max(sun_lum,0.0))+gi_col+local_col;
70
71 gl_FragColor.rgb = col.rgb;
72 gl_FragColor.a = max(sun_lum*min(sun_col.r+sun_col.g+sun_col.b, 1.0), sun_col.a);
73
74 //gl_FragColor.rgb = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
75 //gl_FragColor.rgb = vec3(texture2D(lightFunc, vary_fragcoord.xy/512.0-vec2(0.5, 0.5)).a);
76}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl
new file mode 100644
index 0000000..9819232
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/postDeferredV.glsl
@@ -0,0 +1,17 @@
1/**
2 * @file postDeferredV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec2 vary_fragcoord;
9uniform vec2 screen_res;
10
11void main()
12{
13 //transform vertex
14 gl_Position = ftransform();
15 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
16 vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
17}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl
new file mode 100644
index 0000000..12a5f39
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/postgiF.glsl
@@ -0,0 +1,87 @@
1/**
2 * @file postgiF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect depthMap;
9uniform sampler2DRect normalMap;
10uniform sampler2DRect giLightMap;
11uniform sampler2D noiseMap;
12
13uniform vec2 kern[32];
14uniform float dist_factor;
15uniform float blur_size;
16uniform vec2 delta;
17uniform int kern_length;
18uniform float kern_scale;
19uniform vec3 blur_quad;
20
21varying vec2 vary_fragcoord;
22
23uniform mat4 inv_proj;
24uniform vec2 screen_res;
25
26vec4 getPosition(vec2 pos_screen)
27{
28 float depth = texture2DRect(depthMap, pos_screen.xy).a;
29 vec2 sc = pos_screen.xy*2.0;
30 sc /= screen_res;
31 sc -= vec2(1.0,1.0);
32 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
33 vec4 pos = inv_proj * ndc;
34 pos /= pos.w;
35 pos.w = 1.0;
36 return pos;
37}
38
39float getDepth(vec2 pos_screen)
40{
41 float z = texture2DRect(depthMap, pos_screen.xy).a;
42 z = z*2.0-1.0;
43 vec4 ndc = vec4(0.0, 0.0, z, 1.0);
44 vec4 p = inv_proj*ndc;
45 return p.z/p.w;
46}
47
48void main()
49{
50 vec3 norm = texture2DRect(normalMap, vary_fragcoord.xy).xyz*2.0-1.0;
51 float depth = getDepth(vary_fragcoord.xy);
52
53 vec3 ccol = texture2DRect(giLightMap, vary_fragcoord.xy).rgb;
54 vec2 dlt = kern_scale * delta/(vec2(1.0,1.0)+norm.xy*norm.xy);
55 dlt /= clamp(-depth*blur_quad.x, 1.0, 3.0);
56 float defined_weight = kern[0].x;
57 vec3 col = ccol*kern[0].x;
58
59 for (int i = 0; i < kern_length; i++)
60 {
61 vec2 tc = vary_fragcoord.xy + kern[i].y*dlt;
62 vec3 sampNorm = texture2DRect(normalMap, tc.xy).xyz*2.0-1.0;
63
64 float d = dot(norm.xyz, sampNorm);
65
66 if (d > 0.5)
67 {
68 float sampdepth = getDepth(tc.xy);
69 sampdepth -= depth;
70 if (sampdepth*sampdepth < blur_quad.z)
71 {
72 col += texture2DRect(giLightMap, tc).rgb*kern[i].x;
73 defined_weight += kern[i].x;
74 }
75 }
76 }
77
78 col /= defined_weight;
79
80 //col = ccol;
81
82 col = col*blur_quad.y;
83
84 gl_FragData[0].xyz = col;
85
86 //gl_FragColor = ccol;
87}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl
new file mode 100644
index 0000000..6adcda8
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/postgiV.glsl
@@ -0,0 +1,17 @@
1/**
2 * @file postgiV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8varying vec2 vary_fragcoord;
9uniform vec2 screen_res;
10
11void main()
12{
13 //transform vertex
14 gl_Position = ftransform();
15 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
16 vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
17}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
new file mode 100644
index 0000000..654b182
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -0,0 +1,312 @@
1/**
2 * @file softenLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8#extension GL_ARB_texture_rectangle : enable
9
10uniform sampler2DRect diffuseRect;
11uniform sampler2DRect specularRect;
12uniform sampler2DRect normalMap;
13uniform sampler2DRect lightMap;
14uniform sampler2DRect giLightMap;
15uniform sampler2D noiseMap;
16uniform samplerCube environmentMap;
17uniform sampler2D lightFunc;
18uniform sampler2D luminanceMap;
19
20uniform vec3 gi_quad;
21uniform vec3 lum_quad;
22uniform float lum_lod;
23
24uniform float blur_size;
25uniform float blur_fidelity;
26
27// Inputs
28uniform vec4 morphFactor;
29uniform vec3 camPosLocal;
30//uniform vec4 camPosWorld;
31uniform vec4 gamma;
32uniform vec4 lightnorm;
33uniform vec4 sunlight_color;
34uniform vec4 ambient;
35uniform vec4 blue_horizon;
36uniform vec4 blue_density;
37uniform vec4 haze_horizon;
38uniform vec4 haze_density;
39uniform vec4 cloud_shadow;
40uniform vec4 density_multiplier;
41uniform vec4 distance_multiplier;
42uniform vec4 max_y;
43uniform vec4 glow;
44uniform float scene_light_strength;
45uniform vec3 env_mat[3];
46uniform vec4 shadow_clip;
47uniform mat3 ssao_effect_mat;
48
49uniform sampler2DRect depthMap;
50uniform mat4 inv_proj;
51uniform vec2 screen_res;
52
53varying vec4 vary_light;
54varying vec2 vary_fragcoord;
55
56vec3 vary_PositionEye;
57
58vec3 vary_SunlitColor;
59vec3 vary_AmblitColor;
60vec3 vary_AdditiveColor;
61vec3 vary_AtmosAttenuation;
62
63vec4 getPosition(vec2 pos_screen)
64{ //get position in screen space (world units) given window coordinate and depth map
65 float depth = texture2DRect(depthMap, pos_screen.xy).a;
66 vec2 sc = pos_screen.xy*2.0;
67 sc /= screen_res;
68 sc -= vec2(1.0,1.0);
69 vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0);
70 vec4 pos = inv_proj * ndc;
71 pos /= pos.w;
72 pos.w = 1.0;
73 return pos;
74}
75
76vec3 getPositionEye()
77{
78 return vary_PositionEye;
79}
80vec3 getSunlitColor()
81{
82 return vary_SunlitColor;
83}
84vec3 getAmblitColor()
85{
86 return vary_AmblitColor;
87}
88vec3 getAdditiveColor()
89{
90 return vary_AdditiveColor;
91}
92vec3 getAtmosAttenuation()
93{
94 return vary_AtmosAttenuation;
95}
96
97
98void setPositionEye(vec3 v)
99{
100 vary_PositionEye = v;
101}
102
103void setSunlitColor(vec3 v)
104{
105 vary_SunlitColor = v;
106}
107
108void setAmblitColor(vec3 v)
109{
110 vary_AmblitColor = v;
111}
112
113void setAdditiveColor(vec3 v)
114{
115 vary_AdditiveColor = v;
116}
117
118void setAtmosAttenuation(vec3 v)
119{
120 vary_AtmosAttenuation = v;
121}
122
123void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
124
125 vec3 P = inPositionEye;
126 setPositionEye(P);
127
128 //(TERRAIN) limit altitude
129 if (P.y > max_y.x) P *= (max_y.x / P.y);
130 if (P.y < -max_y.x) P *= (-max_y.x / P.y);
131
132 vec3 tmpLightnorm = lightnorm.xyz;
133
134 vec3 Pn = normalize(P);
135 float Plen = length(P);
136
137 vec4 temp1 = vec4(0);
138 vec3 temp2 = vec3(0);
139 vec4 blue_weight;
140 vec4 haze_weight;
141 vec4 sunlight = sunlight_color;
142 vec4 light_atten;
143
144 //sunlight attenuation effect (hue and brightness) due to atmosphere
145 //this is used later for sunlight modulation at various altitudes
146 light_atten = (blue_density * 1.0 + vec4(haze_density.r) * 0.25) * (density_multiplier.x * max_y.x);
147 //I had thought blue_density and haze_density should have equal weighting,
148 //but attenuation due to haze_density tends to seem too strong
149
150 temp1 = blue_density + vec4(haze_density.r);
151 blue_weight = blue_density / temp1;
152 haze_weight = vec4(haze_density.r) / temp1;
153
154 //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain)
155 temp2.y = max(0.0, tmpLightnorm.y);
156 temp2.y = 1. / temp2.y;
157 sunlight *= exp( - light_atten * temp2.y);
158
159 // main atmospheric scattering line integral
160 temp2.z = Plen * density_multiplier.x;
161
162 // Transparency (-> temp1)
163 // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier.x in a variable because the ati
164 // compiler gets confused.
165 temp1 = exp(-temp1 * temp2.z * distance_multiplier.x);
166
167 //final atmosphere attenuation factor
168 setAtmosAttenuation(temp1.rgb);
169
170 //compute haze glow
171 //(can use temp2.x as temp because we haven't used it yet)
172 temp2.x = dot(Pn, tmpLightnorm.xyz);
173 temp2.x = 1. - temp2.x;
174 //temp2.x is 0 at the sun and increases away from sun
175 temp2.x = max(temp2.x, .03); //was glow.y
176 //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot)
177 temp2.x *= glow.x;
178 //higher glow.x gives dimmer glow (because next step is 1 / "angle")
179 temp2.x = pow(temp2.x, glow.z);
180 //glow.z should be negative, so we're doing a sort of (1 / "angle") function
181
182 //add "minimum anti-solar illumination"
183 temp2.x += .25;
184
185 //increase ambient when there are more clouds
186 vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow.x * 0.5;
187
188 /* decrease value and saturation (that in HSV, not HSL) for occluded areas
189 * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html
190 * // The following line of code performs the equivalent of:
191 * float ambAlpha = tmpAmbient.a;
192 * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis
193 * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue);
194 * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha);
195 */
196 tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a);
197
198 //haze color
199 setAdditiveColor(
200 vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow.x) + tmpAmbient)
201 + (haze_horizon.r * haze_weight) * (sunlight*(1.-cloud_shadow.x) * temp2.x
202 + tmpAmbient)));
203
204 //brightness of surface both sunlight and ambient
205 setSunlitColor(vec3(sunlight * .5));
206 setAmblitColor(vec3(tmpAmbient * .25));
207 setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1));
208}
209
210vec3 atmosLighting(vec3 light)
211{
212 light *= getAtmosAttenuation().r;
213 light += getAdditiveColor();
214 return (2.0 * light);
215}
216
217vec3 atmosTransport(vec3 light) {
218 light *= getAtmosAttenuation().r;
219 light += getAdditiveColor() * 2.0;
220 return light;
221}
222vec3 atmosGetDiffuseSunlightColor()
223{
224 return getSunlitColor();
225}
226
227vec3 scaleDownLight(vec3 light)
228{
229 return (light / scene_light_strength );
230}
231
232vec3 scaleUpLight(vec3 light)
233{
234 return (light * scene_light_strength);
235}
236
237vec3 atmosAmbient(vec3 light)
238{
239 return getAmblitColor() + light / 2.0;
240}
241
242vec3 atmosAffectDirectionalLight(float lightIntensity)
243{
244 return getSunlitColor() * lightIntensity;
245}
246
247vec3 scaleSoftClip(vec3 light)
248{
249 //soft clip effect:
250 light = 1. - clamp(light, vec3(0.), vec3(1.));
251 light = 1. - pow(light, gamma.xxx);
252
253 return light;
254}
255
256void main()
257{
258 vec2 tc = vary_fragcoord.xy;
259 vec3 pos = getPosition(tc).xyz;
260 vec3 norm = texture2DRect(normalMap, tc).xyz*2.0-1.0;
261 vec3 nz = texture2D(noiseMap, vary_fragcoord.xy/128.0).xyz;
262
263 vec3 at = normalize(pos);
264
265 vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
266
267 vec3 lum = texture2DLod(luminanceMap, tc/screen_res, lum_lod).rgb;
268
269 vec3 ha = normalize(vary_light.xyz-at);
270
271 float da = dot(ha, norm.xyz);
272 da = texture2D(lightFunc, vec2(da, spec.a)).a;
273
274 vec4 diffuse = texture2DRect(diffuseRect, tc);
275
276 vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg;
277 float scol = max(scol_ambocc.r, diffuse.a);
278 float ambocc = scol_ambocc.g;
279
280 calcAtmospherics(pos.xyz, ambocc);
281
282 vec3 col = vec3(0,0,0);
283
284 col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a)*(1.0+spec.a));
285
286 col *= diffuse.rgb;
287
288 col += da*spec.rgb*spec.a*vary_SunlitColor*scol_ambocc.r;
289
290 /*if (spec.a > 0.0)
291 {
292 vec3 ref = normalize(reflect(pos.xyz, norm.xyz));
293 float sa = dot(ref, vary_light.xyz);
294 col.rgb += vary_SunlitColor*scol*spec.rgb*texture2D(lightFunc, vec2(sa, spec.a)).a;
295 }*/
296
297 col = atmosLighting(col);
298 col = scaleSoftClip(col);
299
300 col = col*vec3(1.0+1.0/2.2);
301
302 gl_FragColor.rgb = col;
303 //gl_FragColor.rgb = lum;
304
305 gl_FragColor.a = 0.0;
306
307 //gl_FragColor.rg = scol_ambocc.rg;
308 //gl_FragColor.rgb = texture2DRect(lightMap, vary_fragcoord.xy).rgb;
309 //gl_FragColor.rgb = norm.rgb*0.5+0.5;
310 //gl_FragColor.rgb = vec3(ambocc);
311 //gl_FragColor.rgb = vec3(scol);
312}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl
new file mode 100644
index 0000000..ad8af47
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl
@@ -0,0 +1,24 @@
1/**
2 * @file softenLightF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform vec2 screen_res;
9
10varying vec4 vary_light;
11varying vec2 vary_fragcoord;
12void main()
13{
14 //transform vertex
15 gl_Position = ftransform();
16
17 vec4 pos = gl_ModelViewProjectionMatrix * gl_Vertex;
18 vary_fragcoord = (pos.xy*0.5+0.5)*screen_res;
19
20 vec4 tex = gl_MultiTexCoord0;
21 tex.w = 1.0;
22
23 vary_light = gl_MultiTexCoord0;
24}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl
new file mode 100644
index 0000000..258acee
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/treeF.glsl
@@ -0,0 +1,18 @@
1/**
2 * @file treeF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2D diffuseMap;
9
10varying vec3 vary_normal;
11
12void main()
13{
14 vec4 col = texture2D(diffuseMap, gl_TexCoord[0].xy);
15 gl_FragData[0] = vec4(gl_Color.rgb*col.rgb, col.a <= 0.5 ? 0.0 : 0.005);
16 gl_FragData[1] = vec4(0,0,0,0);
17 gl_FragData[2] = vec4(normalize(vary_normal)*0.5+0.5, 0.0);
18}
diff --git a/linden/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl b/linden/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl
new file mode 100644
index 0000000..bea1515
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl
@@ -0,0 +1,139 @@
1/**
2 * @file waterF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8vec3 scaleSoftClip(vec3 inColor);
9vec3 atmosTransport(vec3 inColor);
10
11uniform sampler2D bumpMap;
12uniform sampler2D screenTex;
13uniform sampler2D refTex;
14uniform sampler2DRectShadow shadowMap0;
15uniform sampler2DRectShadow shadowMap1;
16uniform sampler2DRectShadow shadowMap2;
17uniform sampler2DRectShadow shadowMap3;
18uniform sampler2D noiseMap;
19
20uniform mat4 shadow_matrix[6];
21uniform vec4 shadow_clip;
22
23uniform float sunAngle;
24uniform float sunAngle2;
25uniform vec3 lightDir;
26uniform vec3 specular;
27uniform float lightExp;
28uniform float refScale;
29uniform float kd;
30uniform vec2 screenRes;
31uniform vec3 normScale;
32uniform float fresnelScale;
33uniform float fresnelOffset;
34uniform float blurMultiplier;
35uniform vec2 screen_res;
36uniform mat4 norm_mat; //region space to screen space
37
38//bigWave is (refCoord.w, view.w);
39varying vec4 refCoord;
40varying vec4 littleWave;
41varying vec4 view;
42varying vec4 vary_position;
43
44void main()
45{
46 vec4 color;
47 float dist = length(view.xy);
48
49 //normalize view vector
50 vec3 viewVec = normalize(view.xyz);
51
52 //get wave normals
53 vec3 wave1 = texture2D(bumpMap, vec2(refCoord.w, view.w)).xyz*2.0-1.0;
54 vec3 wave2 = texture2D(bumpMap, littleWave.xy).xyz*2.0-1.0;
55 vec3 wave3 = texture2D(bumpMap, littleWave.zw).xyz*2.0-1.0;
56 //get base fresnel components
57
58 vec3 df = vec3(
59 dot(viewVec, wave1),
60 dot(viewVec, (wave2 + wave3) * 0.5),
61 dot(viewVec, wave3)
62 ) * fresnelScale + fresnelOffset;
63 df *= df;
64
65 vec2 distort = (refCoord.xy/refCoord.z) * 0.5 + 0.5;
66
67 float dist2 = dist;
68 dist = max(dist, 5.0);
69
70 float dmod = sqrt(dist);
71
72 vec2 dmod_scale = vec2(dmod*dmod, dmod);
73
74 //get reflected color
75 vec2 refdistort1 = wave1.xy*normScale.x;
76 vec2 refvec1 = distort+refdistort1/dmod_scale;
77 vec4 refcol1 = texture2D(refTex, refvec1);
78
79 vec2 refdistort2 = wave2.xy*normScale.y;
80 vec2 refvec2 = distort+refdistort2/dmod_scale;
81 vec4 refcol2 = texture2D(refTex, refvec2);
82
83 vec2 refdistort3 = wave3.xy*normScale.z;
84 vec2 refvec3 = distort+refdistort3/dmod_scale;
85 vec4 refcol3 = texture2D(refTex, refvec3);
86
87 vec4 refcol = refcol1 + refcol2 + refcol3;
88 float df1 = df.x + df.y + df.z;
89 refcol *= df1 * 0.333;
90
91 vec3 wavef = (wave1 + wave2 * 0.4 + wave3 * 0.6) * 0.5;
92 //wavef.z *= max(-viewVec.z, 0.1);
93 wavef = normalize(wavef);
94
95 float df2 = dot(viewVec, wavef) * fresnelScale+fresnelOffset;
96
97 vec2 refdistort4 = wavef.xy*0.125;
98 refdistort4.y -= abs(refdistort4.y);
99 vec2 refvec4 = distort+refdistort4/dmod;
100 float dweight = min(dist2*blurMultiplier, 1.0);
101 vec4 baseCol = texture2D(refTex, refvec4);
102 refcol = mix(baseCol*df2, refcol, dweight);
103
104 //get specular component
105 //float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0);
106
107 //harden specular
108 //spec = pow(spec, 128.0);
109
110 //figure out distortion vector (ripply)
111 vec2 distort2 = distort+wavef.xy*refScale/max(dmod*df1, 1.0);
112
113 vec4 fb = texture2D(screenTex, distort2);
114
115 //mix with reflection
116 // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug
117 color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.99999);
118
119 float shadow = 1.0;
120 vec4 pos = vary_position;
121
122 vec3 nz = texture2D(noiseMap, gl_FragCoord.xy/128.0).xyz;
123 vec4 spos = pos;
124
125 //spec *= shadow;
126 //color.rgb += spec * specular;
127
128 //color.rgb = atmosTransport(color.rgb);
129 //color.rgb = scaleSoftClip(color.rgb);
130 //color.a = spec * sunAngle2;
131
132 //wavef.z *= 0.1f;
133 wavef = normalize(wavef);
134 wavef = (norm_mat*vec4(wavef, 1.0)).xyz;
135
136 gl_FragData[0] = vec4(color.rgb, 0.5);
137 gl_FragData[1] = vec4(0.5,0.5,0.5, 0.95);
138 gl_FragData[2] = vec4(wavef*0.5+0.5, 0.f);
139}
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/blurF.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/blurF.glsl
new file mode 100644
index 0000000..9443320
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/effects/blurF.glsl
@@ -0,0 +1,31 @@
1/**
2 * @file blurf.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect RenderTexture;
9uniform float bloomStrength;
10
11varying vec4 gl_TexCoord[gl_MaxTextureCoords];
12void main(void)
13{
14 float blurWeights[7];
15 blurWeights[0] = 0.05;
16 blurWeights[1] = 0.1;
17 blurWeights[2] = 0.2;
18 blurWeights[3] = 0.3;
19 blurWeights[4] = 0.2;
20 blurWeights[5] = 0.1;
21 blurWeights[6] = 0.05;
22
23 vec3 color = vec3(0,0,0);
24 for (int i = 0; i < 7; i++){
25 color += vec3(texture2DRect(RenderTexture, gl_TexCoord[i].st)) * blurWeights[i];
26 }
27
28 color *= bloomStrength;
29
30 gl_FragColor = vec4(color, 1.0);
31}
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/blurV.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/blurV.glsl
new file mode 100644
index 0000000..ba65b16
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/effects/blurV.glsl
@@ -0,0 +1,35 @@
1/**
2 * @file blurV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform vec2 texelSize;
9uniform vec2 blurDirection;
10uniform float blurWidth;
11
12void main(void)
13{
14 // Transform vertex
15 gl_Position = ftransform();
16
17 vec2 blurDelta = texelSize * blurDirection * vec2(blurWidth, blurWidth);
18 vec2 s = gl_MultiTexCoord0.st - (blurDelta * 3.0);
19
20 // for (int i = 0; i < 7; i++) {
21 // gl_TexCoord[i].st = s + (i * blurDelta);
22 // }
23
24 // MANUALLY UNROLL
25 gl_TexCoord[0].st = s;
26 gl_TexCoord[1].st = s + blurDelta;
27 gl_TexCoord[2].st = s + (2. * blurDelta);
28 gl_TexCoord[3].st = s + (3. * blurDelta);
29 gl_TexCoord[4].st = s + (4. * blurDelta);
30 gl_TexCoord[5].st = s + (5. * blurDelta);
31 gl_TexCoord[6].st = s + (6. * blurDelta);
32
33 // gl_TexCoord[0].st = s;
34 // gl_TexCoord[1].st = blurDelta;
35}
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/colorFilterF.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/colorFilterF.glsl
new file mode 100644
index 0000000..623ef7a
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/effects/colorFilterF.glsl
@@ -0,0 +1,31 @@
1/**
2 * @file colorFilterF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect RenderTexture;
9uniform float brightness;
10uniform float contrast;
11uniform vec3 contrastBase;
12uniform float saturation;
13uniform vec3 lumWeights;
14
15const float gamma = 2.0;
16
17void main(void)
18{
19 vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st));
20
21 /// Modulate brightness
22 color *= brightness;
23
24 /// Modulate contrast
25 color = mix(contrastBase, color, contrast);
26
27 /// Modulate saturation
28 color = mix(vec3(dot(color, lumWeights)), color, saturation);
29
30 gl_FragColor = vec4(color, 1.0);
31}
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/drawQuadV.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/drawQuadV.glsl
new file mode 100644
index 0000000..29c2a09
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/effects/drawQuadV.glsl
@@ -0,0 +1,14 @@
1/**
2 * @file drawQuadV.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8void main(void)
9{
10 //transform vertex
11 gl_Position = ftransform();
12 gl_TexCoord[0] = gl_MultiTexCoord0;
13 gl_TexCoord[1] = gl_MultiTexCoord1;
14}
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/extractF.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/extractF.glsl
new file mode 100644
index 0000000..a1583b1
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/effects/extractF.glsl
@@ -0,0 +1,22 @@
1/**
2 * @file extractF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect RenderTexture;
9uniform float extractLow;
10uniform float extractHigh;
11uniform vec3 lumWeights;
12
13void main(void)
14{
15 /// Get scene color
16 vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st));
17
18 /// Extract luminance and scale up by night vision brightness
19 float lum = smoothstep(extractLow, extractHigh, dot(color, lumWeights));
20
21 gl_FragColor = vec4(vec3(lum), 1.0);
22}
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/nightVisionF.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/nightVisionF.glsl
new file mode 100644
index 0000000..271d5cf
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/effects/nightVisionF.glsl
@@ -0,0 +1,42 @@
1/**
2 * @file nightVisionF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect RenderTexture;
9uniform sampler2D NoiseTexture;
10uniform float brightMult;
11uniform float noiseStrength;
12
13float luminance(vec3 color)
14{
15 /// CALCULATING LUMINANCE (Using NTSC lum weights)
16 /// http://en.wikipedia.org/wiki/Luma_%28video%29
17 return dot(color, vec3(0.299, 0.587, 0.114));
18}
19
20void main(void)
21{
22 /// Get scene color
23 vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st));
24
25 /// Extract luminance and scale up by night vision brightness
26 float lum = luminance(color) * brightMult;
27
28 /// Convert into night vision color space
29 /// Newer NVG colors (crisper and more saturated)
30 vec3 outColor = (lum * vec3(0.91, 1.21, 0.9)) + vec3(-0.07, 0.1, -0.12);
31
32 /// Add noise
33 float noiseValue = texture2D(NoiseTexture, gl_TexCoord[1].st).r;
34 noiseValue = (noiseValue - 0.5) * noiseStrength;
35
36 /// Older NVG colors (more muted)
37 // vec3 outColor = (lum * vec3(0.82, 0.75, 0.83)) + vec3(0.05, 0.32, -0.11);
38
39 outColor += noiseValue;
40
41 gl_FragColor = vec4(outColor, 1.0);
42}
diff --git a/linden/indra/newview/app_settings/shaders/class3/effects/simpleF.glsl b/linden/indra/newview/app_settings/shaders/class3/effects/simpleF.glsl
new file mode 100644
index 0000000..e55d278
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/effects/simpleF.glsl
@@ -0,0 +1,14 @@
1/**
2 * @file simpleF.glsl
3 *
4 * Copyright (c) 2007-$CurrentYear$, Linden Research, Inc.
5 * $License$
6 */
7
8uniform sampler2DRect RenderTexture;
9
10void main(void)
11{
12 vec3 color = vec3(texture2DRect(RenderTexture, gl_TexCoord[0].st));
13 gl_FragColor = vec4(1.0 - color, 1.0);
14}