diff options
author | Graham Linden <graham@lindenlab.com> | 2019-04-25 10:59:00 -0700 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2019-04-25 10:59:00 -0700 |
commit | 4ed05fc84fce0fbee76c583e91feed5aff2dbbfc (patch) | |
tree | 31bfec7a2b09919d9df3a050d2f2ed369d31f0ad | |
parent | ca16874379bf76dd844d57b2ee59da531d642a8e (diff) |
Fix dark ALM and strangeness at Mid lighting (class 3 but with a darkness about it).
Make a distinct class3/lighting/lightV which boosts to WL levels (* 2.0)
and make lighting without WL atmo enabled use class 2 or below.
Make forward shaders (alpha and materialF with alpha-blend mode on) more consistent with deferred lighting.
7 files changed, 37 insertions, 25 deletions
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 41e8882181..c41944bdbb 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -33,9 +33,8 @@ #include "v3colorutil.h" //========================================================================= -namespace { - const F32 NIGHTTIME_ELEVATION = 8.0f; // degrees - const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION * DEG_TO_RAD); +namespace +{ const LLUUID IMG_BLOOM1("3c59f7fe-9dc8-47f9-8aaf-a9dd1fbc3bef"); const LLUUID IMG_RAINBOW("11b4c57c-56b3-04ed-1f82-2004363882e4"); const LLUUID IMG_HALO("12149143-f599-91a7-77ac-b52a3c0f59cd"); @@ -958,15 +957,15 @@ F32 LLSettingsSky::getSunMoonGlowFactor() const LLVector3 moonDir = getMoonDirection(); // sun glow at full iff moon is not up - if (sunDir.mV[VZ] > -NIGHTTIME_ELEVATION_SIN) + if (getIsSunUp()) { - if (moonDir.mV[2] <= 0.0f) + if (!getIsMoonUp()) { return 1.0f; } } - if (moonDir.mV[2] > 0.0f) + if (getIsMoonUp()) { return 0.25f; } @@ -977,13 +976,13 @@ F32 LLSettingsSky::getSunMoonGlowFactor() const bool LLSettingsSky::getIsSunUp() const { LLVector3 sunDir = getSunDirection(); - return (sunDir.mV[2] >= 0.0f) || ((sunDir.mV[2] > -NIGHTTIME_ELEVATION_SIN) && !getIsMoonUp()); + return sunDir.mV[2] >= 0.0f || !getIsMoonUp(); } bool LLSettingsSky::getIsMoonUp() const { LLVector3 moonDir = getMoonDirection(); - return moonDir.mV[2] > 0.0f; + return moonDir.mV[2] >= 0.0f; } void LLSettingsSky::calculateHeavenlyBodyPositions() const @@ -997,10 +996,19 @@ void LLSettingsSky::calculateHeavenlyBodyPositions() const mSunDirection.normalize(); mMoonDirection.normalize(); - if (mSunDirection.lengthSquared() < 0.01f) - LL_WARNS("SETTINGS") << "Zero length sun direction. Wailing and gnashing of teeth may follow... or not." << LL_ENDL; - if (mMoonDirection.lengthSquared() < 0.01f) - LL_WARNS("SETTINGS") << "Zero length moon direction. Wailing and gnashing of teeth may follow... or not." << LL_ENDL; + // find out about degen math earlier rather than later + llassert(mSunDirection.length() >= 0.9f); + llassert(mMoonDirection.length() >= 0.9f); + + if (mSunDirection.lengthSquared() < 0.9f) + { + LL_WARNS("SETTINGS") << "Invalid sun direction." << LL_ENDL; + } + + if (mMoonDirection.lengthSquared() < 0.9f) + { + LL_WARNS("SETTINGS") << "Invalid moon direction." << LL_ENDL; + } } LLVector3 LLSettingsSky::getLightDirection() const @@ -1280,9 +1288,9 @@ void LLSettingsSky::calculateLightSettings() const // and vary_sunlight will work properly with moon light F32 lighty = lightnorm[2]; - if(lighty > 0.001f) + if(fabs(lighty) > 0.001f) { - lighty = 1.f / lighty; + lighty = 1.f / fabs(lighty); } lighty = llmax(0.001f, lighty); componentMultBy(sunlight, componentExp((light_atten * -1.f) * lighty)); diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index e8400ba66d..8709053ac6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -201,7 +201,6 @@ void main() float final_da = da; final_da = clamp(final_da, 0.0f, 1.0f); - final_da = pow(final_da, 1.0/1.3); vec4 color = vec4(0,0,0,0); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index f1dbf4af46..5926236fd7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -302,7 +302,6 @@ void main() float final_da = da; final_da = clamp(final_da, 0.0, 1.0); - final_da = pow(final_da, 1.0 / 1.3); float ambient = da; ambient *= 0.5; @@ -372,6 +371,8 @@ vec3 post_spec = col.rgb; glare += cur_glare; } +vec3 post_env = col.rgb; + col = atmosFragLighting(col, additive, atten); col = scaleSoftClipFrag(col); @@ -379,7 +380,7 @@ vec3 post_spec = col.rgb; vec3 light = vec3(0,0,0); - vec3 prelight_linearish_maybe = srgb_to_linear(col.rgb); +vec3 post_atmo = 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 * 0.5); @@ -393,7 +394,7 @@ vec3 post_spec = col.rgb; vec3 light_linear = light.rgb; - col.rgb += light.rgb; + col.rgb += light_linear; vec3 postlight_linear = col.rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 68deedd0d0..83006c8916 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -108,7 +108,7 @@ void main() vec3 atten; calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); - sunlit *= 0.5; + float ambient = da; ambient *= 0.5; ambient *= ambient; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index dd70790fc3..2d5d1c1b50 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -120,7 +120,7 @@ void main() vec3 atten; calcAtmosphericVars(pos.xyz, ambocc, sunlit, amblit, additive, atten); - sunlit *= 0.5; + float ambient = da; ambient *= 0.5; ambient *= ambient; diff --git a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl index b19f4e96ca..efe7f69f21 100644 --- a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl @@ -28,10 +28,9 @@ // All lights, no specular highlights vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight); -vec3 atmosAmbient(vec3 c); + vec4 calcLighting(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) { - vec4 l = sumLights(pos, norm, color, baseLight); - return l; + return sumLights(pos, norm, color, baseLight) * 2.0f; } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ebfdc38d50..0bd4a5eae0 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -478,7 +478,8 @@ void LLViewerShaderMgr::setShaders() //using shaders, disable fixed function LLGLSLShader::sNoFixedFunction = true; - S32 light_class = 2; + S32 light_class = 3; + S32 interface_class = 2; S32 env_class = 2; S32 obj_class = 2; S32 effect_class = 2; @@ -519,6 +520,10 @@ void LLViewerShaderMgr::setShaders() // windlight shaders to stub versions. wl_class = 2; } + else + { + light_class = 2; + } // Trigger a full rebuild of the fallback skybox / cubemap if we've toggled windlight shaders if (mShaderLevel[SHADER_WINDLIGHT] != wl_class && gSky.mVOSkyp.notNull()) @@ -528,7 +533,7 @@ void LLViewerShaderMgr::setShaders() // Load lighting shaders mShaderLevel[SHADER_LIGHTING] = light_class; - mShaderLevel[SHADER_INTERFACE] = light_class; + mShaderLevel[SHADER_INTERFACE] = interface_class; mShaderLevel[SHADER_ENVIRONMENT] = env_class; mShaderLevel[SHADER_WATER] = water_class; mShaderLevel[SHADER_OBJECT] = obj_class; |