aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/newview/app_settings
diff options
context:
space:
mode:
Diffstat (limited to 'linden/indra/newview/app_settings')
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl26
-rw-r--r--linden/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl54
-rw-r--r--linden/indra/newview/app_settings/shaders/class3/environment/waterF.glsl290
3 files changed, 185 insertions, 185 deletions
diff --git a/linden/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl b/linden/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl
index 12c99a6..6942132 100644
--- a/linden/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/objects/shinyF.glsl
@@ -1,13 +1,13 @@
1void applyScatter(inout vec3 col); 1void applyScatter(inout vec3 col);
2 2
3uniform samplerCube environmentMap; 3uniform samplerCube environmentMap;
4 4
5void main() 5void main()
6{ 6{
7 vec3 ref = textureCube(environmentMap, gl_TexCoord[0].xyz).rgb; 7 vec3 ref = textureCube(environmentMap, gl_TexCoord[0].xyz).rgb;
8 8
9 applyScatter(ref); 9 applyScatter(ref);
10 10
11 gl_FragColor.rgb = ref; 11 gl_FragColor.rgb = ref;
12 gl_FragColor.a = gl_Color.a; 12 gl_FragColor.a = gl_Color.a;
13} 13}
diff --git a/linden/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl b/linden/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl
index 621ff6b..16fba01 100644
--- a/linden/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl
+++ b/linden/indra/newview/app_settings/shaders/class1/objects/shinyV.glsl
@@ -1,27 +1,27 @@
1void default_scatter(vec3 viewVec, vec3 lightDir); 1void default_scatter(vec3 viewVec, vec3 lightDir);
2 2
3uniform vec4 origin; 3uniform vec4 origin;
4 4
5void main() 5void main()
6{ 6{
7 //transform vertex 7 //transform vertex
8 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; 8 gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
9 9
10 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz; 10 vec3 pos = (gl_ModelViewMatrix * gl_Vertex).xyz;
11 vec3 norm = normalize(gl_NormalMatrix * gl_Normal); 11 vec3 norm = normalize(gl_NormalMatrix * gl_Normal);
12 12
13 gl_FrontColor = gl_Color; 13 gl_FrontColor = gl_Color;
14 14
15 vec3 ref = reflect(pos, norm); 15 vec3 ref = reflect(pos, norm);
16 16
17 vec3 d = pos - origin.xyz; 17 vec3 d = pos - origin.xyz;
18 float dist = dot(normalize(d), ref); 18 float dist = dot(normalize(d), ref);
19 vec3 e = d + (ref * max(origin.w-dist, 0.0)); 19 vec3 e = d + (ref * max(origin.w-dist, 0.0));
20 20
21 ref = e - origin.xyz; 21 ref = e - origin.xyz;
22 22
23 gl_TexCoord[0] = gl_TextureMatrix[0]*vec4(ref,1.0); 23 gl_TexCoord[0] = gl_TextureMatrix[0]*vec4(ref,1.0);
24 24
25 default_scatter(pos.xyz, gl_LightSource[0].position.xyz); 25 default_scatter(pos.xyz, gl_LightSource[0].position.xyz);
26} 26}
27 27
diff --git a/linden/indra/newview/app_settings/shaders/class3/environment/waterF.glsl b/linden/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
index 3a117c5..ac8b07c 100644
--- a/linden/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
+++ b/linden/indra/newview/app_settings/shaders/class3/environment/waterF.glsl
@@ -1,145 +1,145 @@
1void applyScatter(inout vec3 color); 1void applyScatter(inout vec3 color);
2 2
3uniform sampler2D diffuseMap; 3uniform sampler2D diffuseMap;
4uniform sampler2D bumpMap; 4uniform sampler2D bumpMap;
5uniform samplerCube environmentMap; //: TEXUNIT4, // Environment map texture 5uniform samplerCube environmentMap; //: TEXUNIT4, // Environment map texture
6uniform sampler2D screenTex; // : TEXUNIT5 6uniform sampler2D screenTex; // : TEXUNIT5
7 7
8uniform vec3 lightDir; 8uniform vec3 lightDir;
9uniform vec3 specular; 9uniform vec3 specular;
10uniform float lightExp; 10uniform float lightExp;
11uniform vec2 fbScale; 11uniform vec2 fbScale;
12uniform float refScale; 12uniform float refScale;
13 13
14float msin(float x) { 14float msin(float x) {
15 float k = sin(x)+1.0; 15 float k = sin(x)+1.0;
16 k *= 0.5; 16 k *= 0.5;
17 k *= k; 17 k *= k;
18 return 2.0 * k; 18 return 2.0 * k;
19} 19}
20 20
21float mcos(float x) { 21float mcos(float x) {
22 float k = cos(x)+1.0; 22 float k = cos(x)+1.0;
23 k *= 0.5; 23 k *= 0.5;
24 k *= k; 24 k *= k;
25 return 2.0 * k; 25 return 2.0 * k;
26} 26}
27 27
28float waveS(vec2 v, float t, float a, float f, vec2 d, float s, sampler1D sinMap) 28float waveS(vec2 v, float t, float a, float f, vec2 d, float s, sampler1D sinMap)
29{ 29{
30 return texture1D(sinMap, (dot(d, v)*f + t*s)*f).r*a; 30 return texture1D(sinMap, (dot(d, v)*f + t*s)*f).r*a;
31} 31}
32 32
33float waveC(vec2 v, float t, float a, float f, vec2 d, float s, sampler1D sinMap) 33float waveC(vec2 v, float t, float a, float f, vec2 d, float s, sampler1D sinMap)
34{ 34{
35 return texture1D(sinMap, (dot(d, v)*f + t*s)*f).g*a*2.0-1.0; 35 return texture1D(sinMap, (dot(d, v)*f + t*s)*f).g*a*2.0-1.0;
36} 36}
37 37
38float magnitude(vec3 vec) { 38float magnitude(vec3 vec) {
39 return sqrt(dot(vec,vec)); 39 return sqrt(dot(vec,vec));
40} 40}
41 41
42vec3 mreflect(vec3 i, vec3 n) { 42vec3 mreflect(vec3 i, vec3 n) {
43 return i + n * 2.0 * abs(dot(n,i))+vec3(0.0,0.0,0.5); 43 return i + n * 2.0 * abs(dot(n,i))+vec3(0.0,0.0,0.5);
44} 44}
45 45
46void main() 46void main()
47{ 47{
48 vec2 texCoord = gl_TexCoord[0].xy; // Texture coordinates 48 vec2 texCoord = gl_TexCoord[0].xy; // Texture coordinates
49 vec2 littleWave1 = gl_TexCoord[0].zw; 49 vec2 littleWave1 = gl_TexCoord[0].zw;
50 vec2 littleWave2 = gl_TexCoord[1].xy; 50 vec2 littleWave2 = gl_TexCoord[1].xy;
51 vec2 bigWave = gl_TexCoord[1].zw; 51 vec2 bigWave = gl_TexCoord[1].zw;
52 vec3 viewVec = gl_TexCoord[2].xyz; 52 vec3 viewVec = gl_TexCoord[2].xyz;
53 vec4 refCoord = gl_TexCoord[3]; 53 vec4 refCoord = gl_TexCoord[3];
54 vec4 col = gl_Color; 54 vec4 col = gl_Color;
55 vec4 color; 55 vec4 color;
56 56
57 //get color from alpha map (alpha denotes water depth), rgb denotes water color 57 //get color from alpha map (alpha denotes water depth), rgb denotes water color
58 vec4 wcol = texture2D(diffuseMap, texCoord.xy); 58 vec4 wcol = texture2D(diffuseMap, texCoord.xy);
59 59
60 float dist = length(viewVec); 60 float dist = length(viewVec);
61 61
62 //store texture alpha 62 //store texture alpha
63 float da = wcol.a; 63 float da = wcol.a;
64 64
65 //modulate by incoming water color 65 //modulate by incoming water color
66 //wcol.a *= refCoord.w; 66 //wcol.a *= refCoord.w;
67 67
68 //scale wcol.a (water depth) for steep transition 68 //scale wcol.a (water depth) for steep transition
69 wcol.a *= wcol.a; 69 wcol.a *= wcol.a;
70 70
71 //normalize view vector 71 //normalize view vector
72 viewVec = normalize(viewVec); 72 viewVec = normalize(viewVec);
73 73
74 //get bigwave normal 74 //get bigwave normal
75 vec3 wavef = texture2D(bumpMap, bigWave).xyz*2.0; 75 vec3 wavef = texture2D(bumpMap, bigWave).xyz*2.0;
76 76
77 vec3 view = vec3(viewVec.x, viewVec.y, viewVec.z); 77 vec3 view = vec3(viewVec.x, viewVec.y, viewVec.z);
78 78
79 float dx = 1.0-(dot(wavef*2.0-vec3(1.0), view))*da; 79 float dx = 1.0-(dot(wavef*2.0-vec3(1.0), view))*da;
80 dx *= 0.274; 80 dx *= 0.274;
81 81
82 //get detail normals 82 //get detail normals
83 vec3 dcol = texture2D(bumpMap, littleWave1+dx*view.xy).rgb*0.75; 83 vec3 dcol = texture2D(bumpMap, littleWave1+dx*view.xy).rgb*0.75;
84 dcol += texture2D(bumpMap, littleWave2+view.xy*dx*0.1).rgb*1.25; 84 dcol += texture2D(bumpMap, littleWave2+view.xy*dx*0.1).rgb*1.25;
85 85
86 //interpolate between big waves and little waves (big waves in deep water) 86 //interpolate between big waves and little waves (big waves in deep water)
87 wavef = wavef*wcol.a + dcol*(1.0-wcol.a); 87 wavef = wavef*wcol.a + dcol*(1.0-wcol.a);
88 88
89 //crunch normal to range [-1,1] 89 //crunch normal to range [-1,1]
90 wavef -= vec3(1,1,1); 90 wavef -= vec3(1,1,1);
91 wavef = normalize(wavef); 91 wavef = normalize(wavef);
92 //wavef = vec3(0.0, 0.0, 1.0); 92 //wavef = vec3(0.0, 0.0, 1.0);
93 93
94 //get base fresnel component 94 //get base fresnel component
95 float df = dot(viewVec,wavef); 95 float df = dot(viewVec,wavef);
96 //translate and flip fresnel 96 //translate and flip fresnel
97 df = 1.0-clamp(-df,0.0,1.0); 97 df = 1.0-clamp(-df,0.0,1.0);
98 98
99 //set output alpha based on fresnel 99 //set output alpha based on fresnel
100 color.a = clamp((1.0-df+da)*0.5,0.0,1.0); 100 color.a = clamp((1.0-df+da)*0.5,0.0,1.0);
101 101
102 //calculate reflection vector 102 //calculate reflection vector
103 vec3 refnorm = vec3(wavef.x*0.5, wavef.y*0.5, wavef.z*2.0); 103 vec3 refnorm = vec3(wavef.x*0.5, wavef.y*0.5, wavef.z*2.0);
104 104
105 //ramp normal towards eye for far view stuff 105 //ramp normal towards eye for far view stuff
106 float ramp = dist/256.0; 106 float ramp = dist/256.0;
107 refnorm -= viewVec * ramp; 107 refnorm -= viewVec * ramp;
108 vec3 ref = reflect(viewVec.xyz, normalize(refnorm)); 108 vec3 ref = reflect(viewVec.xyz, normalize(refnorm));
109 ref.z /= sqrt(dist); 109 ref.z /= sqrt(dist);
110 110
111 //get diffuse component 111 //get diffuse component
112 float diff = clamp(dot(ref, wavef),0.0,1.0)*0.9; 112 float diff = clamp(dot(ref, wavef),0.0,1.0)*0.9;
113 113
114 //fudge diffuse for extra contrast and ambience 114 //fudge diffuse for extra contrast and ambience
115 diff *= diff; 115 diff *= diff;
116 diff += 0.4; 116 diff += 0.4;
117 117
118 vec3 fog = gl_TexCoord[5].rgb*0.5; 118 vec3 fog = gl_TexCoord[5].rgb*0.5;
119 119
120 //read from reflection map 120 //read from reflection map
121 vec3 refcol = textureCube(environmentMap, ref).rgb; 121 vec3 refcol = textureCube(environmentMap, ref).rgb;
122 //tint reflection by fresnal, bias by z component of view vec 122 //tint reflection by fresnal, bias by z component of view vec
123 color.rgb = refcol*(df*df*dcol.x*dcol.y); 123 color.rgb = refcol*(df*df*dcol.x*dcol.y);
124 124
125 //add diffuse contribution (fake blue water, yay!) 125 //add diffuse contribution (fake blue water, yay!)
126 vec3 blue = vec3(0.1, 0.3, 0.6); 126 vec3 blue = vec3(0.1, 0.3, 0.6);
127 color.rgb += (diff/(max(ramp, 1.0)))*vec3(fog.r*blue.r, fog.g*blue.g, fog.b*blue.b); 127 color.rgb += (diff/(max(ramp, 1.0)))*vec3(fog.r*blue.r, fog.g*blue.g, fog.b*blue.b);
128 128
129 //figure out distortion vector (ripply) 129 //figure out distortion vector (ripply)
130 vec2 distort = clamp(((refCoord.xy/refCoord.z) * 0.5 + 0.5 + wavef.xy*refScale),0.0,0.99); 130 vec2 distort = clamp(((refCoord.xy/refCoord.z) * 0.5 + 0.5 + wavef.xy*refScale),0.0,0.99);
131 131
132 //read from framebuffer (offset) 132 //read from framebuffer (offset)
133 vec4 fb = texture2D(screenTex, distort*fbScale); 133 vec4 fb = texture2D(screenTex, distort*fbScale);
134 134
135 //tint by framebuffer 135 //tint by framebuffer
136 color.rgb = da*color.rgb + (1.0-da)*fb.rgb; 136 color.rgb = da*color.rgb + (1.0-da)*fb.rgb;
137 137
138 //render as solid (previous pixel color already present) 138 //render as solid (previous pixel color already present)
139 color.a = 1.0; 139 color.a = 1.0;
140 140
141 //apply fog 141 //apply fog
142 applyScatter(color.rgb); 142 applyScatter(color.rgb);
143 143
144 gl_FragColor = color; 144 gl_FragColor = color;
145} 145}