diff options
author | Graham Linden <graham@lindenlab.com> | 2019-04-05 14:35:55 -0700 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-04-05 14:35:55 -0700 |
commit | fff2aecf7f96de9e53620887210487a48dd45580 (patch) | |
tree | c49ec5b62bbcd87069916212aab3506405efd2e3 /indra | |
parent | 39803f29c6b8dec710fb4b0244a81734bd95644a (diff) |
SL-10821
Fix directionality of da and preserve bumps on completely shadowed areas.
Diffstat (limited to 'indra')
5 files changed, 19 insertions, 14 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 1bc576a4ec..68a735e813 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -194,7 +194,8 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; float da = dot(norm.xyz, light_dir.xyz); - + da = clamp(da, -1.0, 1.0); + float final_da = da; final_da = clamp(final_da, 0.0f, 1.0f); final_da = pow(final_da, 1.0/1.3); @@ -204,13 +205,13 @@ void main() color.rgb = amblit; color.a = final_alpha; - float ambient = abs(da); + float ambient = da; ambient *= 0.5; ambient *= ambient; ambient = max(0.9, ambient); // keeps shadows dark ambient = 1.0 - ambient; - vec3 sun_contrib = min(final_da, shadow) * sunlit; + vec3 sun_contrib = mix(final_da, min(final_da, shadow), 0.1) * sunlit; color.rgb *= ambient; color.rgb += sun_contrib; diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 4e24e61018..8691e729ee 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -296,18 +296,19 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; float da = dot(norm.xyz, light_dir.xyz); + da = clamp(da, -1.0, 1.0); float final_da = da; final_da = clamp(final_da, 0.0, 1.0); final_da = pow(final_da, 1.0 / 1.3); - float ambient = abs(da); + float ambient = da; ambient *= 0.5; ambient *= ambient; ambient = max(0.9, ambient); ambient = 1.0 - ambient; - vec3 sun_contrib = min(final_da, shadow) * sunlit; + vec3 sun_contrib = mix(final_da, min(final_da, shadow), 0.1) * sunlit; col.rgb = amblit; col.rgb *= ambient; diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index e44b441727..361ed40eaf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -86,13 +86,15 @@ void main() float envIntensity = norm.z; norm.xyz = getNorm(tc); + float light_gamma = 1.0/1.3; vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; float da = dot(normalize(norm.xyz), light_dir.xyz); - da = clamp(da, 0.0, 1.0); + da = clamp(da, -1.0, 1.0); - float light_gamma = 1.0/1.3; - da = pow(da, light_gamma); + float final_da = da; + final_da = clamp(final_da, 0.0, 1.0); + final_da = pow(final_da, light_gamma); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -107,12 +109,12 @@ void main() calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); - float ambient = min(abs(da), 1.0); + float ambient = da; ambient *= 0.5; ambient *= ambient; ambient = 1.0 - ambient; - vec3 sun_contrib = da * sunlit; + vec3 sun_contrib = final_da * sunlit; col.rgb = amblit; col.rgb *= ambient; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 92888e0fd2..688e4e1d59 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -99,6 +99,7 @@ void main() vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; float da = dot(normalize(norm.xyz), light_dir.xyz); + da = clamp(da, -1.0, 1.0); vec4 diffuse = texture2DRect(diffuseRect, tc); @@ -122,13 +123,13 @@ void main() calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten); - float ambient = abs(da); + float ambient = da; ambient *= 0.5; ambient *= ambient; ambient = max(0.9, ambient); ambient = 1.0 - ambient; - vec3 sun_contrib = min(scol, final_da) * sunlit; + vec3 sun_contrib = mix(final_da, min(scol, final_da), 0.1) * sunlit; col.rgb = amblit; col.rgb *= ambient; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 952ff3ec9f..c6d727430c 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -2110,7 +2110,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSoftenProgram.mFeatures.hasTransport = true; gDeferredSoftenProgram.mFeatures.hasGamma = true; gDeferredSoftenProgram.mFeatures.isDeferred = true; - gDeferredSoftenProgram.mFeatures.hasShadows = true; + gDeferredSoftenProgram.mFeatures.hasShadows = use_sun_shadow; gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSoftenProgram.mShaderFiles.push_back(make_pair("deferred/softenLightF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -2143,7 +2143,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSoftenWaterProgram.mFeatures.hasTransport = true; gDeferredSoftenWaterProgram.mFeatures.hasGamma = true; gDeferredSoftenWaterProgram.mFeatures.isDeferred = true; - gDeferredSoftenWaterProgram.mFeatures.hasShadows = true; + gDeferredSoftenWaterProgram.mFeatures.hasShadows = use_sun_shadow; if (gSavedSettings.getBOOL("RenderDeferredSSAO")) { //if using SSAO, take screen space light map into account as if shadows are enabled |