From 570bbdb779f5e4be0c1804862bdffc9c5a1beb1b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 7 May 2019 15:09:30 -0700 Subject: [PATCH 1/6] Fix diffuse boost which we don't want underwater, but do want in other cases. --- .../app_settings/shaders/class1/deferred/softenLightF.glsl | 4 ++++ .../app_settings/shaders/class2/deferred/softenLightF.glsl | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index fb9f6d7f37..b6e3951ee3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -153,6 +153,10 @@ vec3 post_diffuse = color.rgb; vec3 post_spec = color.rgb; +#ifndef WATER_FOG + color.rgb += diffuse_srgb.a * diffuse_srgb.rgb; +#endif + if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 73b4473be5..03e5143fca 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -163,6 +163,10 @@ vec3 post_diffuse = color.rgb; vec3 post_spec = color.rgb; +#ifndef WATER_FOG + color.rgb += diffuse_srgb.a * diffuse_srgb.rgb; +#endif + if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; From a1e8042c1f2f1ab0ed5b6040535348974e659556 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 7 May 2019 15:36:43 -0700 Subject: [PATCH 2/6] SL-11055, SL-10966, SL-11087 Make haze look more like WL. Make lack of sun and moon mean black and fixed dir to prevent spooky underlighting. --- indra/llrender/llrender.cpp | 1 + .../class1/windlight/atmosphericsFuncs.glsl | 2 +- .../shaders/class2/deferred/skyF.glsl | 7 ++++--- .../shaders/class2/windlight/atmosphericsF.glsl | 4 +++- .../shaders/class2/windlight/cloudsF.glsl | 6 +++--- .../shaders/class2/windlight/cloudsV.glsl | 7 ++++--- .../shaders/class2/windlight/skyV.glsl | 3 ++- .../shaders/class3/lighting/lightV.glsl | 4 ++-- indra/newview/pipeline.cpp | 16 ++++++++++++++-- 9 files changed, 34 insertions(+), 16 deletions(-) diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index f3771f3bf2..c536b403ef 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1228,6 +1228,7 @@ void LLRender::syncLightState() shader->uniform3fv(LLShaderMgr::LIGHT_DIFFUSE, 8, diffuse[0].mV); shader->uniform4fv(LLShaderMgr::LIGHT_AMBIENT, 1, mAmbientLightColor.mV); shader->uniform1i(LLShaderMgr::SUN_UP_FACTOR, sun_primary[0] ? 1 : 0); + shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, diffuse[0].mV); shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, diffuse_b[0].mV); } } diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index a3041fccdc..6788cc1f63 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -68,7 +68,7 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o vec4 light_atten; float dens_mul = density_multiplier; - float dist_mul = distance_multiplier * 0.1; + float dist_mul = distance_multiplier; //sunlight attenuation effect (hue and brightness) due to atmosphere //this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl index bd0ca0a46e..eb95890e08 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl @@ -44,6 +44,7 @@ uniform float haze_density; uniform float cloud_shadow; uniform float density_multiplier; +uniform float distance_multiplier; uniform float max_y; uniform vec4 glow; @@ -117,7 +118,8 @@ void main() vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; - float dens_mul = density_multiplier * 0.45; + float dens_mul = density_multiplier; + float dist_mul = distance_multiplier; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -139,8 +141,7 @@ void main() // Transparency (-> temp1) // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati // compiler gets confused. - temp1 = exp(-temp1 * temp2.z); - + temp1 = exp(-temp1 * temp2.z * dist_mul); // Compute haze glow temp2.x = dot(Pn, lightnorm.xyz); diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 36703ea742..9db04f4e9a 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -37,6 +37,8 @@ uniform vec4 blue_density; uniform float haze_horizon; uniform float haze_density; uniform float cloud_shadow; +uniform float density_multiplier; +uniform float distance_multiplier; uniform float max_y; uniform vec4 glow; uniform float scene_light_strength; @@ -53,7 +55,7 @@ vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) return light; } light *= atten.r; - light += additive * exp(-1.0f); + light += additive; return light * 2.0; } diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index 1de919bf30..396ceacd19 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -86,14 +86,14 @@ void main() vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); // Offset texture coords - uv1 += cloud_pos_density1.xy;// + (disturbance * 0.02); //large texture, visible density + uv1 += cloud_pos_density1.xy + (disturbance * 0.02); //large texture, visible density uv2 += cloud_pos_density1.xy; //large texture, self shadow uv3 += cloud_pos_density2.xy; //small texture, visible density uv4 += cloud_pos_density2.xy; //small texture, self shadow float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y)); - //cloudDensity *= 1.0 - (density_variance * density_variance); + cloudDensity *= 1.0 - (density_variance * density_variance); // Compute alpha1, the main cloud opacity @@ -104,7 +104,7 @@ void main() alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1; - //alpha1 *= altitude_blend_factor; + alpha1 *= altitude_blend_factor; //if (alpha1 < 0.001f) //{ diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl index 43500bc5e3..aaf995af3c 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl @@ -57,6 +57,7 @@ uniform float haze_density; uniform float cloud_shadow; uniform float density_multiplier; +uniform float distance_multiplier; uniform float max_y; uniform vec4 glow; @@ -103,7 +104,8 @@ void main() vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; - float dens_mul = density_multiplier * 0.45; + float dens_mul = density_multiplier; + float dist_mul = distance_multiplier; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -125,8 +127,7 @@ void main() // Transparency (-> temp1) // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati // compiler gets confused. - temp1 = exp(-temp1 * temp2.z); - + temp1 = exp(-temp1 * temp2.z * dist_mul); // Compute haze glow temp2.x = dot(Pn, lightnorm.xyz); diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl index f6bef3e6bc..a23a5d4076 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl @@ -49,6 +49,7 @@ uniform float haze_density; uniform float cloud_shadow; uniform float density_multiplier; +uniform float distance_multiplier; uniform float max_y; uniform vec4 glow; @@ -109,7 +110,7 @@ void main() // Transparency (-> temp1) // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati // compiler gets confused. - temp1 = exp(-temp1 * temp2.z); + temp1 = exp(-temp1 * temp2.z * distance_multiplier); // Compute haze glow diff --git a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl index 69267621a3..48c883d98a 100644 --- a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl @@ -31,8 +31,8 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color); vec4 calcLighting(vec3 pos, vec3 norm, vec4 color) { - vec4 c = sumLights(pos, norm, color * 2.0); + vec4 c = sumLights(pos, norm, color); c.rgb += atmosAmbient() * color.rgb; - return c * 2.0; + return c; } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c57b267c92..211993fb46 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6203,7 +6203,8 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) gGL.setAmbientLightColor(ambient); } - bool sun_up = environment.getIsSunUp(); + bool sun_up = environment.getIsSunUp(); + bool moon_up = environment.getIsMoonUp(); // Light 0 = Sun or Moon (All objects) { @@ -6212,7 +6213,9 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) mSunDir.setVec(sun_dir); mMoonDir.setVec(moon_dir); - mSunDiffuse.setVec(psky->getSunDiffuse()); + + // calculates diffuse sunlight per-pixel downstream, just provide setting sunlight_color + mSunDiffuse.setVec(psky->getSunlightColor()); mMoonDiffuse.setVec(psky->getMoonDiffuse()); F32 max_color = llmax(mSunDiffuse.mV[0], mSunDiffuse.mV[1], mSunDiffuse.mV[2]); @@ -6229,6 +6232,15 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) } mMoonDiffuse.clamp(); + // prevent underlighting from having neither lightsource facing us + if (!sun_up && !moon_up) + { + mSunDiffuse.setVec(LLColor4(0.0, 0.0, 0.0, 1.0)); + mMoonDiffuse.setVec(LLColor4(0.0, 0.0, 0.0, 1.0)); + mSunDir.setVec(LLVector4(0.0, 1.0, 0.0, 0.0)); + mMoonDir.setVec(LLVector4(0.0, 1.0, 0.0, 0.0)); + } + LLVector4 light_dir = sun_up ? mSunDir : mMoonDir; mHWLightColors[0] = mSunDiffuse; From d3cf82969a6bf63585eba58d50223fec5e32a502 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 7 May 2019 15:39:01 -0700 Subject: [PATCH 3/6] SL-11105 --- indra/newview/app_settings/shaders/class1/lighting/lightV.glsl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl index 2d41776ee2..38230836eb 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl @@ -32,7 +32,7 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color); vec4 calcLighting(vec3 pos, vec3 norm, vec4 color) { vec4 c = sumLights(pos, norm, color); - c.rgb += atmosAmbient() * color.rgb; + c.rgb += atmosAmbient() * color.rgb * 0.5; return c; } From 989de25f189276d586d5c7077e505bc697fe4112 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 7 May 2019 16:32:34 -0700 Subject: [PATCH 4/6] SL-11086 Re-fix sun/moon glow factor and make it depend on moon brightness. Make cloud shaders use sunlight color exclusively for consistency when moon is up or down. --- indra/llinventory/llsettingssky.cpp | 19 +++---------------- .../shaders/class1/deferred/cloudsV.glsl | 5 ++--- .../shaders/class2/windlight/cloudsV.glsl | 3 ++- 3 files changed, 7 insertions(+), 20 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index def492c203..cfca2d0d78 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -953,21 +953,8 @@ void LLSettingsSky::updateSettings() F32 LLSettingsSky::getSunMoonGlowFactor() const { - // sun glow at full iff moon is not up - if (getIsSunUp()) - { - if (!getIsMoonUp()) - { - return 1.0f; - } - } - - if (getIsMoonUp()) - { - return 0.25f; - } - - return 0.0f; + return getIsSunUp() ? 1.0f : + getIsMoonUp() ? getMoonBrightness() * 0.25 : 0.0f; } bool LLSettingsSky::getIsSunUp() const @@ -1302,7 +1289,7 @@ void LLSettingsSky::calculateLightSettings() const mMoonDiffuse = gammaCorrect(componentMult(moonlight, light_transmittance) * moon_brightness); mMoonAmbient = gammaCorrect(componentMult(moonlight_b, light_transmittance) * 0.0125f); - mTotalAmbient = mSunAmbient + mMoonAmbient; + mTotalAmbient = mSunAmbient; } LLUUID LLSettingsSky::GetDefaultAssetId() diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl index f1eb1af90c..aed5a9b950 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -99,7 +99,8 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + //vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec4 sunlight = sunlight_color; vec4 light_atten; float dens_mul = density_multiplier * 0.45; @@ -156,8 +157,6 @@ void main() ); // CLOUDS - - sunlight = sunlight_color; temp2.y = max(0., lightnorm.y * 2.); temp2.y = 1. / temp2.y; sunlight *= exp( - light_atten * temp2.y); diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl index aaf995af3c..5c29290e47 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl @@ -101,7 +101,8 @@ void main() vec4 temp2 = vec4(0.); vec4 blue_weight; vec4 haze_weight; - vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + //vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec4 sunlight = sunlight_color; vec4 light_atten; float dens_mul = density_multiplier; From 06097302f4ad8786913e77514d5d60678da3160d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 7 May 2019 16:42:38 -0700 Subject: [PATCH 5/6] SL-11108 Remove tweaks to combine cascade results. --- .../shaders/class1/deferred/shadowUtil.glsl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 5694ba1f7b..bea016300d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -110,9 +110,9 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; - w = clamp(w, 0.0, 1.0); + //w = clamp(w, 0.0, 1.0); float contrib = pcfShadow(shadowMap3, norm, lpos, 1.0, pos_screen, light_dir)*w; - if (contrib > 0) + //if (contrib > 0) { shadow += contrib; weight += w; @@ -127,9 +127,9 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - w = clamp(w, 0.0, 1.0); + //w = clamp(w, 0.0, 1.0); float contrib = pcfShadow(shadowMap2, norm, lpos, 1.0, pos_screen, light_dir)*w; - if (contrib > 0) + //if (contrib > 0) { shadow += contrib; weight += w; @@ -143,9 +143,9 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - w = clamp(w, 0.0, 1.0); + //w = clamp(w, 0.0, 1.0); float contrib = pcfShadow(shadowMap1, norm, lpos, 1.0, pos_screen, light_dir)*w; - if (contrib > 0) + //if (contrib > 0) { shadow += contrib; weight += w; @@ -158,9 +158,9 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - w = clamp(w, 0.0, 1.0); + //w = clamp(w, 0.0, 1.0); float contrib = pcfShadow(shadowMap0, norm, lpos, 1.0, pos_screen, light_dir)*w; - if (contrib > 0) + //if (contrib > 0) { shadow += contrib; weight += w; From 22fc3409f4606459c6df219c343a002fc53a35cd Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 8 May 2019 14:30:09 -0700 Subject: [PATCH 6/6] SL-10878: Update default day cycle asset ID --- indra/llinventory/llsettingsdaycycle.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/llinventory/llsettingsdaycycle.cpp b/indra/llinventory/llsettingsdaycycle.cpp index 403d0ff9d8..b80e74791e 100644 --- a/indra/llinventory/llsettingsdaycycle.cpp +++ b/indra/llinventory/llsettingsdaycycle.cpp @@ -121,7 +121,7 @@ const S32 LLSettingsDay::FRAME_MAX(56); const F32 LLSettingsDay::DEFAULT_FRAME_SLOP_FACTOR(0.02501f); -const LLUUID LLSettingsDay::DEFAULT_ASSET_ID("78751d18-6c51-3c43-2887-3654cd427a42"); +const LLUUID LLSettingsDay::DEFAULT_ASSET_ID("5646d39e-d3d7-6aff-ed71-30fc87d64a91"); // Minimum value to prevent multislider in edit floaters from eating up frames that 'encroach' on one another's space static const F32 DEFAULT_MULTISLIDER_INCREMENT(0.005f);