summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders
diff options
context:
space:
mode:
authorDon Kjer <don@lindenlab.com>2011-06-13 02:48:52 +0000
committerDon Kjer <don@lindenlab.com>2011-06-13 02:48:52 +0000
commit45c6dcbe87fbfc1351e4faa9ef3196a191b7dd69 (patch)
tree4fe43929cb518d67e8afbd227db3bc62e4d175e5 /indra/newview/app_settings/shaders
parent694b0838bc80efc152e7ecda09ffdc7a944b7079 (diff)
parent12d9d1d3ef76518171ae87aae2467593218f8413 (diff)
Merge
Diffstat (limited to 'indra/newview/app_settings/shaders')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl25
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl25
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl25
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl61
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl25
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl25
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl25
7 files changed, 124 insertions, 87 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
index 5addbbb176..65d9209983 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaSkinnedV.glsl
@@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
//get distance
float d = length(lv);
- //normalize light vector
- lv *= 1.0/d;
+ float da = 0.0;
+
+ if (d > 0.0 && la > 0.0 && fa > 0.0)
+ {
+ //normalize light vector
+ lv *= 1.0/d;
- //distance attenuation
- float dist2 = d*d/(la*la);
- float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ //distance attenuation
+ float dist2 = d*d/(la*la);
+ da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
- // spotlight coefficient.
- float spot = max(dot(-ln, lv), is_pointlight);
- da *= spot*spot; // GL_SPOT_EXPONENT=2
+ // spotlight coefficient.
+ float spot = max(dot(-ln, lv), is_pointlight);
+ da *= spot*spot; // GL_SPOT_EXPONENT=2
- //angular attenuation
- da *= calcDirectionalLight(n, lv);
+ //angular attenuation
+ da *= calcDirectionalLight(n, lv);
+ }
return da;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
index 525b68c437..2691fc8ded 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaV.glsl
@@ -36,19 +36,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
//get distance
float d = length(lv);
- //normalize light vector
- lv *= 1.0/d;
+ float da = 0.0;
+
+ if (d > 0.0 && la > 0.0 && fa > 0.0)
+ {
+ //normalize light vector
+ lv *= 1.0/d;
- //distance attenuation
- float dist2 = d*d/(la*la);
- float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ //distance attenuation
+ float dist2 = d*d/(la*la);
+ da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
- // spotlight coefficient.
- float spot = max(dot(-ln, lv), is_pointlight);
- da *= spot*spot; // GL_SPOT_EXPONENT=2
+ // spotlight coefficient.
+ float spot = max(dot(-ln, lv), is_pointlight);
+ da *= spot*spot; // GL_SPOT_EXPONENT=2
- //angular attenuation
- da *= calcDirectionalLight(n, lv);
+ //angular attenuation
+ da *= calcDirectionalLight(n, lv);
+ }
return da;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
index a2a7dea20d..a012cb5030 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/avatarAlphaV.glsl
@@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
//get distance
float d = length(lv);
- //normalize light vector
- lv *= 1.0/d;
+ float da = 0.0;
+
+ if (d > 0.0 && la > 0.0 && fa > 0.0)
+ {
+ //normalize light vector
+ lv *= 1.0/d;
- //distance attenuation
- float dist2 = d*d/(la*la);
- float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ //distance attenuation
+ float dist2 = d*d/(la*la);
+ da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
- // spotlight coefficient.
- float spot = max(dot(-ln, lv), is_pointlight);
- da *= spot*spot; // GL_SPOT_EXPONENT=2
+ // spotlight coefficient.
+ float spot = max(dot(-ln, lv), is_pointlight);
+ da *= spot*spot; // GL_SPOT_EXPONENT=2
- //angular attenuation
- da *= calcDirectionalLight(n, lv);
+ //angular attenuation
+ da *= calcDirectionalLight(n, lv);
+ }
return da;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index c5ddf31ac0..609fc4f14f 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -23,8 +23,9 @@ uniform float sun_wash;
uniform int light_count;
-uniform vec4 light[16];
-uniform vec4 light_col[16];
+#define MAX_LIGHT_COUNT 16
+uniform vec4 light[MAX_LIGHT_COUNT];
+uniform vec4 light_col[MAX_LIGHT_COUNT];
varying vec4 vary_fragcoord;
uniform vec2 screen_res;
@@ -63,50 +64,56 @@ void main()
float noise = texture2D(noiseMap, frag.xy/128.0).b;
vec3 out_col = vec3(0,0,0);
vec3 npos = normalize(-pos);
-
- for (int i = 0; i < light_count; ++i)
+
+ // As of OSX 10.6.7 ATI Apple's crash when using a variable size loop
+ for (int i = 0; i < MAX_LIGHT_COUNT; ++i)
{
+ bool light_contrib = (i < light_count);
+
vec3 lv = light[i].xyz-pos;
float dist2 = dot(lv,lv);
dist2 /= light[i].w;
if (dist2 > 1.0)
{
- continue;
+ light_contrib = false;
}
float da = dot(norm, lv);
if (da < 0.0)
{
- continue;
+ light_contrib = false;
}
-
- lv = normalize(lv);
- da = dot(norm, lv);
-
- float fa = light_col[i].a+1.0;
- float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
- dist_atten *= noise;
-
- float lit = da * dist_atten;
- vec3 col = light_col[i].rgb*lit*diff;
- //vec3 col = vec3(dist2, light_col[i].a, lit);
-
- if (spec.a > 0.0)
+ if (light_contrib)
{
- //vec3 ref = dot(pos+lv, norm);
+ lv = normalize(lv);
+ da = dot(norm, lv);
+
+ float fa = light_col[i].a+1.0;
+ float dist_atten = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ dist_atten *= noise;
+
+ float lit = da * dist_atten;
- float sa = dot(normalize(lv+npos),norm);
+ vec3 col = light_col[i].rgb*lit*diff;
+ //vec3 col = vec3(dist2, light_col[i].a, lit);
- if (sa > 0.0)
+ if (spec.a > 0.0)
{
- sa = texture2D(lightFunc,vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
- sa *= noise;
- col += da*sa*light_col[i].rgb*spec.rgb;
+ //vec3 ref = dot(pos+lv, norm);
+
+ float sa = dot(normalize(lv+npos),norm);
+
+ if (sa > 0.0)
+ {
+ sa = texture2D(lightFunc,vec2(sa, spec.a)).a * min(dist_atten*4.0, 1.0);
+ sa *= noise;
+ col += da*sa*light_col[i].rgb*spec.rgb;
+ }
}
+
+ out_col += col;
}
-
- out_col += col;
}
if (dot(out_col, out_col) <= 0.0)
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
index d227346163..dfb36980b0 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaSkinnedV.glsl
@@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
//get distance
float d = length(lv);
- //normalize light vector
- lv *= 1.0/d;
+ float da = 0.0;
+
+ if (d > 0.0 && la > 0.0 && fa > 0.0)
+ {
+ //normalize light vector
+ lv *= 1.0/d;
- //distance attenuation
- float dist2 = d*d/(la*la);
- float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ //distance attenuation
+ float dist2 = d*d/(la*la);
+ da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
- // spotlight coefficient.
- float spot = max(dot(-ln, lv), is_pointlight);
- da *= spot*spot; // GL_SPOT_EXPONENT=2
+ // spotlight coefficient.
+ float spot = max(dot(-ln, lv), is_pointlight);
+ da *= spot*spot; // GL_SPOT_EXPONENT=2
- //angular attenuation
- da *= calcDirectionalLight(n, lv);
+ //angular attenuation
+ da *= calcDirectionalLight(n, lv);
+ }
return da;
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
index 86f014df35..f6160815eb 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/alphaV.glsl
@@ -35,19 +35,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
//get distance
float d = length(lv);
- //normalize light vector
- lv *= 1.0/d;
+ float da = 0.0;
+
+ if (d > 0.0 && la > 0.0 && fa > 0.0)
+ {
+ //normalize light vector
+ lv *= 1.0/d;
- //distance attenuation
- float dist2 = d*d/(la*la);
- float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ //distance attenuation
+ float dist2 = d*d/(la*la);
+ da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
- // spotlight coefficient.
- float spot = max(dot(-ln, lv), is_pointlight);
- da *= spot*spot; // GL_SPOT_EXPONENT=2
+ // spotlight coefficient.
+ float spot = max(dot(-ln, lv), is_pointlight);
+ da *= spot*spot; // GL_SPOT_EXPONENT=2
- //angular attenuation
- da *= calcDirectionalLight(n, lv);
+ //angular attenuation
+ da *= calcDirectionalLight(n, lv);
+ }
return da;
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
index 495e86c8db..0ae09df0c6 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/avatarAlphaV.glsl
@@ -37,19 +37,24 @@ float calcPointLightOrSpotLight(vec3 v, vec3 n, vec4 lp, vec3 ln, float la, floa
//get distance
float d = length(lv);
- //normalize light vector
- lv *= 1.0/d;
+ float da = 0.0;
+
+ if (d > 0.0 && la > 0.0 && fa > 0.0)
+ {
+ //normalize light vector
+ lv *= 1.0/d;
- //distance attenuation
- float dist2 = d*d/(la*la);
- float da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ //distance attenuation
+ float dist2 = d*d/(la*la);
+ da = clamp(1.0-(dist2-1.0*(1.0-fa))/fa, 0.0, 1.0);
- // spotlight coefficient.
- float spot = max(dot(-ln, lv), is_pointlight);
- da *= spot*spot; // GL_SPOT_EXPONENT=2
+ // spotlight coefficient.
+ float spot = max(dot(-ln, lv), is_pointlight);
+ da *= spot*spot; // GL_SPOT_EXPONENT=2
- //angular attenuation
- da *= calcDirectionalLight(n, lv);
+ //angular attenuation
+ da *= calcDirectionalLight(n, lv);
+ }
return da;
}