summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1
diff options
context:
space:
mode:
authorJames Cook <james@lindenlab.com>2007-01-02 08:33:20 +0000
committerJames Cook <james@lindenlab.com>2007-01-02 08:33:20 +0000
commit420b91db29485df39fd6e724e782c449158811cb (patch)
treeb471a94563af914d3ed3edd3e856d21cb1b69945 /indra/newview/app_settings/shaders/class1
Print done when done.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
-rw-r--r--indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl35
-rw-r--r--indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl20
-rw-r--r--indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl17
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/terrainF.glsl19
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/terrainV.glsl37
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterF.glsl22
-rw-r--r--indra/newview/app_settings/shaders/class1/environment/waterV.glsl41
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/highlightF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/highlightV.glsl20
-rw-r--r--indra/newview/app_settings/shaders/class1/lighting/lightF.glsl31
-rw-r--r--indra/newview/app_settings/shaders/class1/lighting/lightV.glsl99
-rw-r--r--indra/newview/app_settings/shaders/class1/objects/simpleF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/objects/simpleV.glsl21
17 files changed, 413 insertions, 0 deletions
diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl
new file mode 100644
index 0000000000..5731add4d5
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/avatar/avatarF.glsl
@@ -0,0 +1,7 @@
+void default_lighting();
+
+void main()
+{
+ default_lighting();
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl
new file mode 100644
index 0000000000..1fcc001911
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/avatar/avatarSkinV.glsl
@@ -0,0 +1,19 @@
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color);
+
+attribute vec4 weight; //1
+
+uniform vec4 matrixPalette[45];
+
+mat4 getSkinnedTransform()
+{
+ mat4 ret;
+ int i = int(floor(weight.x));
+ float x = fract(weight.x);
+
+ ret[0] = mix(matrixPalette[i+0], matrixPalette[i+1], x);
+ ret[1] = mix(matrixPalette[i+15],matrixPalette[i+16], x);
+ ret[2] = mix(matrixPalette[i+30],matrixPalette[i+31], x);
+ ret[3] = vec4(0,0,0,1);
+
+ return ret;
+}
diff --git a/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl b/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl
new file mode 100644
index 0000000000..50f9b0192e
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/avatar/avatarV.glsl
@@ -0,0 +1,35 @@
+void default_scatter(vec3 viewVec, vec3 lightDir);
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
+mat4 getSkinnedTransform();
+vec2 getScatterCoord(vec3 viewVec, vec3 lightDir);
+
+attribute vec4 materialColor;
+
+void main()
+{
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ vec4 pos;
+ vec3 norm;
+
+ mat4 trans = getSkinnedTransform();
+ pos.x = dot(trans[0], gl_Vertex);
+ pos.y = dot(trans[1], gl_Vertex);
+ pos.z = dot(trans[2], gl_Vertex);
+ pos.w = 1.0;
+
+ norm.x = dot(trans[0].xyz, gl_Normal);
+ norm.y = dot(trans[1].xyz, gl_Normal);
+ norm.z = dot(trans[2].xyz, gl_Normal);
+ norm = normalize(norm);
+
+ gl_Position = gl_ProjectionMatrix * pos;
+
+ //gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+ default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
+
+ vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color);
+ gl_FrontColor = color;
+
+}
diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl
new file mode 100644
index 0000000000..5731add4d5
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/avatar/eyeballF.glsl
@@ -0,0 +1,7 @@
+void default_lighting();
+
+void main()
+{
+ default_lighting();
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl
new file mode 100644
index 0000000000..d436b4e00a
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/avatar/eyeballV.glsl
@@ -0,0 +1,20 @@
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseCol);
+void default_scatter(vec3 viewVec, vec3 lightDir);
+
+attribute vec4 materialColor;
+
+void main()
+{
+ //transform vertex
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+
+ vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
+ vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
+
+ vec4 color = calcLighting(pos, norm, materialColor, gl_Color.rgb);
+ default_scatter(pos, gl_LightSource[0].position.xyz);
+
+ gl_FrontColor = color;
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl
new file mode 100644
index 0000000000..b311afb59c
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarF.glsl
@@ -0,0 +1,6 @@
+uniform sampler2D diffuseMap;
+
+void main()
+{
+ gl_FragColor = vec4(gl_Color.rgb, texture2D(diffuseMap, gl_TexCoord[0].xy).a);
+}
diff --git a/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl
new file mode 100644
index 0000000000..b6dcbe1693
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/avatar/pickAvatarV.glsl
@@ -0,0 +1,17 @@
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color);
+mat4 getSkinnedTransform();
+
+void main()
+{
+ vec4 pos;
+
+ mat4 trans = getSkinnedTransform();
+ pos.x = dot(trans[0], gl_Vertex);
+ pos.y = dot(trans[1], gl_Vertex);
+ pos.z = dot(trans[2], gl_Vertex);
+ pos.w = 1.0;
+
+ gl_FrontColor = gl_Color;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_Position = gl_ProjectionMatrix * pos;
+} \ No newline at end of file
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
new file mode 100644
index 0000000000..fde370155d
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainF.glsl
@@ -0,0 +1,19 @@
+void terrain_lighting(inout vec3 color);
+
+uniform sampler2D detail0; //0
+uniform sampler2D detail1; //2
+uniform sampler2D alphaRamp; //1
+
+
+void main()
+{
+ float a = texture2D(alphaRamp, gl_TexCoord[1].xy).a;
+ vec3 color = mix(texture2D(detail1, gl_TexCoord[2].xy).rgb,
+ texture2D(detail0, gl_TexCoord[0].xy).rgb,
+ a);
+
+ terrain_lighting(color);
+
+ gl_FragColor.rgb = color;
+ gl_FragColor.a = texture2D(alphaRamp, gl_TexCoord[3].xy).a;
+}
diff --git a/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
new file mode 100644
index 0000000000..3153a80e93
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/environment/terrainV.glsl
@@ -0,0 +1,37 @@
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
+void default_scatter(vec3 viewVec, vec3 lightDir);
+
+attribute vec4 materialColor;
+
+vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
+{
+ vec4 tcoord;
+
+ tcoord.x = dot(vpos, tp0);
+ tcoord.y = dot(vpos, tp1);
+ tcoord.z = tc.z;
+ tcoord.w = tc.w;
+
+ tcoord = mat * tcoord;
+
+ return tcoord;
+}
+
+void main()
+{
+ //transform vertex
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+ vec4 pos = gl_ModelViewMatrix * gl_Vertex;
+ vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
+
+ vec4 color = calcLighting(pos.xyz, norm, materialColor, gl_Color);
+
+ gl_FrontColor = color;
+
+ gl_TexCoord[0] = texgen_object(gl_Vertex,gl_MultiTexCoord0,gl_TextureMatrix[0],gl_ObjectPlaneS[0],gl_ObjectPlaneT[0]);
+ gl_TexCoord[1] = gl_TextureMatrix[1]*gl_MultiTexCoord1;
+ gl_TexCoord[2] = texgen_object(gl_Vertex,gl_MultiTexCoord2,gl_TextureMatrix[2],gl_ObjectPlaneS[2],gl_ObjectPlaneT[2]);
+ gl_TexCoord[3] = gl_TextureMatrix[3]*gl_MultiTexCoord3;
+ default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
+}
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
new file mode 100644
index 0000000000..f8b8031ce6
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl
@@ -0,0 +1,22 @@
+void water_lighting(inout vec3 diff);
+
+uniform samplerCube environmentMap;
+uniform sampler2D diffuseMap;
+uniform sampler2D bumpMap;
+
+varying vec4 specular;
+
+void main()
+{
+ vec4 depth = texture2D(diffuseMap, gl_TexCoord[0].xy);
+ vec4 diff = texture2D(bumpMap, gl_TexCoord[1].xy);
+ vec3 ref = textureCube(environmentMap, gl_TexCoord[2].xyz).rgb;
+
+ diff.rgb *= depth.rgb;
+
+ vec3 col = mix(diff.rgb, ref, specular.a)+specular.rgb*diff.rgb;
+
+ water_lighting(col.rgb);
+ gl_FragColor.rgb = col.rgb;
+ gl_FragColor.a = (gl_Color.a+depth.a)*0.5;
+}
diff --git a/indra/newview/app_settings/shaders/class1/environment/waterV.glsl b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
new file mode 100644
index 0000000000..873a6fcb34
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/environment/waterV.glsl
@@ -0,0 +1,41 @@
+void default_scatter(vec3 viewVec, vec3 lightDir);
+vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol);
+vec2 getScatterCoord(vec3 viewVec, vec3 lightDir);
+
+varying vec4 specular;
+
+vec4 texgen_object(vec4 vpos, vec4 tc, mat4 mat, vec4 tp0, vec4 tp1)
+{
+ vec4 tcoord;
+
+ tcoord.x = dot(vpos, tp0);
+ tcoord.y = dot(vpos, tp1);
+ tcoord.z = tc.z;
+ tcoord.w = tc.w;
+
+ tcoord = mat * tcoord;
+
+ return tcoord;
+}
+
+void main()
+{
+ //transform vertex
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+ gl_TexCoord[1] = texgen_object(gl_Vertex, gl_MultiTexCoord1, gl_TextureMatrix[1], gl_ObjectPlaneS[1],gl_ObjectPlaneT[1]);
+
+ vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
+ vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
+ vec4 spec = gl_Color;
+ gl_FrontColor.rgb = calcLightingSpecular(pos, norm, gl_Color, spec, vec3(0.0, 0.0, 0.0)).rgb;
+ gl_FrontColor.a = gl_Color.a;
+ specular = spec;
+ specular.a = gl_Color.a*0.5;
+ vec3 ref = reflect(pos,norm);
+
+ gl_TexCoord[2] = gl_TextureMatrix[2]*vec4(ref,1);
+
+ default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl
new file mode 100644
index 0000000000..1e342fb51b
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/interface/highlightF.glsl
@@ -0,0 +1,6 @@
+uniform sampler2D diffuseMap;
+
+void main()
+{
+ gl_FragColor = gl_Color*texture2D(diffuseMap, gl_TexCoord[0].xy);
+}
diff --git a/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl
new file mode 100644
index 0000000000..bb6707b2a9
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/interface/highlightV.glsl
@@ -0,0 +1,20 @@
+attribute vec4 materialColor;
+
+void main()
+{
+ //transform vertex
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
+ pos = normalize(pos);
+ float d = dot(pos, normalize(gl_NormalMatrix * gl_Normal));
+ d *= d;
+ d = 1.0 - d;
+ d *= d;
+
+ d = min(d, materialColor.a*2.0);
+
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+ gl_FrontColor.rgb = materialColor.rgb;
+ gl_FrontColor.a = max(d, materialColor.a);
+}
+
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl
new file mode 100644
index 0000000000..b2a6d67621
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightF.glsl
@@ -0,0 +1,31 @@
+void applyScatter(inout vec3 color);
+
+uniform sampler2D diffuseMap;
+
+void default_lighting()
+{
+ vec4 color = gl_Color * texture2D(diffuseMap, gl_TexCoord[0].xy);
+ applyScatter(color.rgb);
+ gl_FragColor = color;
+}
+
+void alpha_lighting()
+{
+ default_lighting();
+}
+
+void water_lighting(inout vec3 diff)
+{
+ applyScatter(diff);
+}
+
+void terrain_lighting(inout vec3 color)
+{
+ color.rgb *= gl_Color.rgb;
+ applyScatter(color);
+}
+
+vec4 getLightColor()
+{
+ return gl_Color;
+} \ No newline at end of file
diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl
new file mode 100644
index 0000000000..e3816318a1
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl
@@ -0,0 +1,99 @@
+
+float calcDirectionalLight(vec3 n, vec3 l)
+{
+ float a = max(dot(n,l),0.0);
+ return a;
+}
+
+float calcPointLight(vec3 v, vec3 n, vec3 l, float r, float pw)
+{
+ //get light vector
+ vec3 lv = l-v;
+
+ //get distance
+ float d = length(lv);
+
+ //normalize light vector
+ lv *= 1.0/d;
+
+ //distance attenuation
+ float da = max((r-d)/r, 0.0);
+
+ //da = pow(da, pw);
+
+ //angular attenuation
+ da *= calcDirectionalLight(n, lv);
+
+ return da;
+}
+
+float calcDirectionalSpecular(vec3 view, vec3 n, vec3 l)
+{
+ float a = max(dot(n,l),0.0);
+ return a;
+}
+
+float calcDirectionalLightSpecular(inout vec4 specular, vec3 view, vec3 n, vec3 l, vec3 lightCol, float da)
+{
+
+ specular.rgb += calcDirectionalSpecular(view,n,l)*lightCol*da;
+ return calcDirectionalLight(n,l);
+}
+
+vec3 calcPointLightSpecular(inout vec4 specular, vec3 view, vec3 v, vec3 n, vec3 l, float r, float pw, vec3 lightCol)
+{
+ //get light vector
+ vec3 lv = l-v;
+
+ //get distance
+ float d = length(lv);
+
+ //normalize light vector
+ lv *= 1.0/d;
+
+ //distance attenuation
+ float da = clamp((r-d)/r, 0.0, 1.0);
+
+ //da = pow(da, pw);
+
+ //angular attenuation
+ da *= calcDirectionalLightSpecular(specular, view, n, lv, lightCol, da);
+
+ return da*lightCol;
+}
+
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseLight)
+{
+ vec4 col;
+ col.a = color.a;
+
+ col.rgb = gl_LightModel.ambient.rgb + baseLight.rgb;
+
+ col.rgb += gl_LightSource[0].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[0].position.xyz);
+ col.rgb += gl_LightSource[1].diffuse.rgb*calcDirectionalLight(norm, gl_LightSource[1].position.xyz);
+
+ col.rgb = min(col.rgb*color.rgb, 1.0);
+
+ return col;
+}
+
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec3 baseLight)
+{
+ return calcLighting(pos, norm, color, vec4(baseLight, 1.0));
+}
+
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color)
+{
+ return calcLighting(pos, norm, color, vec3(0.0,0.0,0.0));
+}
+
+vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec4 baseCol)
+{
+ specularColor.rgb = vec3(0.0, 0.0, 0.0);
+ return calcLighting(pos, norm, color, baseCol);
+}
+
+vec4 calcLightingSpecular(vec3 pos, vec3 norm, vec4 color, inout vec4 specularColor, vec3 baseCol)
+{
+ return calcLightingSpecular(pos, norm, color, specularColor, vec4(baseCol, 1.0));
+}
diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl
new file mode 100644
index 0000000000..ce5ab12b74
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/objects/simpleF.glsl
@@ -0,0 +1,6 @@
+void default_lighting();
+
+void main()
+{
+ default_lighting();
+}
diff --git a/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl b/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl
new file mode 100644
index 0000000000..2aa3521931
--- /dev/null
+++ b/indra/newview/app_settings/shaders/class1/objects/simpleV.glsl
@@ -0,0 +1,21 @@
+vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseCol);
+void default_scatter(vec3 viewVec, vec3 lightDir);
+
+attribute vec4 materialColor;
+
+void main()
+{
+ //transform vertex
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ gl_TexCoord[0] = gl_TextureMatrix[0] * gl_MultiTexCoord0;
+
+ vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
+ vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
+
+ default_scatter(pos, gl_LightSource[0].position.xyz);
+
+ vec4 color = calcLighting(pos, norm, materialColor, gl_Color);
+ gl_FrontColor = color;
+
+ gl_FogFragCoord = pos.z;
+}