summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2013-06-26 11:53:47 -0500
committerDave Parks <davep@lindenlab.com>2013-06-26 11:53:47 -0500
commitb717a28194eb6e5a2f9113c65abe62cb81141413 (patch)
treee89277781b4818ffe54e130546663a398bc62f37 /indra/newview/app_settings/shaders/class1
parent7ede4c4b6e2a86914c452b3e0f465ccf17a1a404 (diff)
parent5595888dd23b0ac526fc520eb20de6e11a2b62ee (diff)
Automated merge with https://bitbucket.org/lindenlab/viewer-development-materials
Diffstat (limited to 'indra/newview/app_settings/shaders/class1')
-rwxr-xr-xindra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl91
1 files changed, 38 insertions, 53 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
index c95aa8bb3c..a955ef6e9d 100755
--- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl
@@ -45,9 +45,8 @@ uniform float sun_wash;
uniform int light_count;
-#define MAX_LIGHT_COUNT 16
-uniform vec4 light[MAX_LIGHT_COUNT];
-uniform vec4 light_col[MAX_LIGHT_COUNT];
+uniform vec4 light[LIGHT_COUNT];
+uniform vec4 light_col[LIGHT_COUNT];
VARYING vec4 vary_fragcoord;
uniform vec2 screen_res;
@@ -105,73 +104,59 @@ void main()
vec3 npos = normalize(-pos);
// 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)
+ for (int i = 0; i < LIGHT_COUNT; ++i)
{
- bool light_contrib = (i < light_count);
-
vec3 lv = light[i].xyz-pos;
float dist = length(lv);
dist /= light[i].w;
- if (dist > 1.0)
+ if (dist <= 1.0)
{
- light_contrib = false;
- }
-
- float da = dot(norm, lv);
- if (da < 0.0)
- {
- light_contrib = false;
- }
-
- if (light_contrib)
- {
- lv = normalize(lv);
- da = dot(norm, lv);
+ float da = dot(norm, lv);
+ if (da > 0.0)
+ {
+ lv = normalize(lv);
+ da = dot(norm, lv);
- float fa = light_col[i].a+1.0;
- float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
- dist_atten *= dist_atten;
- dist_atten *= 2.0;
+ float fa = light_col[i].a+1.0;
+ float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0);
+ dist_atten *= dist_atten;
+ dist_atten *= 2.0;
- dist_atten *= noise;
+ dist_atten *= noise;
- float lit = da * dist_atten;
+ float lit = da * dist_atten;
- vec3 col = light_col[i].rgb*lit*diff;
+ vec3 col = light_col[i].rgb*lit*diff;
- //vec3 col = vec3(dist2, light_col[i].a, lit);
+ //vec3 col = vec3(dist2, light_col[i].a, lit);
- if (spec.a > 0.0)
- {
- lit = min(da*6.0, 1.0) * dist_atten;
- //vec3 ref = dot(pos+lv, norm);
- vec3 h = normalize(lv+npos);
- float nh = dot(norm, h);
- float nv = dot(norm, npos);
- float vh = dot(npos, h);
- float sa = nh;
- float fres = pow(1 - dot(h, npos), 5)*0.4+0.5;
-
- float gtdenom = 2 * nh;
- float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh));
-
- if (nh > 0.0)
+ if (spec.a > 0.0)
{
- float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
- col += lit*scol*light_col[i].rgb*spec.rgb;
- //col += spec.rgb;
+ lit = min(da*6.0, 1.0) * dist_atten;
+ //vec3 ref = dot(pos+lv, norm);
+ vec3 h = normalize(lv+npos);
+ float nh = dot(norm, h);
+ float nv = dot(norm, npos);
+ float vh = dot(npos, h);
+ float sa = nh;
+ float fres = pow(1 - dot(h, npos), 5)*0.4+0.5;
+
+ float gtdenom = 2 * nh;
+ float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh));
+
+ if (nh > 0.0)
+ {
+ float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
+ col += lit*scol*light_col[i].rgb*spec.rgb;
+ //col += spec.rgb;
+ }
}
- }
- out_col += col;
+ out_col += col;
+ }
}
}
- if (dot(out_col, out_col) <= 0.0)
- {
- discard;
- }
-
frag_color.rgb = out_col;
frag_color.a = 0.0;
}