diff options
author | Graham Linden <graham@lindenlab.com> | 2019-04-08 16:53:57 -0700 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-04-08 16:53:57 -0700 |
commit | 996d441ddc64996711b5a4eb3135607686992b86 (patch) | |
tree | 55129c482873d34564f4a48fb06e681c93ad1112 /indra/newview | |
parent | 759525040ac11a2edee541c944ad0c6e9cc04d0f (diff) |
SL-5186
Make projector ambiance unshadowed in both forward and deferred for consistency.
Diffstat (limited to 'indra/newview')
4 files changed, 30 insertions, 28 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index fb24927b26..4b99592dbb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -99,8 +99,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec lv = normalize(lv); vec3 norm = normalize(n); - da = max(0.0, dot(norm, lv)); - //da = min(da, shadow); + da = dot(norm, lv); da = clamp(da, 0.0, 1.0); //distance attenuation @@ -116,18 +115,15 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec // to match spotLight (but not multiSpotLight) *sigh* float lit = max(da * dist_atten,0.0); - // the shadowmap is wrong for alpha objects - // since we only have 2 maps but N spots - //col = lit * light_col * diffuse * shadow; - col = lit * light_col * diffuse; + col = lit * light_col * diffuse * shadow; float amb_da = ambiance; - amb_da += (da*0.5) * (1.0 - shadow) * ambiance; + amb_da += (da*0.5+0.5) * (1.0 - shadow) * ambiance; amb_da += (da*da*0.5 + 0.5) * (1.0 - shadow) * ambiance; amb_da *= dist_atten; amb_da = min(amb_da, 1.0f - lit); - col.rgb += amb_da * light_col * diffuse; + col.rgb += amb_da * 0.5 * light_col * diffuse; // no spec for alpha shader... } col = max(col, vec3(0)); @@ -234,7 +230,7 @@ vec3 post_diffuse = color.rgb; vec3 prelight_linearish_maybe = color.rgb; - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w, shadow); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w, 1.0); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -244,16 +240,17 @@ vec3 prelight_linearish_maybe = color.rgb; LIGHT_LOOP(6) LIGHT_LOOP(7) +vec3 light_linear = light.rgb; + // keep it linear // color.rgb += light.rgb; vec3 postlight_linear = color.rgb; -color.rgb = prelight_linearish_maybe; +//color.rgb = light_linear; color.rgb = linear_to_srgb(color.rgb); - #endif #ifdef WATER_FOG diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 4bb01824bf..8c5a0ef297 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -112,23 +112,20 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe //angular attenuation da = dot(n, lv); - //da = min(da, shadow); - da *= clamp(da, 0.0, 1.0); + da = clamp(da, 0.0, 1.0); float lit = max(da * dist_atten, 0.0); // shadowmap is wrong for alpha-blended objs // since we created shadowmaps for 2 but render N - //col = light_col*lit*diffuse*shadow; - col = light_col*lit*diffuse; + col = light_col*lit*diffuse*shadow; float amb_da = ambiance; - amb_da += (da*0.5) * (1.0 - shadow) * ambiance; + amb_da += (da*0.5+0.5) * (1.0 - shadow) * ambiance; amb_da += (da*da*0.5 + 0.5) * (1.0 - shadow) * ambiance; - amb_da *= dist_atten; amb_da = min(amb_da, 1.0f - lit); - col.rgb += amb_da * light_col * diffuse; + col.rgb += amb_da * 0.5 * light_col * diffuse; if (spec.a > 0.0) { @@ -373,7 +370,7 @@ vec3 post_spec = col.rgb; vec3 prelight_linearish_maybe = col.rgb; - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w, shadow); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w, 1.0); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -383,6 +380,8 @@ vec3 post_spec = col.rgb; LIGHT_LOOP(6) LIGHT_LOOP(7) +vec3 light_linear = light.rgb; + col.rgb += light.rgb; vec3 postlight_linear = col.rgb; @@ -396,7 +395,7 @@ vec3 postlight_linear = col.rgb; al = temp.a; #endif -//col.rgb = prelight_linearish_maybe; +//col.rgb = light_linear; col.rgb = linear_to_srgb(col.rgb); diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index ab380f70e8..7ccc91f73c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -218,15 +218,19 @@ void main() dlit = color.rgb * plcol.rgb * plcol.a; col = dlit*lit*diff_tex*shadow; - amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; + + // unshadowed for consistency between forward and deferred? + amb_da += (da*0.5+0.5)/* *(1.0-shadow) */ *proj_ambiance; } //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod); - - amb_da += (da*da*0.5+0.5)*(1.0-shadow)*proj_ambiance; + + // unshadowed for consistency between forward and deferred? + amb_da += (da*da*0.5+0.5) /* *(1.0-shadow) */ * proj_ambiance; amb_da *= dist_atten * noise; amb_da = min(amb_da, 1.0-lit); + col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; } @@ -251,7 +255,7 @@ void main() { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = dlit*scol*spec.rgb*shadow; - speccol = max(speccol, vec3(0)); + speccol = clamp(speccol, vec3(0), vec3(1)); col += speccol; } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index a9482ea54c..2844cc8574 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -185,7 +185,8 @@ void main() lv = proj_origin-pos.xyz; lv = normalize(lv); float da = dot(norm, lv); - + da = clamp(da, 0.0, 1.0); + vec3 col = vec3(0,0,0); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; @@ -214,9 +215,10 @@ void main() vec4 plcol = texture2DLodDiffuse(projectionMap, proj_tc.xy, lod); dlit = color.rgb * plcol.rgb * plcol.a; - + col = dlit*lit*diff_tex*shadow; - amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance; + + amb_da += (da*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance; } //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); @@ -250,7 +252,7 @@ void main() { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = dlit*scol*spec.rgb*shadow; - speccol = max(speccol, vec3(0)); + speccol = clamp(speccol, vec3(0), vec3(1)); col += speccol; } } |