summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/environment
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/environment
Print done when done.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/environment')
-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
4 files changed, 119 insertions, 0 deletions
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);
+}
+