diff options
4 files changed, 26 insertions, 22 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl index 521ad33059..699a9c0276 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl @@ -97,13 +97,16 @@ void main() for (int light_idx = 0; light_idx < LIGHT_COUNT; ++light_idx) { vec3 lightColor = light_col[ light_idx ].rgb; + float falloff = light_col[ light_idx ].a; float lightSize = light [ light_idx ].w; vec3 lv =(light [ light_idx ].xyz - pos); calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist); if (nl > 0.0 || nv > 0.0) { - vec3 intensity = getLightIntensityPoint(lightColor, lightSize, lightDist); + float dist = lightDist / lightSize; + float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff); + vec3 intensity = dist_atten * getLightIntensityPoint(lightColor, lightSize, lightDist); colorDiffuse += intensity * nl * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); colorSpec += intensity * nl * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index f8655ccf3b..09a8dbd4f1 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -135,14 +135,7 @@ void main() vec3 n; vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); - float fa = falloff+1.0; - float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); - dist_atten *= dist_atten; - dist_atten *= 2.0; - if (dist_atten <= 0.0) - { - discard; - } + float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff); lv = proj_origin-pos.xyz; vec3 h, l, v = -normalize(pos); @@ -169,6 +162,13 @@ void main() } else { + dist_atten *= dist_atten; + dist_atten *= 2.0; + if (dist_atten <= 0.0) + { + discard; + } + float noise = texture2D(noiseMap, tc/128.0).b; if (proj_tc.z > 0.0 && proj_tc.x < 1.0 && diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl index 5d9b4bc877..defd577266 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl @@ -88,6 +88,9 @@ void main() float nh, nl, nv, vh, lightDist; calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist); + float dist = lightDist / size; + float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff); + if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR)) { vec3 colorDiffuse = vec3(0); @@ -101,7 +104,7 @@ void main() if (nl > 0.0 || nv > 0.0) { - vec3 intensity = getLightIntensityPoint(color, size, lightDist); + vec3 intensity = dist_atten * getLightIntensityPoint(color, size, lightDist); colorDiffuse += intensity * nl * BRDFLambertian (reflect0, reflect90, c_diff , specWeight, vh); colorSpec += intensity * nl * BRDFSpecularGGX(reflect0, reflect90, alphaRough, specWeight, vh, nl, nv, nh); } @@ -126,8 +129,6 @@ void main() discard; } - 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; diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index 300e3b8e76..72ae733622 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -132,17 +132,9 @@ void main() vec3 n; vec4 norm = getNormalEnvIntensityFlags(tc, n, envIntensity); // need `norm.w` for GET_GBUFFER_FLAG() - float fa = falloff+1.0; - float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); - dist_atten *= dist_atten; - dist_atten *= 2.0; + float dist_atten = 1.0 - (dist + falloff)/(1.0 + falloff); - if (dist_atten <= 0.0) - { - discard; - } - - lv = proj_origin-pos.xyz; + lv = proj_origin-pos.xyz; // NOTE: Re-using lv vec3 h, l, v = -normalize(pos); float nh, nl, nv, vh, lightDist; calcHalfVectors(lv, n, v, h, l, nh, nl, nv, vh, lightDist); @@ -166,6 +158,14 @@ void main() } else { + dist_atten *= dist_atten; + dist_atten *= 2.0; + + if (dist_atten <= 0.0) + { + discard; + } + float noise = texture2D(noiseMap, tc/128.0).b; if (proj_tc.z > 0.0 && proj_tc.x < 1.0 && |