diff options
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl')
-rwxr-xr-x | indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl | 76 |
1 files changed, 44 insertions, 32 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index b331258952..73b9767a71 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -93,52 +93,64 @@ void main() vec3 pos = getPosition(frag.xy).xyz; vec3 lv = trans_center.xyz-pos; - float d = length(lv); + float dist = length(lv); + dist /= size; + if (dist > 1.0) + { + discard; + } - float dist = d*size; - - vec3 col = vec3(0.0); - if (dist <= 1.0) + vec3 norm = texture2DRect(normalMap, frag.xy).xyz; + norm = decode_normal(norm.xy); // unpack norm + float da = dot(norm, lv); + if (da < 0.0) { - vec3 norm = texture2DRect(normalMap, frag.xy).xyz; - norm = decode_normal(norm.xy); // unpack norm - - norm = normalize(norm); - lv = normalize(lv); - float da = max(dot(norm, lv), 0.0); + discard; + } + + norm = normalize(norm); + lv = normalize(lv); + da = dot(norm, lv); //float noise = texture2D(noiseMap, frag.xy/128.0).b; - col = texture2DRect(diffuseRect, frag.xy).rgb; - float fa = falloff+1.0; - float dist_atten = clamp(1.0-(dist-1.0+fa)/fa, 0.0, 1.0); - dist_atten *= dist_atten; - dist_atten *= 2.0; + vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; + float fa = falloff+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 lit = da * dist_atten; - col = color.rgb*lit*col; + col = color.rgb*lit*col; - vec4 spec = texture2DRect(specularRect, frag.xy); - if (spec.a > 0.0) + vec4 spec = texture2DRect(specularRect, frag.xy); + if (spec.a > 0.0) + { + lit = min(da*6.0, 1.0) * dist_atten; + + vec3 npos = -normalize(pos); + 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) { - lit = min(da*6.0, 1.0) * dist_atten; - - vec3 npos = -normalize(pos); - 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))); - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - col += max(lit*scol*color.rgb*spec.rgb, vec3(0.0)); + col += lit*scol*color.rgb*spec.rgb; } } + if (dot(col, col) <= 0.0) + { + discard; + } + frag_color.rgb = col; frag_color.a = 0.0; } |