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/avatar/avatarF.glsl7
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl19
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl35
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl7
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl20
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl6
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl17
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/environment/groundF.glsl5
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/environment/groundV.glsl6
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/environment/scatterF.glsl17
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/environment/scatterV.glsl15
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl19
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl37
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/environment/waterF.glsl22
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/environment/waterV.glsl41
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl6
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl20
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl31
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl99
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/objects/alphaF.glsl6
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/objects/alphaV.glsl21
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/objects/bumpshinyF.glsl18
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/objects/bumpshinyV.glsl25
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl6
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl21
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/avatar/avatarV.glsl48
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl23
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/environment/waterF.glsl136
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/environment/waterV.glsl53
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl36
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl126
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/objects/alphaF.glsl18
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/objects/alphaV.glsl24
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/objects/bumpshinyF.glsl29
-rw-r--r--linden/indra/newview/app_settings/shaders/class2/objects/bumpshinyV.glsl31
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl128
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/environment/groundF.glsl12
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/environment/groundV.glsl11
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/environment/scatterF.glsl25
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/environment/scatterV.glsl16
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/objects/bumpshinyF.glsl25
41 files changed, 1267 insertions, 0 deletions
diff --git a/linden/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl b/linden/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl
new file mode 100644
index 0000000..5731add
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl
@@ -0,0 +1,7 @@
1void default_lighting();
2
3void main()
4{
5 default_lighting();
6}
7
diff --git a/linden/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl b/linden/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl
new file mode 100644
index 0000000..1fcc001
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl
@@ -0,0 +1,19 @@
1vec4 calcLighting(vec3 pos, vec3 norm, vec4 color);
2
3attribute vec4 weight; //1
4
5uniform vec4 matrixPalette[45];
6
7mat4 getSkinnedTransform()
8{
9 mat4 ret;
10 int i = int(floor(weight.x));
11 float x = fract(weight.x);
12
13 ret[0] = mix(matrixPalette[i+0], matrixPalette[i+1], x);
14 ret[1] = mix(matrixPalette[i+15],matrixPalette[i+16], x);
15 ret[2] = mix(matrixPalette[i+30],matrixPalette[i+31], x);
16 ret[3] = vec4(0,0,0,1);
17
18 return ret;
19}
diff --git a/linden/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl b/linden/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl
new file mode 100644
index 0000000..50f9b01
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl
@@ -0,0 +1,35 @@
1void default_scatter(vec3 viewVec, vec3 lightDir);
2vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
3mat4 getSkinnedTransform();
4vec2 getScatterCoord(vec3 viewVec, vec3 lightDir);
5
6attribute vec4 materialColor;
7
8void main()
9{
10 gl_TexCoord[0] = gl_MultiTexCoord0;
11
12 vec4 pos;
13 vec3 norm;
14
15 mat4 trans = getSkinnedTransform();
16 pos.x = dot(trans[0], gl_Vertex);
17 pos.y = dot(trans[1], gl_Vertex);
18 pos.z = dot(trans[2], gl_Vertex);
19 pos.w = 1.0;
20
21 norm.x = dot(trans[0].xyz, gl_Normal);
22 norm.y = dot(trans[1].xyz, gl_Normal);
23 norm.z = dot(trans[2].xyz, gl_Normal);
24 norm = normalize(norm);
25
26 gl_Position = gl_ProjectionMatrix * pos;
27
28 //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
29
30 default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
31
32 vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color);
33 gl_FrontColor = color;
34
35}
diff --git a/linden/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl b/linden/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl
new file mode 100644
index 0000000..5731add
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl
@@ -0,0 +1,7 @@
1void default_lighting();
2
3void main()
4{
5 default_lighting();
6}
7
diff --git a/linden/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl b/linden/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl
new file mode 100644
index 0000000..d436b4e
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl
@@ -0,0 +1,20 @@
1vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseCol);
2void default_scatter(vec3 viewVec, vec3 lightDir);
3
4attribute vec4 materialColor;
5
6void main()
7{
8 //transform vertex
9 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
10 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
11
12 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
13 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
14
15 vec4 color = calcLighting(pos, norm, materialColor, gl_Color.rgb);
16 default_scatter(pos, gl_LightSource[0].position.xyz);
17
18 gl_FrontColor = color;
19}
20
diff --git a/linden/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl b/linden/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl
new file mode 100644
index 0000000..b311afb
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl
@@ -0,0 +1,6 @@
1uniform sampler2D diffuseMap;
2
3void main()
4{
5 gl_FragColor = vec4(gl_Color.rgb, texture2D(diffuseMap, gl_TexCoord[0].xy).a);
6}
diff --git a/linden/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl b/linden/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl
new file mode 100644
index 0000000..b6dcbe1
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl
@@ -0,0 +1,17 @@
1vec4 calcLighting(vec3 pos, vec3 norm, vec4 color);
2mat4 getSkinnedTransform();
3
4void main()
5{
6 vec4 pos;
7
8 mat4 trans = getSkinnedTransform();
9 pos.x = dot(trans[0], gl_Vertex);
10 pos.y = dot(trans[1], gl_Vertex);
11 pos.z = dot(trans[2], gl_Vertex);
12 pos.w = 1.0;
13
14 gl_FrontColor = gl_Color;
15 gl_TexCoord[0] = gl_MultiTexCoord0;
16 gl_Position = gl_ProjectionMatrix * pos;
17} \ No newline at end of file
diff --git a/linden/indra/newview/app_settings/shaders/class1/environment/groundF.glsl b/linden/indra/newview/app_settings/shaders/class1/environment/groundF.glsl
new file mode 100644
index 0000000..ef81b07
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/environment/groundF.glsl
@@ -0,0 +1,5 @@
1
2void main()
3{
4 gl_FragColor = gl_Color;
5}
diff --git a/linden/indra/newview/app_settings/shaders/class1/environment/groundV.glsl b/linden/indra/newview/app_settings/shaders/class1/environment/groundV.glsl
new file mode 100644
index 0000000..e227c58
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/environment/groundV.glsl
@@ -0,0 +1,6 @@
1
2void main()
3{
4 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
5 gl_FrontColor = gl_Fog.color;
6}
diff --git a/linden/indra/newview/app_settings/shaders/class1/environment/scatterF.glsl b/linden/indra/newview/app_settings/shaders/class1/environment/scatterF.glsl
new file mode 100644
index 0000000..3aa44de
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/environment/scatterF.glsl
@@ -0,0 +1,17 @@
1uniform sampler2D scatterMap;
2
3//for per-pixel scatter
4vec4 getScatter(vec3 viewVec, vec3 lightDir)
5{
6 return gl_TexCoord[5];
7}
8
9void applyScatter(inout vec3 color)
10{
11 color = gl_TexCoord[5].a*color + (1.0-gl_TexCoord[5].a) * gl_TexCoord[5].rgb;
12}
13
14void applyScatter(inout vec3 color, vec4 haze)
15{
16 color.rgb = haze.rgb + haze.a * color.rgb;
17}
diff --git a/linden/indra/newview/app_settings/shaders/class1/environment/scatterV.glsl b/linden/indra/newview/app_settings/shaders/class1/environment/scatterV.glsl
new file mode 100644
index 0000000..19dc2b8
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/environment/scatterV.glsl
@@ -0,0 +1,15 @@
1
2
3vec2 getScatterCoord(vec3 viewVec, vec3 lightDir)
4{
5 vec2 scatterCoord = vec2(0,0);
6 return scatterCoord;
7}
8
9void default_scatter(vec3 viewVec, vec3 lightDir)
10{
11 float f = gl_Fog.density * (gl_ModelViewProjectionMatrix * gl_Vertex).z;
12 f = clamp(exp2(-f),0.0,1.0);
13 gl_TexCoord[5].a = f;
14 gl_TexCoord[5].rgb = gl_Fog.color.rgb;
15}
diff --git a/linden/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl b/linden/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
new file mode 100644
index 0000000..fde3701
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
@@ -0,0 +1,19 @@
1void terrain_lighting(inout vec3 color);
2
3uniform sampler2D detail0; //0
4uniform sampler2D detail1; //2
5uniform sampler2D alphaRamp; //1
6
7
8void main()
9{
10 float a = texture2D(alphaRamp, gl_TexCoord[1].xy).a;
11 vec3 color = mix(texture2D(detail1, gl_TexCoord[2].xy).rgb,
12 texture2D(detail0, gl_TexCoord[0].xy).rgb,
13 a);
14
15 terrain_lighting(color);
16
17 gl_FragColor.rgb = color;
18 gl_FragColor.a = texture2D(alphaRamp, gl_TexCoord[3].xy).a;
19}
diff --git a/linden/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl b/linden/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
new file mode 100644
index 0000000..3153a80
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
@@ -0,0 +1,37 @@
1vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
2void default_scatter(vec3 viewVec, vec3 lightDir);
3
4attribute vec4 materialColor;
5
6vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
7{
8 vec4 tcoord;
9
10 tcoord.x = dot(vpos, tp0);
11 tcoord.y = dot(vpos, tp1);
12 tcoord.z = tc.z;
13 tcoord.w = tc.w;
14
15 tcoord = mat * tcoord;
16
17 return tcoord;
18}
19
20void main()
21{
22 //transform vertex
23 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
24
25 vec4 pos = gl_ModelViewMatrix * gl_Vertex;
26 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
27
28 vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color);
29
30 gl_FrontColor = color;
31
32 gl_TexCoord[0] = texgen_object(gl_Vertex,gl_MultiTexCoord0,gl_TextureMatrix[0],gl_ObjectPlaneS[0],gl_ObjectPlaneT[0]);
33 gl_TexCoord[1] = gl_TextureMatrix[1]*gl_MultiTexCoord1;
34 gl_TexCoord[2] = texgen_object(gl_Vertex,gl_MultiTexCoord2,gl_TextureMatrix[2],gl_ObjectPlaneS[2],gl_ObjectPlaneT[2]);
35 gl_TexCoord[3] = gl_TextureMatrix[3]*gl_MultiTexCoord3;
36 default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
37}
diff --git a/linden/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/linden/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
new file mode 100644
index 0000000..f8b8031
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
@@ -0,0 +1,22 @@
1void water_lighting(inout vec3 diff);
2
3uniform samplerCube environmentMap;
4uniform sampler2D diffuseMap;
5uniform sampler2D bumpMap;
6
7varying vec4 specular;
8
9void main()
10{
11 vec4 depth = texture2D(diffuseMap, gl_TexCoord[0].xy);
12 vec4 diff = texture2D(bumpMap, gl_TexCoord[1].xy);
13 vec3 ref = textureCube(environmentMap, gl_TexCoord[2].xyz).rgb;
14
15 diff.rgb *= depth.rgb;
16
17 vec3 col = mix(diff.rgb, ref, specular.a)+specular.rgb*diff.rgb;
18
19 water_lighting(col.rgb);
20 gl_FragColor.rgb = col.rgb;
21 gl_FragColor.a = (gl_Color.a+depth.a)*0.5;
22}
diff --git a/linden/indra/newview/app_settings/shaders/class1/environment/waterV.glsl b/linden/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
new file mode 100644
index 0000000..873a6fc
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
@@ -0,0 +1,41 @@
1void default_scatter(vec3 viewVec, vec3 lightDir);
2vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol);
3vec2 getScatterCoord(vec3 viewVec, vec3 lightDir);
4
5varying vec4 specular;
6
7vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
8{
9 vec4 tcoord;
10
11 tcoord.x = dot(vpos, tp0);
12 tcoord.y = dot(vpos, tp1);
13 tcoord.z = tc.z;
14 tcoord.w = tc.w;
15
16 tcoord = mat * tcoord;
17
18 return tcoord;
19}
20
21void main()
22{
23 //transform vertex
24 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
25 gl_TexCoord[0] = gl_MultiTexCoord0;
26 gl_TexCoord[1] = texgen_object(gl_Vertex, gl_MultiTexCoord1, gl_TextureMatrix[1], gl_ObjectPlaneS[1],gl_ObjectPlaneT[1]);
27
28 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
29 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
30 vec4 spec = gl_Color;
31 gl_FrontColor.rgb = calcLightingSpecular(pos, norm, gl_Color, spec, vec3(0.0, 0.0, 0.0)).rgb;
32 gl_FrontColor.a = gl_Color.a;
33 specular = spec;
34 specular.a = gl_Color.a*0.5;
35 vec3 ref = reflect(pos,norm);
36
37 gl_TexCoord[2] = gl_TextureMatrix[2]*vec4(ref,1);
38
39 default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
40}
41
diff --git a/linden/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/linden/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl
new file mode 100644
index 0000000..1e342fb
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl
@@ -0,0 +1,6 @@
1uniform sampler2D diffuseMap;
2
3void main()
4{
5 gl_FragColor = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy);
6}
diff --git a/linden/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl b/linden/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl
new file mode 100644
index 0000000..bb6707b
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl
@@ -0,0 +1,20 @@
1attribute vec4 materialColor;
2
3void main()
4{
5 //transform vertex
6 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
7 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
8 pos = normalize(pos);
9 float d = dot(pos, normalize(gl_NormalMatrix * gl_Normal));
10 d *= d;
11 d = 1.0 - d;
12 d *= d;
13
14 d = min(d, materialColor.a*2.0);
15
16 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
17 gl_FrontColor.rgb = materialColor.rgb;
18 gl_FrontColor.a = max(d, materialColor.a);
19}
20
diff --git a/linden/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl b/linden/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl
new file mode 100644
index 0000000..b2a6d67
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl
@@ -0,0 +1,31 @@
1void applyScatter(inout vec3 color);
2
3uniform sampler2D diffuseMap;
4
5void default_lighting()
6{
7 vec4 color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy);
8 applyScatter(color.rgb);
9 gl_FragColor = color;
10}
11
12void alpha_lighting()
13{
14 default_lighting();
15}
16
17void water_lighting(inout vec3 diff)
18{
19 applyScatter(diff);
20}
21
22void terrain_lighting(inout vec3 color)
23{
24 color.rgb *= gl_Color.rgb;
25 applyScatter(color);
26}
27
28vec4 getLightColor()
29{
30 return gl_Color;
31} \ No newline at end of file
diff --git a/linden/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl b/linden/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl
new file mode 100644
index 0000000..e381631
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl
@@ -0,0 +1,99 @@
1
2float calcDirectionalLight(vec3 n, vec3 l)
3{
4 float a = max(dot(n,l),0.0);
5 return a;
6}
7
8float calcPointLight(vec3 v, vec3 n, vec3 l, float r, float pw)
9{
10 //get light vector
11 vec3 lv = l-v;
12
13 //get distance
14 float d = length(lv);
15
16 //normalize light vector
17 lv *= 1.0/d;
18
19 //distance attenuation
20 float da = max((r-d)/r, 0.0);
21
22 //da = pow(da, pw);
23
24 //angular attenuation
25 da *= calcDirectionalLight(n, lv);
26
27 return da;
28}
29
30float calcDirectionalSpecular(vec3 view, vec3 n, vec3 l)
31{
32 float a = max(dot(n,l),0.0);
33 return a;
34}
35
36float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da)
37{
38
39 specular.rgb += calcDirectionalSpecular(view,n,l)*lightCol*da;
40 return calcDirectionalLight(n,l);
41}
42
43vec3 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol)
44{
45 //get light vector
46 vec3 lv = l-v;
47
48 //get distance
49 float d = length(lv);
50
51 //normalize light vector
52 lv *= 1.0/d;
53
54 //distance attenuation
55 float da = clamp((r-d)/r, 0.0, 1.0);
56
57 //da = pow(da, pw);
58
59 //angular attenuation
60 da *= calcDirectionalLightSpecular(specular, view, n, lv, lightCol, da);
61
62 return da*lightCol;
63}
64
65vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
66{
67 vec4 col;
68 col.a = color.a;
69
70 col.rgb = gl_LightModel.ambient.rgb + baseLight.rgb;
71
72 col.rgb += gl_LightSource[0].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[0].position.xyz);
73 col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
74
75 col.rgb = min(col.rgb*color.rgb, 1.0);
76
77 return col;
78}
79
80vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseLight)
81{
82 return calcLighting(pos, norm, color, vec4(baseLight, 1.0));
83}
84
85vec4 calcLighting(vec3 pos, vec3 norm, vec4 color)
86{
87 return calcLighting(pos, norm, color, vec3(0.0,0.0,0.0));
88}
89
90vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol)
91{
92 specularColor.rgb = vec3(0.0, 0.0, 0.0);
93 return calcLighting(pos, norm, color, baseCol);
94}
95
96vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol)
97{
98 return calcLightingSpecular(pos, norm, color, specularColor, vec4(baseCol, 1.0));
99}
diff --git a/linden/indra/newview/app_settings/shaders/class1/objects/alphaF.glsl b/linden/indra/newview/app_settings/shaders/class1/objects/alphaF.glsl
new file mode 100644
index 0000000..0d98f36
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/objects/alphaF.glsl
@@ -0,0 +1,6 @@
1void alpha_lighting();
2
3void main()
4{
5 alpha_lighting();
6}
diff --git a/linden/indra/newview/app_settings/shaders/class1/objects/alphaV.glsl b/linden/indra/newview/app_settings/shaders/class1/objects/alphaV.glsl
new file mode 100644
index 0000000..91821f7
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/objects/alphaV.glsl
@@ -0,0 +1,21 @@
1vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
2void default_scatter(vec3 viewVec, vec3 lightDir);
3
4attribute vec4 materialColor;
5
6void main()
7{
8 //transform vertex
9 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
10 gl_TexCoord[0] = gl_MultiTexCoord0;
11
12 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
13 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
14
15 default_scatter(pos, gl_LightSource[0].position.xyz);
16
17 vec4 color = calcLighting(pos, norm, materialColor, gl_Color);
18 color.a = materialColor.a;
19
20 gl_FrontColor = color;
21}
diff --git a/linden/indra/newview/app_settings/shaders/class1/objects/bumpshinyF.glsl b/linden/indra/newview/app_settings/shaders/class1/objects/bumpshinyF.glsl
new file mode 100644
index 0000000..8509c62
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/objects/bumpshinyF.glsl
@@ -0,0 +1,18 @@
1vec4 getLightColor();
2void applyScatter(inout vec3 col);
3
4uniform samplerCube environmentMap;
5uniform sampler2D diffuseMap;
6
7void main()
8{
9 vec4 diff = texture2D(diffuseMap, gl_TexCoord[0].xy);
10 vec3 ref = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb;
11 vec4 specular = gl_TexCoord[2];
12 vec3 col = mix(getLightColor().rgb * diff.rgb, ref, specular.a)+specular.rgb*diff.rgb;
13
14 applyScatter(col);
15
16 gl_FragColor.rgb = col;
17 gl_FragColor.a = diff.a*gl_Color.a;
18}
diff --git a/linden/indra/newview/app_settings/shaders/class1/objects/bumpshinyV.glsl b/linden/indra/newview/app_settings/shaders/class1/objects/bumpshinyV.glsl
new file mode 100644
index 0000000..9a189a2
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/objects/bumpshinyV.glsl
@@ -0,0 +1,25 @@
1vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol);
2void default_scatter(vec3 viewVec, vec3 lightDir);
3
4attribute vec4 materialColor;
5attribute vec4 specularColor;
6
7void main()
8{
9 //transform vertex
10 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
11 gl_TexCoord[0] = gl_MultiTexCoord0;
12
13 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
14 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
15
16 vec4 spec = specularColor;
17 gl_FrontColor.rgb = calcLightingSpecular(pos, norm, materialColor, spec, gl_Color).rgb;
18 gl_FrontColor.a = materialColor.a;
19 gl_TexCoord[2] = spec;
20 vec3 ref = reflect(pos,norm);
21 gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1.0);
22
23 default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
24}
25
diff --git a/linden/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl b/linden/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl
new file mode 100644
index 0000000..ce5ab12
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl
@@ -0,0 +1,6 @@
1void default_lighting();
2
3void main()
4{
5 default_lighting();
6}
diff --git a/linden/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl b/linden/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl
new file mode 100644
index 0000000..2aa3521
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl
@@ -0,0 +1,21 @@
1vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
2void default_scatter(vec3 viewVec, vec3 lightDir);
3
4attribute vec4 materialColor;
5
6void main()
7{
8 //transform vertex
9 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
10 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
11
12 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
13 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
14
15 default_scatter(pos, gl_LightSource[0].position.xyz);
16
17 vec4 color = calcLighting(pos, norm, materialColor, gl_Color);
18 gl_FrontColor = color;
19
20 gl_FogFragCoord = pos.z;
21}
diff --git a/linden/indra/newview/app_settings/shaders/class2/avatar/avatarV.glsl b/linden/indra/newview/app_settings/shaders/class2/avatar/avatarV.glsl
new file mode 100644
index 0000000..b040143
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/avatar/avatarV.glsl
@@ -0,0 +1,48 @@
1vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseCol);
2mat4 getSkinnedTransform();
3void default_scatter(vec3 viewVec, vec3 lightDir);
4
5attribute vec4 materialColor;
6attribute vec4 binormal;
7
8void main()
9{
10 gl_TexCoord[0] = gl_MultiTexCoord0;
11
12 vec4 pos;
13 mat4 trans = getSkinnedTransform();
14 pos.x = dot(trans[0], gl_Vertex);
15 pos.y = dot(trans[1], gl_Vertex);
16 pos.z = dot(trans[2], gl_Vertex);
17 pos.w = 1.0;
18
19 vec3 norm;
20 norm.x = dot(trans[0].xyz, gl_Normal);
21 norm.y = dot(trans[1].xyz, gl_Normal);
22 norm.z = dot(trans[2].xyz, gl_Normal);
23 norm = normalize(norm);
24
25 vec3 binorm;
26 binorm.x = dot(trans[0].xyz, binormal.xyz);
27 binorm.y = dot(trans[1].xyz, binormal.xyz);
28 binorm.z = dot(trans[2].xyz, binormal.xyz);
29
30 float spec = 1.0-max(dot(reflect(normalize(pos.xyz), norm),gl_LightSource[0].position.xyz), 0.0);
31 spec *= spec;
32 spec = 1.0-spec;
33
34 vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color.rgb);
35 gl_FrontColor = color;
36
37 gl_Position = gl_ProjectionMatrix * pos;
38
39 vec3 N = norm;
40 vec3 B = normalize(binorm);
41 vec3 T = cross(N,B);
42
43 //gl_TexCoord[1].xy = gl_MultiTexCoord0.xy + 1.0/512.0 * vec2(dot(T,gl_LightSource[0].position.xyz),
44 // dot(B,gl_LightSource[0].position.xyz));
45
46
47 default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
48} \ No newline at end of file
diff --git a/linden/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl b/linden/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl
new file mode 100644
index 0000000..7957edd
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/avatar/eyeballV.glsl
@@ -0,0 +1,23 @@
1vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol);
2void default_scatter(vec3 viewVec, vec3 lightDir);
3
4attribute vec4 materialColor;
5attribute vec4 specularColor;
6
7void main()
8{
9 //transform vertex
10 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
11 gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
12
13 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
14 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
15
16 default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
17 vec4 specular = specularColor;
18 vec4 color = calcLightingSpecular(pos, norm, materialColor, specular, gl_Color.rgb);
19
20 gl_FrontColor = color;
21 gl_FogFragCoord = pos.z;
22}
23
diff --git a/linden/indra/newview/app_settings/shaders/class2/environment/waterF.glsl b/linden/indra/newview/app_settings/shaders/class2/environment/waterF.glsl
new file mode 100644
index 0000000..e0e79e9
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/environment/waterF.glsl
@@ -0,0 +1,136 @@
1void applyScatter(inout vec3 color);
2
3uniform sampler2D diffuseMap;
4uniform sampler2D bumpMap;
5uniform samplerCube environmentMap; //: TEXUNIT4, // Environment map texture
6uniform sampler2D screenTex; // : TEXUNIT5
7
8uniform vec3 lightDir;
9uniform vec3 specular;
10uniform float lightExp;
11uniform vec2 fbScale;
12uniform float refScale;
13
14float msin(float x) {
15 float k = sin(x)+1.0;
16 k *= 0.5;
17 k *= k;
18 return 2.0 * k;
19}
20
21float mcos(float x) {
22 float k = cos(x)+1.0;
23 k *= 0.5;
24 k *= k;
25 return 2.0 * k;
26}
27
28float waveS(vec2 v, float t, float a, float f, vec2 d, float s, sampler1D sinMap)
29{
30 return texture1D(sinMap, (dot(d, v)*f + t*s)*f).r*a;
31}
32
33float waveC(vec2 v, float t, float a, float f, vec2 d, float s, sampler1D sinMap)
34{
35 return texture1D(sinMap, (dot(d, v)*f + t*s)*f).g*a*2.0-1.0;
36}
37
38float magnitude(vec3 vec) {
39 return sqrt(dot(vec,vec));
40}
41
42vec3 mreflect(vec3 i, vec3 n) {
43 return i + n * 2.0 * abs(dot(n,i))+vec3(0.0,0.0,0.5);
44}
45
46void main()
47{
48 vec2 texCoord = gl_TexCoord[0].xy; // Texture coordinates
49 vec2 littleWave1 = gl_TexCoord[0].zw;
50 vec2 littleWave2 = gl_TexCoord[1].xy;
51 vec2 bigWave = gl_TexCoord[1].zw;
52 vec3 viewVec = gl_TexCoord[2].xyz;
53 vec4 refCoord = gl_TexCoord[3];
54 vec4 col = gl_Color;
55 vec4 color;
56
57 //get color from alpha map (alpha denotes water depth), rgb denotes water color
58 vec4 wcol = texture2D(diffuseMap, texCoord.xy);
59
60 //store texture alpha
61 float da = wcol.a;
62
63 //modulate by incoming water color
64 //wcol.a *= refCoord.w;
65
66 //scale wcol.a (water depth) for steep transition
67 wcol.a *= wcol.a;
68
69 //normalize view vector
70 viewVec = normalize(viewVec);
71
72 //get bigwave normal
73 vec3 wavef = texture2D(bumpMap, bigWave).xyz*2.0;
74
75 vec3 view = vec3(viewVec.x, viewVec.y, viewVec.z);
76
77 float dx = 1.0-(dot(wavef*2.0-vec3(1.0), view))*da;
78 dx *= 0.274;
79
80 //get detail normals
81 vec3 dcol = texture2D(bumpMap, littleWave1+dx*view.xy).rgb*0.75;
82 dcol += texture2D(bumpMap, littleWave2+view.xy*dx*0.1).rgb*1.25;
83
84 //interpolate between big waves and little waves (big waves in deep water)
85 wavef = wavef*wcol.a + dcol*(1.0-wcol.a);
86
87 //crunch normal to range [-1,1]
88 wavef -= vec3(1,1,1);
89
90 //get base fresnel component
91 float df = dot(viewVec,wavef);
92 //reposition fresnel to latter half of [0,1]
93 df = 1.0-clamp(df,0.0,1.0);
94
95 //set output alpha based on fresnel
96 color.a = clamp((df+da)*0.5,0.0,1.0);
97
98 //calculate reflection vector
99 vec3 ref = reflect(viewVec.xyz, wavef);
100
101 //get specular component
102 float spec = clamp(dot(lightDir, normalize(ref)),0.0,1.0);
103
104 //fudge reflection to be more noisy at good angles
105 ref.z = ref.z*ref.z+df*df*0.5;
106
107 //get diffuse component
108 float diff = clamp((abs(dot(ref, wavef))),0.0,1.0)*0.9;
109
110 //fudge diffuse for extra contrast and ambience
111 diff *= diff;
112 diff += 0.4;
113
114 //set diffuse color contribution
115 color.rgb = textureCube(environmentMap, ref).rgb*diff;
116
117 //harden specular
118 spec = pow(spec, lightExp);
119
120 //add specular color contribution
121 color.rgb += spec * specular;
122
123 //figure out distortion vector (ripply)
124 vec2 distort = clamp(((refCoord.xy/refCoord.z) * 0.5 + 0.5 + wavef.xy*refScale),0.0,0.99);
125
126 //read from framebuffer (offset)
127 vec4 fb = texture2D(screenTex, distort*fbScale);
128
129 //tint by framebuffer
130 color.rgb = color.a*color.rgb + (1.0-color.a)*fb.rgb;
131
132 //apply fog
133 applyScatter(color.rgb);
134
135 gl_FragColor = color;
136}
diff --git a/linden/indra/newview/app_settings/shaders/class2/environment/waterV.glsl b/linden/indra/newview/app_settings/shaders/class2/environment/waterV.glsl
new file mode 100644
index 0000000..5f06aeb
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/environment/waterV.glsl
@@ -0,0 +1,53 @@
1void default_scatter(vec3 viewVec, vec3 lightDir);
2
3uniform vec2 d1;
4uniform vec2 d2;
5uniform float time;
6uniform vec3 eyeVec;
7
8float wave(vec2 v, float t, float f, vec2 d, float s)
9{
10 return (dot(d, v)*f + t*s)*f;
11}
12
13void main()
14{
15 //transform vertex
16 vec4 position = gl_Vertex;
17 mat4 modelViewProj = gl_ModelViewProjectionMatrix;
18 vec4 oPosition = modelViewProj * position;
19 vec3 oRefCoord = oPosition.xyz + vec3(0, 0, 0.2);
20
21 //get view vector
22 vec4 oEyeVec;
23 oEyeVec.xyz = position.xyz-eyeVec;
24
25 //get wave position parameter (create sweeping horizontal waves)
26 vec3 v = position.xyz;
27 v.x += (cos(v.x*0.08+time*0.01)+sin(v.y*0.02))*6.0;
28
29 //get two normal map (detail map) texture coordinates
30 vec2 oTexCoord = gl_MultiTexCoord0.xy;
31 vec2 littleWave1 = (v.xy)*vec2(0.7, 1.5)+d2*time*0.065;
32 vec2 littleWave2 = (v.xy)*vec2(0.07, 0.15)-d1*time*0.087;
33
34 //pass wave parameters to pixel shader
35 float t = time * 0.075;
36 vec2 bigWave = (v.xy)*vec2(0.04,0.04)+d1*t;
37
38 //pass color and fog color to pixel shader
39 vec4 col = gl_Color;
40 col.a = clamp(abs(dot(normalize(oEyeVec.xyz), vec3(0,0,1))),0.0,1.0);
41 col.a = 1.0-col.a;
42 col.a += 0.75;
43 default_scatter((gl_ModelViewMatrix * gl_Vertex).xyz, gl_LightSource[0].position.xyz);
44
45 gl_Position = oPosition;
46 gl_TexCoord[0].xy = oTexCoord;
47 gl_TexCoord[0].zw = littleWave1;
48 gl_TexCoord[1].xy = littleWave2;
49 gl_TexCoord[1].zw = bigWave;
50 gl_TexCoord[2] = oEyeVec;
51 gl_TexCoord[3].xyz = oRefCoord;
52 gl_FrontColor = col;
53}
diff --git a/linden/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl b/linden/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl
new file mode 100644
index 0000000..0ef1129
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/lighting/lightF.glsl
@@ -0,0 +1,36 @@
1void applyScatter(inout vec3 color);
2
3uniform sampler2D diffuseMap;
4
5void default_lighting()
6{
7 vec4 color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy);
8 applyScatter(color.rgb);
9 gl_FragColor = color;
10}
11
12void alpha_lighting()
13{
14 vec4 diff = texture2D(diffuseMap, gl_TexCoord[0].xy);
15 vec3 color = gl_Color.rgb * diff.rgb;
16 applyScatter(color);
17 gl_FragColor.rgb = color;
18 gl_FragColor.a = diff.a * gl_Color.a;
19}
20
21void water_lighting(inout vec3 diff)
22{
23 diff = (diff*0.9 + gl_Color.rgb*0.1);
24 applyScatter(diff);
25}
26
27void terrain_lighting(inout vec3 color)
28{
29 color.rgb *= gl_Color.rgb;
30 applyScatter(color);
31}
32
33vec4 getLightColor()
34{
35 return gl_Color;
36} \ No newline at end of file
diff --git a/linden/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl b/linden/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl
new file mode 100644
index 0000000..b15960d
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/lighting/lightV.glsl
@@ -0,0 +1,126 @@
1// All lights, no specular highlights
2
3float calcDirectionalLight(vec3 n, vec3 l)
4{
5 float a = max(dot(n,l),0.0);
6 return a;
7}
8
9float calcPointLight(vec3 v, vec3 n, vec4 lp, float la)
10{
11 //get light vector
12 vec3 lv = lp.xyz-v;
13
14 //get distance
15 float d = length(lv);
16
17 //normalize light vector
18 lv *= 1.0/d;
19
20 //distance attenuation
21 float da = clamp(1.0/(la * d), 0.0, 1.0);
22
23 //angular attenuation
24 da *= calcDirectionalLight(n, lv);
25
26 return da;
27}
28
29float calcDirectionalSpecular(vec3 view, vec3 n, vec3 l)
30{
31 return pow(max(dot(reflect(view, n),l), 0.0),8.0);
32}
33
34float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da)
35{
36
37 specular.rgb += calcDirectionalSpecular(view,n,l)*lightCol*da;
38 return calcDirectionalLight(n,l);
39}
40
41vec3 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol)
42{
43 //get light vector
44 vec3 lv = l-v;
45
46 //get distance
47 float d = length(lv);
48
49 //normalize light vector
50 lv *= 1.0/d;
51
52 //distance attenuation
53 float da = clamp(1.0/(r * d), 0.0, 1.0);
54
55 //angular attenuation
56
57 da *= calcDirectionalLightSpecular(specular, view, n, lv, lightCol, da);
58
59 return da*lightCol;
60}
61
62vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
63{
64 vec4 col;
65 col.a = color.a;
66
67 col.rgb = gl_LightModel.ambient.rgb + baseLight.rgb;
68
69 col.rgb += gl_LightSource[0].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[0].position.xyz);
70 col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
71 col.rgb += gl_LightSource[2].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[2].position, gl_LightSource[2].linearAttenuation);
72 col.rgb += gl_LightSource[3].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[3].position, gl_LightSource[3].linearAttenuation);
73 col.rgb += gl_LightSource[4].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[4].position, gl_LightSource[4].linearAttenuation);
74 col.rgb += gl_LightSource[5].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[5].position, gl_LightSource[5].linearAttenuation);
75 col.rgb += gl_LightSource[6].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[6].position, gl_LightSource[6].linearAttenuation);
76 col.rgb += gl_LightSource[7].diffuse.rgb*calcPointLight(pos, norm, gl_LightSource[7].position, gl_LightSource[7].linearAttenuation);
77
78 col.rgb = min(col.rgb*color.rgb, 1.0);
79
80 gl_FrontColor = vec4(col.rgb, col.a);
81 return col;
82}
83
84vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseLight)
85{
86 return calcLighting(pos, norm, color, vec4(baseLight, 1.0));
87}
88
89vec4 calcLighting(vec3 pos, vec3 norm, vec4 color)
90{
91 return calcLighting(pos, norm, color, vec3(0.0,0.0,0.0));
92}
93
94vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol)
95{
96 vec4 col;
97 col.a = color.a;
98
99 col.rgb = gl_LightModel.ambient.rgb;
100
101 vec3 view = normalize(pos);
102
103 vec4 specular = specularColor;
104 specularColor.rgb = vec3(0.0, 0.0, 0.0);
105
106 col.rgb += baseCol.a*gl_LightSource[0].diffuse.rgb*calcDirectionalLightSpecular(specularColor, view, norm, gl_LightSource[0].position.xyz,gl_LightSource[0].diffuse.rgb*baseCol.a, 1.0);
107 col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLightSpecular(specularColor, view, norm, gl_LightSource[1].position.xyz,gl_LightSource[1].diffuse.rgb, 1.0);
108 col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[2].position.xyz, gl_LightSource[2].linearAttenuation, gl_LightSource[2].quadraticAttenuation,gl_LightSource[2].diffuse.rgb);
109 col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[3].position.xyz, gl_LightSource[3].linearAttenuation, gl_LightSource[3].quadraticAttenuation,gl_LightSource[3].diffuse.rgb);
110 col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[4].position.xyz, gl_LightSource[4].linearAttenuation, gl_LightSource[4].quadraticAttenuation,gl_LightSource[4].diffuse.rgb);
111 col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[5].position.xyz, gl_LightSource[5].linearAttenuation, gl_LightSource[5].quadraticAttenuation,gl_LightSource[5].diffuse.rgb);
112 //col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[6].position.xyz, gl_LightSource[6].linearAttenuation, gl_LightSource[6].quadraticAttenuation,gl_LightSource[6].diffuse.rgb);
113 //col.rgb += calcPointLightSpecular(specularColor, view, pos, norm, gl_LightSource[7].position.xyz, gl_LightSource[7].linearAttenuation, gl_LightSource[7].quadraticAttenuation,gl_LightSource[7].diffuse.rgb);
114 col.rgb += baseCol.rgb;
115
116 col.rgb = min(col.rgb*color.rgb, 1.0);
117 specularColor.rgb = min(specularColor.rgb*specular.rgb, 1.0);
118
119 gl_FrontColor = vec4(col.rgb+specularColor.rgb,col.a);
120 return col;
121}
122
123vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol)
124{
125 return calcLightingSpecular(pos, norm, color, specularColor, vec4(baseCol, 1.0));
126}
diff --git a/linden/indra/newview/app_settings/shaders/class2/objects/alphaF.glsl b/linden/indra/newview/app_settings/shaders/class2/objects/alphaF.glsl
new file mode 100644
index 0000000..97feb55
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/objects/alphaF.glsl
@@ -0,0 +1,18 @@
1vec4 getLightColor();
2void applyScatter(inout vec3 col);
3
4uniform samplerCube environmentMap;
5uniform sampler2D diffuseMap;
6
7void main()
8{
9 vec4 diff = texture2D(diffuseMap, gl_TexCoord[0].xy);
10 vec3 ref = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb;
11 vec4 specular = gl_TexCoord[2];
12 vec3 col = mix(getLightColor().rgb * diff.rgb, ref, specular.a)+specular.rgb*diff.rgb;
13
14 applyScatter(col);
15
16 gl_FragColor.rgb = col.rgb;
17 gl_FragColor.a = diff.a*gl_Color.a;
18}
diff --git a/linden/indra/newview/app_settings/shaders/class2/objects/alphaV.glsl b/linden/indra/newview/app_settings/shaders/class2/objects/alphaV.glsl
new file mode 100644
index 0000000..baf5323
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/objects/alphaV.glsl
@@ -0,0 +1,24 @@
1vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol);
2void default_scatter(vec3 viewVec, vec3 lightDir);
3
4attribute vec4 materialColor;
5attribute vec4 specularColor;
6
7void main()
8{
9 //transform vertex
10 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
11 gl_TexCoord[0] = gl_MultiTexCoord0;
12
13 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
14 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
15 vec4 spec = specularColor;
16 gl_FrontColor.rgb = calcLightingSpecular(pos, norm, materialColor, spec, gl_Color).rgb;
17 gl_FrontColor.a = materialColor.a;
18 gl_TexCoord[2] = spec;
19 vec3 ref = reflect(pos,norm);
20 gl_TexCoord[1] = gl_TextureMatrix[1]*vec4(ref,1);
21
22 default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
23}
24
diff --git a/linden/indra/newview/app_settings/shaders/class2/objects/bumpshinyF.glsl b/linden/indra/newview/app_settings/shaders/class2/objects/bumpshinyF.glsl
new file mode 100644
index 0000000..7462bb1
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/objects/bumpshinyF.glsl
@@ -0,0 +1,29 @@
1vec4 getLightColor();
2void applyScatter(inout vec3 col);
3
4uniform samplerCube environmentMap;
5uniform sampler2D diffuseMap;
6uniform sampler2D bumpMap;
7
8
9void main()
10{
11 vec4 diff = texture2D(diffuseMap, gl_TexCoord[0].xy);
12 vec3 ref = textureCube(environmentMap, gl_TexCoord[1].xyz).rgb;
13
14 vec4 specular = gl_TexCoord[3];
15
16 float b = texture2D(bumpMap, gl_TexCoord[0].xy).a;
17 b -= texture2D(bumpMap, gl_TexCoord[2].xy).a;
18
19 vec3 col = mix(getLightColor().rgb * diff.rgb, ref, specular.a)+specular.rgb*diff.rgb;
20 col += col * b;
21 float m = (col.r + col.g + col.b);
22 m *= 1.0/3.0;
23 col = mix(col, vec3(m), -specular.a*specular.a);
24
25 applyScatter(col);
26
27 gl_FragColor.rgb = col;
28 gl_FragColor.a = diff.a;
29}
diff --git a/linden/indra/newview/app_settings/shaders/class2/objects/bumpshinyV.glsl b/linden/indra/newview/app_settings/shaders/class2/objects/bumpshinyV.glsl
new file mode 100644
index 0000000..037b282
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class2/objects/bumpshinyV.glsl
@@ -0,0 +1,31 @@
1vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol);
2void default_scatter(vec3 viewVec, vec3 lightDir);
3
4attribute vec4 materialColor;
5attribute vec4 specularColor;
6attribute vec4 binormal;
7
8void main()
9{
10 //transform vertex
11 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
12 gl_TexCoord[0] = gl_MultiTexCoord0;
13
14 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
15 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
16 vec3 binorm = normalize(gl_NormalMatrix * binormal.xyz);
17 vec3 tangent = cross(binorm, norm);
18 binorm.xy = vec2(dot(tangent, gl_LightSource[0].position.xyz),
19 dot(binorm, gl_LightSource[0].position.xyz))*1.0/128.0;
20
21 vec4 spec = specularColor;
22 gl_FrontColor.rgb = calcLightingSpecular(pos, norm, materialColor, spec, gl_Color).rgb;
23 gl_TexCoord[3] = spec;
24 gl_FrontColor.a = materialColor.a;
25 vec3 ref = reflect(pos,norm);
26 gl_TexCoord[1].xyz = (gl_TextureMatrix[1]*vec4(ref,1.0)).xyz;
27 gl_TexCoord[2].xy = binorm.xy + gl_MultiTexCoord0.xy;
28
29 default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
30}
31
diff --git a/linden/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl b/linden/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl
new file mode 100644
index 0000000..2505afe
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/avatar/avatarV.glsl
@@ -0,0 +1,128 @@
1vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseCol);
2mat4 getSkinnedTransform();
3void default_scatter(vec3 viewVec, vec3 lightDir);
4
5attribute vec4 materialColor; //2
6
7attribute vec4 binormal; //6
8attribute vec4 clothing; //4
9
10attribute vec4 gWindDir; //7
11attribute vec4 gSinWaveParams; //3
12attribute vec4 gGravity; //5
13
14const vec4 gMinMaxConstants = vec4(1.0, 0.166666, 0.0083143, .00018542); // #minimax-generated coefficients
15const vec4 gPiConstants = vec4(0.159154943, 6.28318530, 3.141592653, 1.5707963); // # {1/2PI, 2PI, PI, PI/2}
16
17void main()
18{
19 gl_TexCoord[0] = gl_MultiTexCoord0;
20
21 vec4 pos;
22 mat4 trans = getSkinnedTransform();
23
24 vec3 norm;
25 norm.x = dot(trans[0].xyz, gl_Normal);
26 norm.y = dot(trans[1].xyz, gl_Normal);
27 norm.z = dot(trans[2].xyz, gl_Normal);
28 norm = normalize(norm);
29
30 vec3 binorm;
31 binorm.x = dot(trans[0].xyz, binormal.xyz);
32 binorm.y = dot(trans[1].xyz, binormal.xyz);
33 binorm.z = dot(trans[2].xyz, binormal.xyz);
34 norm = normalize(norm);
35
36 //wind
37 vec4 windEffect;
38 windEffect = vec4(dot(norm, gWindDir.xyz)); // DP3 windEffect, blendNorm, gWindDir;
39 pos.x = dot(trans[2].xyz, gl_Vertex.xyz); // DP3 blendPos.x, blendMatZ, iPos;
40 windEffect.xyz = pos.x * vec3(0.015, 0.015, 0.015)
41 + windEffect.xyz; // MAD windEffect.xyz, blendPos.x, {0.015, 0.015, 0.015, 0}, windEffect;
42 windEffect.w = windEffect.w * 2.0 + 1.0; // MAD windEffect.w, windEffect, {0, 0, 0, 2}, {0, 0, 0, 1}; # move wind offset value to [-1, 3]
43 windEffect.w = windEffect.w*gWindDir.w; // MUL windEffect.w, windEffect, gWindDir; # modulate wind strength
44
45 windEffect.xyz = windEffect.xyz*gSinWaveParams.xyz
46 +vec3(gSinWaveParams.w); // MAD windEffect.xyz, windEffect, gSinWaveParams, gSinWaveParams.w; # use sin wave params to scale and offset input
47
48
49 //reduce to period of 2 PI
50 vec4 temp1, temp0, temp2, offsetPos;
51 temp1.xyz = windEffect.xyz * gPiConstants.x; // MUL temp1.xyz, windEffect, gPiConstants.x; # change input as multiple of [0-2PI] to [0-1]
52 temp0.y = mod(temp1.x,1.0); // EXP temp0, temp1.x; # find mod(x, 1)
53 windEffect.x = temp0.y * gPiConstants.y; // MUL windEffect.x, temp0.y, gPiConstants.y; # scale from [0,1] to [0, 2PI]
54 temp1.z = temp1.z - gPiConstants.w; // ADD temp1.z, temp1.z, -gPiConstants.w; # shift normal oscillation by PI/2
55 temp0.y = mod(temp1.z,1.0); // EXP temp0, temp1.z; # find mod(x, 1)
56
57 windEffect.z = temp0.y * gPiConstants.y; // MUL windEffect.z, temp0.y, gPiConstants.y; # scale from [0,1] to [0, 2PI]
58 windEffect.xyz = windEffect.xyz + vec3(-3.141592); // # offset to [-PI, PI]
59 // ADD windEffect.xyz, windEffect, {-3.141592, -3.141592, -3.141592, -3.141592};
60
61 //calculate sinusoid
62 vec4 sinWave;
63 temp1 = windEffect*windEffect; // MUL temp1, windEffect, windEffect; # x^2
64 sinWave = -temp1 * gMinMaxConstants.w
65 + vec4(gMinMaxConstants.z); // MAD sinWave, -temp1, gMinMaxConstants.w, gMinMaxConstants.z; # y = -(x^2)/7! + 1/5!
66 sinWave = sinWave * -temp1 + vec4(gMinMaxConstants.y); // MAD sinWave, sinWave, -temp1, gMinMaxConstants.y; # y = -(x^2) * (-(x^2)/7! + 1/5!) + 1/3!
67 sinWave = sinWave * -temp1 + vec4(gMinMaxConstants.x); // MAD sinWave, sinWave, -temp1, gMinMaxConstants.x; # y = -(x^2) * (-(x^2) * (-(x^2)/7! + 1/5!) + 1/3!) + 1
68 sinWave = sinWave * windEffect; // MUL sinWave, sinWave, windEffect; # y = x * (-(x^2) * (-(x^2) * (-(x^2)/7! + 1/5!) + 1/3!) + 1)
69
70 // sinWave.x holds sin(norm . wind_direction) with primary frequency
71 // sinWave.y holds sin(norm . wind_direction) with secondary frequency
72 // sinWave.z hold cos(norm . wind_direction) with primary frequency
73 sinWave.xyz = sinWave.xyz * gWindDir.w
74 + vec3(windEffect.w); // MAD sinWave.xyz, sinWave, gWindDir.w, windEffect.w; # multiply by wind strength in gWindDir.w [-wind, wind]
75
76 // add normal facing bias offset [-wind,wind] -> [-wind - .25, wind + 1]
77 temp1 = vec4(dot(norm, gGravity.xyz)); // DP3 temp1, blendNorm, gGravity; # how much is this normal facing in direction of gGravity?
78 temp1 = min(temp1, vec4(0.2,0.0,0.0,0.0)); // MIN temp1, temp1, {0.2, 0, 0, 0}; # clamp [-1, 1] to [-1, 0.2]
79 temp1 = temp1*vec4(1.5,0.0,0.0,0.0); // MUL temp1, temp1, {1.5, 0, 0, 0}; # scale from [-1,0.2] to [-1.5, 0.3]
80 sinWave.x = sinWave.x + temp1.x; // ADD sinWave.x, sinWave, temp1; # add gGravity effect to sinwave (only primary frequency)
81 sinWave.xyz = sinWave.xyz * clothing.w; // MUL sinWave.xyz, sinWave, iClothing.w; # modulate by clothing coverage
82
83 sinWave.xyz = max(sinWave.xyz, vec3(-1.0, -1.0, -1.0)); // MAX sinWave.xyz, sinWave, {-1, -1, -1, -1}; # clamp to underlying body shape
84 offsetPos = clothing * sinWave.x; // MUL offsetPos, iClothing, sinWave.x; # multiply wind effect times clothing displacement
85 temp2 = gWindDir*sinWave.z + vec4(norm,0); // MAD temp2, gWindDir, sinWave.z, blendNorm; # calculate normal offset due to wind oscillation
86 offsetPos = vec4(1.0,1.0,1.0,0.0)*offsetPos+gl_Vertex; // MAD offsetPos, {1.0, 1.0, 1.0, 0.0}, offsetPos, iPos; # add to offset vertex position, and zero out effect from w
87 norm += temp2.xyz*2.0; // MAD blendNorm, temp2, {2, 2, 2, 2}, blendNorm; # add sin wave effect on normals (exaggerated)
88
89 //add "backlighting" effect
90 float colorAcc;
91 colorAcc = 1.0 - clothing.w; // SUB colorAcc, {1, 1, 1, 1}, iClothing;
92 norm.z -= colorAcc * 0.2; // MAD blendNorm, colorAcc.w, {0, 0, -0.2, 0}, blendNorm;
93
94 //renormalize normal (again)
95 norm = normalize(norm); // DP3 divisor.w, blendNorm, blendNorm;
96 // RSQ divisor.xyz, divisor.w;
97 // MUL blendNorm.xyz, blendNorm, divisor;
98
99 //project binormal to normal plane to ensure orthogonality
100 temp2 = vec4(dot(norm, binorm)); // DP3 temp2, blendNorm, blendBinorm;
101 binorm = binorm - temp2.xyz; // SUB blendBinorm, blendBinorm, temp2;
102
103 //renormalize binormal
104 binorm = normalize(binorm); // DP3 divisor.w, blendBinorm, blendBinorm;
105 // RSQ divisor.xyz, divisor.w;
106 // MUL blendBinorm.xyz, blendBinorm, divisor;
107
108 pos.x = dot(trans[0], offsetPos);
109 pos.y = dot(trans[1], offsetPos);
110 pos.z = dot(trans[2], offsetPos);
111 pos.w = 1.0;
112
113 vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color.rgb);
114 gl_FrontColor = color;
115
116 gl_Position = gl_ProjectionMatrix * pos;
117
118 vec3 N = norm;
119 vec3 B = binorm;
120 vec3 T = cross(N,B);
121
122 //gl_TexCoord[1].xy = gl_MultiTexCoord0.xy + 1.0/512.0 * vec2(dot(T,gl_LightSource[0].position.xyz),
123 // dot(B,gl_LightSource[0].position.xyz));
124
125 gl_TexCoord[2] = vec4(pos.xyz, 1.0);
126 default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
127
128} \ No newline at end of file
diff --git a/linden/indra/newview/app_settings/shaders/class3/environment/groundF.glsl b/linden/indra/newview/app_settings/shaders/class3/environment/groundF.glsl
new file mode 100644
index 0000000..8618dad
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/environment/groundF.glsl
@@ -0,0 +1,12 @@
1vec4 getScatter(vec3 viewVec, vec3 lightDir);
2
3varying vec3 lightd;
4varying vec3 viewVec;
5
6void main()
7{
8 vec4 color = gl_Color;
9 vec4 haze = getScatter(viewVec, lightd) * vec4(gl_Fog.color.rgb, 1.0);
10 color.rgb = haze.rgb + haze.a * color.rgb;
11 gl_FragColor = color;
12}
diff --git a/linden/indra/newview/app_settings/shaders/class3/environment/groundV.glsl b/linden/indra/newview/app_settings/shaders/class3/environment/groundV.glsl
new file mode 100644
index 0000000..a6f5270
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/environment/groundV.glsl
@@ -0,0 +1,11 @@
1varying vec3 lightd;
2varying vec3 viewVec;
3
4void main()
5{
6 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
7 lightd = gl_LightSource[0].position.xyz;
8 viewVec = (gl_ModelViewMatrix * gl_Vertex).xyz;
9
10 gl_FrontColor = gl_Color;
11}
diff --git a/linden/indra/newview/app_settings/shaders/class3/environment/scatterF.glsl b/linden/indra/newview/app_settings/shaders/class3/environment/scatterF.glsl
new file mode 100644
index 0000000..7a9245f
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/environment/scatterF.glsl
@@ -0,0 +1,25 @@
1uniform sampler2D scatterMap;
2
3//for per-pixel scatter
4vec4 getScatter(vec3 viewVec, vec3 lightDir)
5{
6 vec2 scatterCoord;
7 scatterCoord.x = length(viewVec);
8 vec3 normVec = viewVec / scatterCoord.x;
9 scatterCoord.y = dot(normVec, lightDir)*0.5 + 0.5;
10 scatterCoord.x = scatterCoord.x / gl_Fog.end;
11 scatterCoord.x *= scatterCoord.x; // HACK!! Remove this when we can push the view distance farther out
12 return texture2D(scatterMap, scatterCoord) * vec4(gl_Fog.color.rgb, 1.0);
13}
14
15void applyScatter(inout vec3 color, vec4 haze)
16{
17 color.rgb = haze.rgb + haze.a * color.rgb;
18}
19
20//for per-vertex scatter
21void applyScatter(inout vec3 color)
22{
23 vec4 haze = texture2D(scatterMap, gl_TexCoord[5].xy) * vec4(gl_Fog.color.rgb, 1.0);
24 color.rgb = haze.rgb + haze.a * color.rgb;
25}
diff --git a/linden/indra/newview/app_settings/shaders/class3/environment/scatterV.glsl b/linden/indra/newview/app_settings/shaders/class3/environment/scatterV.glsl
new file mode 100644
index 0000000..c9ebd9e
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/environment/scatterV.glsl
@@ -0,0 +1,16 @@
1
2vec2 getScatterCoord(vec3 viewVec, vec3 lightDir)
3{
4 vec2 scatterCoord;
5 scatterCoord.x = length(viewVec);
6 vec3 normVec = normalize(viewVec);
7 scatterCoord.y = dot(normVec, lightDir)*0.5 + 0.5;
8 scatterCoord.x = scatterCoord.x / gl_Fog.end;
9 scatterCoord.x *= scatterCoord.x; // HACK!! Remove this when we can push the view distance farther out
10 return scatterCoord;
11}
12
13void default_scatter(vec3 viewVec, vec3 lightDir)
14{
15 gl_TexCoord[5].xy = getScatterCoord(viewVec, lightDir);
16}
diff --git a/linden/indra/newview/app_settings/shaders/class3/objects/bumpshinyF.glsl b/linden/indra/newview/app_settings/shaders/class3/objects/bumpshinyF.glsl
new file mode 100644
index 0000000..9d1a91d
--- /dev/null
+++ b/linden/indra/newview/app_settings/shaders/class3/objects/bumpshinyF.glsl
@@ -0,0 +1,25 @@
1vec4 getLightColor();
2void applyScatter(inout vec3 col);
3
4uniform samplerCube environmentMap;
5uniform sampler2D diffuseMap;
6uniform sampler2D bumpMap;
7
8void main()
9{
10 vec4 diff = texture2D(diffuseMap, gl_TexCoord[0].xy);
11 float b = texture2D(bumpMap, gl_TexCoord[0].xy).a;
12 b -= texture2D(bumpMap, gl_TexCoord[2].xy).a;
13 vec3 ref = textureCube(environmentMap, gl_TexCoord[1].xyz*vec3(1.0,1.0,1.0-b*5.0)).rgb;
14 vec4 specular = gl_TexCoord[3];
15 vec3 col = mix(getLightColor().rgb * diff.rgb, ref, specular.a)+specular.rgb*diff.rgb;
16 col += col * b;
17 float m = (col.r + col.g + col.b);
18 m *= 1.0/3.0;
19 col = mix(col, vec3(m), -specular.a*specular.a);
20
21 applyScatter(col);
22
23 gl_FragColor.rgb = col;
24 gl_FragColor.a = diff.a;
25}