From ed12bb1c77b957ac00fd1a9d73d4d9aa93bd7f78 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 3 Apr 2019 09:58:46 -0700 Subject: [PATCH 01/40] Remove unused iterator for Xcode 10.2 happiness. --- indra/newview/llappearancemgr.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 2bdffec7fb..5ab86059f3 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -1864,7 +1864,6 @@ bool LLAppearanceMgr::getCanRemoveOutfit(const LLUUID& outfit_cat_id) LLFindNonRemovableObjects filter_non_removable; LLInventoryModel::cat_array_t cats; LLInventoryModel::item_array_t items; - LLInventoryModel::item_array_t::const_iterator it; gInventory.collectDescendentsIf(outfit_cat_id, cats, items, false, filter_non_removable); if (!cats.empty() || !items.empty()) { From 98f71bb8e4cd94c29a1b728147d8507f3a74c3a2 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 3 Apr 2019 12:01:34 -0700 Subject: [PATCH 02/40] Replace dropped code from 6.1.2 for loading new avatar/attachment alpha/mask shadow shaders. --- indra/newview/llviewershadermgr.cpp | 53 +++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 28593a43ba..dc38339e6e 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -2218,6 +2218,32 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() llassert(success); } + if (success) + { + gDeferredAvatarAlphaShadowProgram.mName = "Deferred Avatar Alpha Shadow Shader"; + gDeferredAvatarAlphaShadowProgram.mFeatures.hasSkinning = true; + gDeferredAvatarAlphaShadowProgram.mShaderFiles.clear(); + gDeferredAvatarAlphaShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaShadowV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredAvatarAlphaShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAvatarAlphaShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); + gDeferredAvatarAlphaShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gDeferredAvatarAlphaShadowProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + gDeferredAvatarAlphaMaskShadowProgram.mName = "Deferred Avatar Alpha Mask Shadow Shader"; + gDeferredAvatarAlphaMaskShadowProgram.mFeatures.hasSkinning = true; + gDeferredAvatarAlphaMaskShadowProgram.mShaderFiles.clear(); + gDeferredAvatarAlphaMaskShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaShadowV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredAvatarAlphaMaskShadowProgram.mShaderFiles.push_back(make_pair("deferred/avatarAlphaMaskShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAvatarAlphaMaskShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); + gDeferredAvatarAlphaMaskShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gDeferredAvatarAlphaMaskShadowProgram.createShader(NULL, NULL); + llassert(success); + } + if (success) { gDeferredAttachmentShadowProgram.mName = "Deferred Attachment Shadow Shader"; @@ -2235,6 +2261,32 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() llassert(success); } + if (success) + { + gDeferredAttachmentAlphaShadowProgram.mName = "Deferred Attachment Alpha Shadow Shader"; + gDeferredAttachmentAlphaShadowProgram.mFeatures.hasObjectSkinning = true; + gDeferredAttachmentAlphaShadowProgram.mShaderFiles.clear(); + gDeferredAttachmentAlphaShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentAlphaShadowV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredAttachmentAlphaShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentAlphaShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAttachmentAlphaShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); + gDeferredAttachmentAlphaShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gDeferredAttachmentAlphaShadowProgram.createShader(NULL, NULL); + llassert(success); + } + + if (success) + { + gDeferredAttachmentAlphaMaskShadowProgram.mName = "Deferred Attachment Alpha Mask Shadow Shader"; + gDeferredAttachmentAlphaMaskShadowProgram.mFeatures.hasObjectSkinning = true; + gDeferredAttachmentAlphaMaskShadowProgram.mShaderFiles.clear(); + gDeferredAttachmentAlphaMaskShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentAlphaShadowV.glsl", GL_VERTEX_SHADER_ARB)); + gDeferredAttachmentAlphaMaskShadowProgram.mShaderFiles.push_back(make_pair("deferred/attachmentAlphaMaskShadowF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDeferredAttachmentAlphaMaskShadowProgram.addPermutation("DEPTH_CLAMP", gGLManager.mHasDepthClamp ? "1" : "0"); + gDeferredAttachmentAlphaMaskShadowProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; + success = gDeferredAttachmentAlphaMaskShadowProgram.createShader(NULL, NULL); + llassert(success); + } + if (success) { gDeferredTerrainProgram.mName = "Deferred Terrain Shader"; @@ -2280,6 +2332,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredTerrainWaterProgram.mShaderGroup = LLGLSLShader::SG_WATER; gDeferredTerrainWaterProgram.addPermutation("WATER_FOG", "1"); success = gDeferredTerrainWaterProgram.createShader(NULL, NULL); + llassert(success); } if (success) From a698b5168195caca4c2863d057cc2e7b4938353d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 3 Apr 2019 12:07:59 -0700 Subject: [PATCH 03/40] Replace MAINT-8836 fix dropped in merge of 6.1.2 --- indra/newview/llviewershadermgr.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index dc38339e6e..caef1df2cd 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -2621,6 +2621,7 @@ BOOL LLViewerShaderMgr::loadShadersObject() gObjectSimpleNonIndexedProgram.mFeatures.hasGamma = true; gObjectSimpleNonIndexedProgram.mFeatures.hasAtmospherics = true; gObjectSimpleNonIndexedProgram.mFeatures.hasLighting = true; + gObjectSimpleNonIndexedProgram.mFeatures.hasAlphaMask = true; // Fix for MAINT-8836 gObjectSimpleNonIndexedProgram.mFeatures.disableTextureIndex = true; gObjectSimpleNonIndexedProgram.mShaderFiles.clear(); gObjectSimpleNonIndexedProgram.mShaderFiles.push_back(make_pair("objects/simpleV.glsl", GL_VERTEX_SHADER_ARB)); From 82fbf642617444e0233e73d3bd5909c7c5285445 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 3 Apr 2019 12:35:51 -0700 Subject: [PATCH 04/40] Add shader unloads for new deferred avatar/attachment alpha/mask shadow shaders. --- indra/newview/llviewershadermgr.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index caef1df2cd..952ff3ec9f 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1250,9 +1250,13 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSoftenWaterProgram.unload(); gDeferredShadowProgram.unload(); gDeferredShadowCubeProgram.unload(); - gDeferredShadowAlphaMaskProgram.unload(); + gDeferredShadowAlphaMaskProgram.unload(); gDeferredAvatarShadowProgram.unload(); + gDeferredAvatarAlphaShadowProgram.unload(); + gDeferredAvatarAlphaMaskShadowProgram.unload(); gDeferredAttachmentShadowProgram.unload(); + gDeferredAttachmentAlphaShadowProgram.unload(); + gDeferredAttachmentAlphaMaskShadowProgram.unload(); gDeferredAvatarProgram.unload(); gDeferredAvatarAlphaProgram.unload(); gDeferredAlphaProgram.unload(); From e24237b6af504ff8faea02c8ab22344f2452364e Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 3 Apr 2019 14:52:59 -0700 Subject: [PATCH 05/40] SL-10189, SL-10880: Mark the day instance so that it does not try to reanimate a day cycle when setting a fixed sky. Add new floater for setting the shared environment to local and allowing modifications. --- indra/newview/CMakeLists.txt | 2 + indra/newview/llenvironment.cpp | 89 +++-- indra/newview/llenvironment.h | 11 + indra/newview/llfloaterenvironmentadjust.cpp | 329 ++++++++++++++++ indra/newview/llfloaterenvironmentadjust.h | 86 +++++ indra/newview/llviewerfloaterreg.cpp | 4 +- indra/newview/llviewermenu.cpp | 4 + .../xui/en/floater_adjust_environment.xml | 365 ++++++++++++++++++ .../skins/default/xui/en/menu_viewer.xml | 7 + 9 files changed, 859 insertions(+), 38 deletions(-) create mode 100644 indra/newview/llfloaterenvironmentadjust.cpp create mode 100644 indra/newview/llfloaterenvironmentadjust.h create mode 100644 indra/newview/skins/default/xui/en/floater_adjust_environment.xml diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 9933713911..7739feb419 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -235,6 +235,7 @@ set(viewer_SOURCE_FILES llfloaterdeleteprefpreset.cpp llfloaterdestinations.cpp llfloatereditextdaycycle.cpp + llfloaterenvironmentadjust.cpp llfloaterevent.cpp llfloaterexperiencepicker.cpp llfloaterexperienceprofile.cpp @@ -858,6 +859,7 @@ set(viewer_HEADER_FILES llfloaterdeleteprefpreset.h llfloaterdestinations.h llfloatereditextdaycycle.h + llfloaterenvironmentadjust.h llfloaterevent.h llfloaterexperiencepicker.h llfloaterexperienceprofile.h diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3defe68a0e..57e6ab7159 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -798,6 +798,11 @@ const S32 LLEnvironment::VERSION_CLEANUP(-4); // for cleanups const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg + +const U32 LLEnvironment::DayInstance::NO_ANIMATE_SKY(0x01); +const U32 LLEnvironment::DayInstance::NO_ANIMATE_WATER(0x02); + + //------------------------------------------------------------------------- LLEnvironment::LLEnvironment(): mCloudScrollDelta(), @@ -1110,28 +1115,28 @@ void LLEnvironment::setEnvironment(LLEnvironment::EnvSelection_t env, LLEnvironm DayInstance::ptr_t environment = getEnvironmentInstance(env, true); -// LLSettingsSky::ptr_t prev_sky = mEnvironments[ENV_DEFAULT]->getSky(); -// LLSettingsWater::ptr_t prev_water = mEnvironments[ENV_DEFAULT]->getWater(); -// if (mCurrentEnvironment && (ENV_EDIT == env)) -// { -// prev_sky = mCurrentEnvironment->getSky() ? mCurrentEnvironment->getSky() : prev_sky; -// prev_water = mCurrentEnvironment->getWater() ? mCurrentEnvironment->getWater() : prev_water; -// } -// environment->clear(); -// environment->setSky((fixed.first) ? fixed.first : prev_sky); -// environment->setWater((fixed.second) ? fixed.second : prev_water); if (fixed.first) + { environment->setSky(fixed.first); + environment->setFlags(DayInstance::NO_ANIMATE_SKY); + } else if (!environment->getSky()) + { environment->setSky(mCurrentEnvironment->getSky()); + environment->setFlags(DayInstance::NO_ANIMATE_SKY); + } if (fixed.second) + { environment->setWater(fixed.second); + environment->setFlags(DayInstance::NO_ANIMATE_WATER); + } else if (!environment->getWater()) + { environment->setWater(mCurrentEnvironment->getWater()); - - + environment->setFlags(DayInstance::NO_ANIMATE_WATER); + } if (!mSignalEnvChanged.empty()) mSignalEnvChanged(env, env_version); @@ -2447,7 +2452,8 @@ LLEnvironment::DayInstance::DayInstance(EnvSelection_t env) : mInitialized(false), mType(TYPE_INVALID), mSkyTrack(1), - mEnv(env) + mEnv(env), + mAnimateFlags(0) { } @@ -2465,6 +2471,7 @@ LLEnvironment::DayInstance::ptr_t LLEnvironment::DayInstance::clone() const environment->mInitialized = mInitialized; environment->mType = mType; environment->mSkyTrack = mSkyTrack; + environment->mAnimateFlags = mAnimateFlags; return environment; } @@ -2489,6 +2496,8 @@ void LLEnvironment::DayInstance::setDay(const LLSettingsDay::ptr_t &pday, LLSett mType = TYPE_CYCLED; mInitialized = false; + mAnimateFlags = 0; + mDayCycle = pday; mDayLength = daylength; mDayOffset = dayoffset; @@ -2596,34 +2605,40 @@ void LLEnvironment::DayInstance::animate() if (!mDayCycle) return; - LLSettingsDay::CycleTrack_t &wtrack = mDayCycle->getCycleTrack(0); + if (!(mAnimateFlags & NO_ANIMATE_WATER)) + { + LLSettingsDay::CycleTrack_t &wtrack = mDayCycle->getCycleTrack(0); - if (wtrack.empty()) - { - mWater.reset(); - mBlenderWater.reset(); - } - else - { - mWater = LLSettingsVOWater::buildDefaultWater(); - mBlenderWater = std::make_shared(mWater, mDayCycle, 0, - mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + if (wtrack.empty()) + { + mWater.reset(); + mBlenderWater.reset(); + } + else + { + mWater = LLSettingsVOWater::buildDefaultWater(); + mBlenderWater = std::make_shared(mWater, mDayCycle, 0, + mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + } } - // sky, initialize to track 1 - LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); + if (!(mAnimateFlags & NO_ANIMATE_SKY)) + { + // sky, initialize to track 1 + LLSettingsDay::CycleTrack_t &track = mDayCycle->getCycleTrack(1); - if (track.empty()) - { - mSky.reset(); - mBlenderSky.reset(); - } - else - { - mSky = LLSettingsVOSky::buildDefaultSky(); - mBlenderSky = std::make_shared(mSky, mDayCycle, 1, - mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); - mBlenderSky->switchTrack(mSkyTrack, 0.0); + if (track.empty()) + { + mSky.reset(); + mBlenderSky.reset(); + } + else + { + mSky = LLSettingsVOSky::buildDefaultSky(); + mBlenderSky = std::make_shared(mSky, mDayCycle, 1, + mDayLength, mDayOffset, DEFAULT_UPDATE_THRESHOLD); + mBlenderSky->switchTrack(mSkyTrack, 0.0); + } } } diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 64350c42e8..327e34d856 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -235,8 +235,12 @@ public: TYPE_FIXED, TYPE_CYCLED }; + typedef std::shared_ptr ptr_t; + static const U32 NO_ANIMATE_SKY; + static const U32 NO_ANIMATE_WATER; + DayInstance(EnvSelection_t env); virtual ~DayInstance() { }; @@ -273,7 +277,12 @@ public: LLSettingsBase::TrackPosition getProgress() const; + void setFlags(U32 flag) { mAnimateFlags |= flag; } + void clearFlags(U32 flag) { mAnimateFlags &= ~flag; } + protected: + + LLSettingsDay::ptr_t mDayCycle; LLSettingsSky::ptr_t mSky; LLSettingsWater::ptr_t mWater; @@ -291,6 +300,8 @@ public: EnvSelection_t mEnv; + U32 mAnimateFlags; + LLSettingsBase::TrackPosition secondsToKeyframe(LLSettingsDay::Seconds seconds); }; diff --git a/indra/newview/llfloaterenvironmentadjust.cpp b/indra/newview/llfloaterenvironmentadjust.cpp new file mode 100644 index 0000000000..9456780627 --- /dev/null +++ b/indra/newview/llfloaterenvironmentadjust.cpp @@ -0,0 +1,329 @@ +/** + * @file llfloaterfixedenvironment.cpp + * @brief Floaters to create and edit fixed settings for sky and water. + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#include "llviewerprecompiledheaders.h" + +#include "llfloaterenvironmentadjust.h" + +#include "llslider.h" +#include "llsliderctrl.h" +#include "llcolorswatch.h" +#include "llvirtualtrackball.h" +#include "llenvironment.h" + +//========================================================================= +namespace +{ + const std::string FIELD_SKY_AMBIENT_LIGHT("ambient_light"); + const std::string FIELD_SKY_BLUE_HORIZON("blue_horizon"); + const std::string FIELD_SKY_BLUE_DENSITY("blue_density"); + const std::string FIELD_SKY_SUN_COLOR("sun_color"); + const std::string FIELD_SKY_CLOUD_COLOR("cloud_color"); + const std::string FIELD_SKY_HAZE_HORIZON("haze_horizon"); + const std::string FIELD_SKY_HAZE_DENSITY("haze_density"); + const std::string FIELD_SKY_CLOUD_COVERAGE("cloud_coverage"); + const std::string FIELD_SKY_CLOUD_SCALE("cloud_scale"); + const std::string FIELD_SKY_SCENE_GAMMA("scene_gamma"); + const std::string FIELD_SKY_SUN_ROTATION("sun_rotation"); + const std::string FIELD_SKY_SUN_SCALE("sun_scale"); + const std::string FIELD_SKY_GLOW_FOCUS("glow_focus"); + const std::string FIELD_SKY_GLOW_SIZE("glow_size"); + const std::string FIELD_SKY_STAR_BRIGHTNESS("star_brightness"); + const std::string FIELD_SKY_MOON_ROTATION("moon_rotation"); + + const F32 SLIDER_SCALE_SUN_AMBIENT(3.0f); + const F32 SLIDER_SCALE_BLUE_HORIZON_DENSITY(2.0f); + const F32 SLIDER_SCALE_GLOW_R(20.0f); + const F32 SLIDER_SCALE_GLOW_B(-5.0f); + const F32 SLIDER_SCALE_DENSITY_MULTIPLIER(0.001f); + + const S32 FLOATER_ENVIRONMENT_UPDATE(-2); +} + +//========================================================================= +LLFloaterEnvironmentAdjust::LLFloaterEnvironmentAdjust(const LLSD &key): + LLFloater(key) +{} + +LLFloaterEnvironmentAdjust::~LLFloaterEnvironmentAdjust() +{} + +//------------------------------------------------------------------------- +BOOL LLFloaterEnvironmentAdjust::postBuild() +{ + getChild(FIELD_SKY_AMBIENT_LIGHT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAmbientLightChanged(); }); + getChild(FIELD_SKY_BLUE_HORIZON)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onBlueHorizonChanged(); }); + getChild(FIELD_SKY_BLUE_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onBlueDensityChanged(); }); + getChild(FIELD_SKY_HAZE_HORIZON)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onHazeHorizonChanged(); }); + getChild(FIELD_SKY_HAZE_DENSITY)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onHazeDensityChanged(); }); + getChild(FIELD_SKY_SCENE_GAMMA)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSceneGammaChanged(); }); + + getChild(FIELD_SKY_CLOUD_COLOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudColorChanged(); }); + getChild(FIELD_SKY_CLOUD_COVERAGE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudCoverageChanged(); }); + getChild(FIELD_SKY_CLOUD_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onCloudScaleChanged(); }); + getChild(FIELD_SKY_SUN_COLOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunColorChanged(); }); + + getChild(FIELD_SKY_GLOW_FOCUS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onGlowChanged(); }); + getChild(FIELD_SKY_GLOW_SIZE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onGlowChanged(); }); + getChild(FIELD_SKY_STAR_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onStarBrightnessChanged(); }); + getChild(FIELD_SKY_SUN_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunRotationChanged(); }); + getChild(FIELD_SKY_SUN_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onSunScaleChanged(); }); + + getChild(FIELD_SKY_MOON_ROTATION)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonRotationChanged(); }); + + refresh(); + return TRUE; +} + +void LLFloaterEnvironmentAdjust::onOpen(const LLSD& key) +{ + captureCurrentEnvironment(); + + mEventConnection = LLEnvironment::instance().setEnvironmentChanged([this](LLEnvironment::EnvSelection_t env, S32 version){ onEnvironmentUpdated(env, version); }); + + LLFloater::onOpen(key); + refresh(); +} + +void LLFloaterEnvironmentAdjust::onClose(bool app_quitting) +{ + mEventConnection.disconnect(); + mLiveSky.reset(); + LLFloater::onClose(app_quitting); +} + + +//------------------------------------------------------------------------- +void LLFloaterEnvironmentAdjust::refresh() +{ + if (!mLiveSky) + { + setAllChildrenEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + getChild(FIELD_SKY_AMBIENT_LIGHT)->set(mLiveSky->getAmbientColor() / SLIDER_SCALE_SUN_AMBIENT); + getChild(FIELD_SKY_BLUE_HORIZON)->set(mLiveSky->getBlueHorizon() / SLIDER_SCALE_BLUE_HORIZON_DENSITY); + getChild(FIELD_SKY_BLUE_DENSITY)->set(mLiveSky->getBlueDensity() / SLIDER_SCALE_BLUE_HORIZON_DENSITY); + getChild(FIELD_SKY_HAZE_HORIZON)->setValue(mLiveSky->getHazeHorizon()); + getChild(FIELD_SKY_HAZE_DENSITY)->setValue(mLiveSky->getHazeDensity()); + getChild(FIELD_SKY_SCENE_GAMMA)->setValue(mLiveSky->getGamma()); + getChild(FIELD_SKY_CLOUD_COLOR)->set(mLiveSky->getCloudColor()); + getChild(FIELD_SKY_CLOUD_COVERAGE)->setValue(mLiveSky->getCloudShadow()); + getChild(FIELD_SKY_CLOUD_SCALE)->setValue(mLiveSky->getCloudScale()); + getChild(FIELD_SKY_SUN_COLOR)->set(mLiveSky->getSunlightColor() / SLIDER_SCALE_SUN_AMBIENT); + + LLColor3 glow(mLiveSky->getGlow()); + + // takes 40 - 0.2 range -> 0 - 1.99 UI range + getChild(FIELD_SKY_GLOW_SIZE)->setValue(2.0 - (glow.mV[0] / SLIDER_SCALE_GLOW_R)); + getChild(FIELD_SKY_GLOW_FOCUS)->setValue(glow.mV[2] / SLIDER_SCALE_GLOW_B); + getChild(FIELD_SKY_STAR_BRIGHTNESS)->setValue(mLiveSky->getStarBrightness()); + getChild(FIELD_SKY_SUN_ROTATION)->setRotation(mLiveSky->getSunRotation()); + getChild(FIELD_SKY_SUN_SCALE)->setValue(mLiveSky->getSunScale()); + getChild(FIELD_SKY_MOON_ROTATION)->setRotation(mLiveSky->getMoonRotation()); + +} + + +void LLFloaterEnvironmentAdjust::captureCurrentEnvironment() +{ + LLEnvironment &environment(LLEnvironment::instance()); + bool updatelocal(false); + + if (environment.hasEnvironment(LLEnvironment::ENV_LOCAL)) + { + if (environment.getEnvironmentDay(LLEnvironment::ENV_LOCAL)) + { // We have a full day cycle in the local environment. Freeze the sky + mLiveSky = environment.getEnvironmentFixedSky(LLEnvironment::ENV_LOCAL)->buildClone(); + updatelocal = true; + } + else + { // otherwise we can just use the sky. + mLiveSky = environment.getEnvironmentFixedSky(LLEnvironment::ENV_LOCAL); + } + } + else + { + mLiveSky = environment.getEnvironmentFixedSky(LLEnvironment::ENV_PARCEL, true)->buildClone(); + updatelocal = true; + } + + if (updatelocal) + { + environment.setEnvironment(LLEnvironment::ENV_LOCAL, mLiveSky, FLOATER_ENVIRONMENT_UPDATE); + } + environment.setSelectedEnvironment(LLEnvironment::ENV_LOCAL); + environment.updateEnvironment(LLEnvironment::TRANSITION_INSTANT); + +} + +//------------------------------------------------------------------------- +void LLFloaterEnvironmentAdjust::onAmbientLightChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setAmbientColor(LLColor3(getChild(FIELD_SKY_AMBIENT_LIGHT)->get() * SLIDER_SCALE_SUN_AMBIENT)); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onBlueHorizonChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setBlueHorizon(LLColor3(getChild(FIELD_SKY_BLUE_HORIZON)->get() * SLIDER_SCALE_BLUE_HORIZON_DENSITY)); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onBlueDensityChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setBlueDensity(LLColor3(getChild(FIELD_SKY_BLUE_DENSITY)->get() * SLIDER_SCALE_BLUE_HORIZON_DENSITY)); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onHazeHorizonChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setHazeHorizon(getChild(FIELD_SKY_HAZE_HORIZON)->getValue().asReal()); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onHazeDensityChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setHazeDensity(getChild(FIELD_SKY_HAZE_DENSITY)->getValue().asReal()); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onSceneGammaChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setGamma(getChild(FIELD_SKY_SCENE_GAMMA)->getValue().asReal()); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onCloudColorChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setCloudColor(LLColor3(getChild(FIELD_SKY_CLOUD_COLOR)->get())); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onCloudCoverageChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setCloudShadow(getChild(FIELD_SKY_CLOUD_COVERAGE)->getValue().asReal()); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onCloudScaleChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setCloudScale(getChild(FIELD_SKY_CLOUD_SCALE)->getValue().asReal()); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onGlowChanged() +{ + if (!mLiveSky) + return; + LLColor3 glow(getChild(FIELD_SKY_GLOW_SIZE)->getValue().asReal(), 0.0f, getChild(FIELD_SKY_GLOW_FOCUS)->getValue().asReal()); + + // takes 0 - 1.99 UI range -> 40 -> 0.2 range + glow.mV[0] = (2.0f - glow.mV[0]) * SLIDER_SCALE_GLOW_R; + glow.mV[2] *= SLIDER_SCALE_GLOW_B; + + mLiveSky->setGlow(glow); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onStarBrightnessChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setStarBrightness(getChild(FIELD_SKY_STAR_BRIGHTNESS)->getValue().asReal()); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onSunRotationChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setSunRotation(getChild(FIELD_SKY_SUN_ROTATION)->getRotation()); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onSunScaleChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setSunScale((getChild(FIELD_SKY_SUN_SCALE)->getValue().asReal())); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onMoonRotationChanged() +{ + if (!mLiveSky) + return; + mLiveSky->setMoonRotation(getChild(FIELD_SKY_MOON_ROTATION)->getRotation()); + mLiveSky->update(); +} + +void LLFloaterEnvironmentAdjust::onSunColorChanged() +{ + if (!mLiveSky) + return; + LLColor3 color(getChild(FIELD_SKY_SUN_COLOR)->get()); + + color *= SLIDER_SCALE_SUN_AMBIENT; + + mLiveSky->setSunlightColor(color); + mLiveSky->update(); +} + + +void LLFloaterEnvironmentAdjust::onEnvironmentUpdated(LLEnvironment::EnvSelection_t env, S32 version) +{ + if (env == LLEnvironment::ENV_LOCAL) + { // a new local environment has been applied + if (version != FLOATER_ENVIRONMENT_UPDATE) + { // not by this floater + captureCurrentEnvironment(); + refresh(); + } + } +} diff --git a/indra/newview/llfloaterenvironmentadjust.h b/indra/newview/llfloaterenvironmentadjust.h new file mode 100644 index 0000000000..5bd91b0c43 --- /dev/null +++ b/indra/newview/llfloaterenvironmentadjust.h @@ -0,0 +1,86 @@ +/** + * @file llfloaterenvironmentadjust.h + * @brief Floaters to create and edit fixed settings for sky and water. + * + * $LicenseInfo:firstyear=2011&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2011, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ + +#ifndef LL_FLOATERENVIRONMENTADJUST_H +#define LL_FLOATERENVIRONMENTADJUST_H + +#include "llfloater.h" +#include "llsettingsbase.h" +#include "llsettingssky.h" +#include "llenvironment.h" + +#include "boost/signals2.hpp" + +class LLButton; +class LLLineEditor; + +/** + * Floater container for taking a snapshot of the current environment and making minor adjustments. + */ +class LLFloaterEnvironmentAdjust : public LLFloater +{ + LOG_CLASS(LLFloaterEnvironmentAdjust); + +public: + LLFloaterEnvironmentAdjust(const LLSD &key); + virtual ~LLFloaterEnvironmentAdjust(); + + + virtual BOOL postBuild() override; + virtual void onOpen(const LLSD& key) override; + virtual void onClose(bool app_quitting) override; + + virtual void refresh() override; + +private: + void captureCurrentEnvironment(); + + void onAmbientLightChanged(); + void onBlueHorizonChanged(); + void onBlueDensityChanged(); + void onHazeHorizonChanged(); + void onHazeDensityChanged(); + void onSceneGammaChanged(); + + void onCloudColorChanged(); + void onCloudCoverageChanged(); + void onCloudScaleChanged(); + void onSunColorChanged(); + + void onGlowChanged(); + void onStarBrightnessChanged(); + void onSunRotationChanged(); + void onSunScaleChanged(); + + void onMoonRotationChanged(); + + void onEnvironmentUpdated(LLEnvironment::EnvSelection_t env, S32 version); + + LLSettingsSky::ptr_t mLiveSky; + LLEnvironment::connection_t mEventConnection; +}; + +#endif // LL_FLOATERFIXEDENVIRONMENT_H diff --git a/indra/newview/llviewerfloaterreg.cpp b/indra/newview/llviewerfloaterreg.cpp index 6ad4ea76af..756dafe270 100644 --- a/indra/newview/llviewerfloaterreg.cpp +++ b/indra/newview/llviewerfloaterreg.cpp @@ -58,6 +58,7 @@ #include "llfloaterdeleteprefpreset.h" #include "llfloaterdestinations.h" #include "llfloatereditextdaycycle.h" +#include "llfloaterenvironmentadjust.h" #include "llfloaterexperienceprofile.h" #include "llfloaterexperiences.h" #include "llfloaterexperiencepicker.h" @@ -222,7 +223,8 @@ void LLViewerFloaterReg::registerFloaters() LLFloaterReg::add("env_fixed_environmentent_water", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_fixed_environmentent_sky", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); - //LLFloaterReg::add("env_fixed_environmentent", "floater_fixedenvironment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); + + LLFloaterReg::add("env_adjust_snapshot", "floater_adjust_environment.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("env_edit_extdaycycle", "floater_edit_ext_day_cycle.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); LLFloaterReg::add("my_environments", "floater_my_environments.xml", (LLFloaterBuildFunc)&LLFloaterReg::build); diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 68a91968ea..f03eb48573 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8542,6 +8542,10 @@ class LLWorldEnvSettings : public view_listener_t else LLEnvironment::instance().pauseCloudScroll(); } + else if (event_name == "adjust_tool") + { + LLFloaterReg::showInstance("env_adjust_snapshot"); + } else if (event_name == "my_environs") { LLFloaterReg::showInstance("my_environments"); diff --git a/indra/newview/skins/default/xui/en/floater_adjust_environment.xml b/indra/newview/skins/default/xui/en/floater_adjust_environment.xml new file mode 100644 index 0000000000..e2cf809c9c --- /dev/null +++ b/indra/newview/skins/default/xui/en/floater_adjust_environment.xml @@ -0,0 +1,365 @@ + + + + + + + + Ambient: + + Blue Horizon: + + Blue Density: + + Sun Color: + + Cloud Color: + + + + Haze Horizon: + + Haze Density: + + Cloud Coverage: + + Cloud Scale: + + Scene Gamma: + + + + Sun: + + + Scale: + + Glow Focus: + + Glow Size: + + Star Brightness: + + + + Moon: + + + + + + + diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml index f676df5e8b..2eab312ecd 100644 --- a/indra/newview/skins/default/xui/en/menu_viewer.xml +++ b/indra/newview/skins/default/xui/en/menu_viewer.xml @@ -715,6 +715,13 @@ function="World.EnvSettings" parameter="my_environs" /> + + + Date: Wed, 3 Apr 2019 15:20:52 -0700 Subject: [PATCH 06/40] SL-10856 Make terrain *not* blend all the way to diffuse color for no reason. --- .../app_settings/shaders/class1/deferred/terrainF.glsl | 4 ++-- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl index f73fc0079b..800070c01d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/terrainF.glsl @@ -66,8 +66,8 @@ void main() outColor = applyWaterFogView(pos.xyz, outColor); #endif - frag_data[0] = vec4(outColor.rgb, 1.0); - frag_data[1] = vec4(0.66,0.86,0.66,0.05f); + frag_data[0] = vec4(outColor.rgb, 0.0); + frag_data[1] = vec4(0.0,0.0,0.0,0.0); vec3 nvn = normalize(vary_normal); frag_data[2] = vec4(encode_normal(nvn.xyz), 0.0, 0.0); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 28248aaf6d..c34bac79dd 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -168,8 +168,6 @@ void main() col = fogged.rgb; bloom = fogged.a; #endif - -//col.rgb = a; } frag_color.rgb = col.rgb; frag_color.a = bloom; From 28fd43a161cc9b1e0a6e9321295427862a7cff3f Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Wed, 3 Apr 2019 15:48:52 -0700 Subject: [PATCH 07/40] OSX hates unused variables --- indra/newview/llfloaterenvironmentadjust.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llfloaterenvironmentadjust.cpp b/indra/newview/llfloaterenvironmentadjust.cpp index 9456780627..6773e2dcaf 100644 --- a/indra/newview/llfloaterenvironmentadjust.cpp +++ b/indra/newview/llfloaterenvironmentadjust.cpp @@ -58,7 +58,7 @@ namespace const F32 SLIDER_SCALE_BLUE_HORIZON_DENSITY(2.0f); const F32 SLIDER_SCALE_GLOW_R(20.0f); const F32 SLIDER_SCALE_GLOW_B(-5.0f); - const F32 SLIDER_SCALE_DENSITY_MULTIPLIER(0.001f); + //const F32 SLIDER_SCALE_DENSITY_MULTIPLIER(0.001f); const S32 FLOATER_ENVIRONMENT_UPDATE(-2); } From 0e9193d84c0f96b890123f092f22f81ae84fe6dc Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 3 Apr 2019 15:51:20 -0700 Subject: [PATCH 08/40] Make sure that the SL BRDF is being applied to objects lit by the sun and moon. Fixes BUG-226620 --HG-- branch : BUG-226620 --- .../shaders/class1/deferred/softenLightF.glsl | 28 +++++++++++++------ .../shaders/class2/deferred/softenLightF.glsl | 28 +++++++++++++------ 2 files changed, 40 insertions(+), 16 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index e22240727c..97b5e56529 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -123,14 +123,26 @@ void main() if (spec.a > 0.0) // specular reflection { - // the old infinite-sky shiny reflection - float sa = dot(refnormpersp, light_dir.xyz); - vec3 dumbshiny = sunlit*(texture2D(lightFunc, vec2(sa, spec.a)).r); - - // add the two types of shiny together - vec3 spec_contrib = dumbshiny * spec.rgb; - bloom = dot(spec_contrib, spec_contrib) / 6; - col += spec_contrib; + vec3 npos = -normalize(pos.xyz); + + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(light_dir.xyz+npos); + float nh = dot(norm.xyz, h); + float nv = dot(norm.xyz, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); + + if (nh > 0.0) + { + float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + vec3 speccol = sun_contrib*scol*spec.rgb; + speccol = max(speccol, vec3(0)); + col += speccol; + } } col.rgb += diffuse.a * diffuse.rgb; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 28248aaf6d..42258cc729 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -136,14 +136,26 @@ void main() if (spec.a > 0.0) // specular reflection { - // the old infinite-sky shiny reflection - float sa = dot(refnormpersp, light_dir.xyz); - vec3 dumbshiny = sunlit*scol*(texture2D(lightFunc, vec2(sa, spec.a)).r); - - // add the two types of shiny together - vec3 spec_contrib = dumbshiny * spec.rgb; - bloom = dot(spec_contrib, spec_contrib) / 6; - col += spec_contrib; + vec3 npos = -normalize(pos.xyz); + + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(light_dir.xyz+npos); + float nh = dot(norm.xyz, h); + float nv = dot(norm.xyz, npos); + float vh = dot(npos, h); + float sa = nh; + float fres = pow(1 - dot(h, npos), 5)*0.4+0.5; + + float gtdenom = 2 * nh; + float gt = max(0, min(gtdenom * nv / vh, gtdenom * da / vh)); + + if (nh > 0.0) + { + float scontrib = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + vec3 speccol = sun_contrib*scontrib*spec.rgb; + speccol = max(speccol, vec3(0)); + col += speccol; + } } col.rgb += diffuse.a * diffuse.rgb; From a615dc049ec1f57d3938a8b49a8f0502b4ce2523 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 3 Apr 2019 16:01:12 -0700 Subject: [PATCH 09/40] Bring back specular bloom. --HG-- branch : BUG-226620 --- .../app_settings/shaders/class1/deferred/softenLightF.glsl | 1 + .../app_settings/shaders/class2/deferred/softenLightF.glsl | 1 + 2 files changed, 2 insertions(+) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 97b5e56529..e44b441727 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -141,6 +141,7 @@ void main() float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = sun_contrib*scol*spec.rgb; speccol = max(speccol, vec3(0)); + bloom = dot (speccol, speccol) / 2; col += speccol; } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 42258cc729..3192f056a5 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -154,6 +154,7 @@ void main() float scontrib = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = sun_contrib*scontrib*spec.rgb; speccol = max(speccol, vec3(0)); + bloom += dot (speccol, speccol) / 2; col += speccol; } } From 2013578ca90261c20501166e508174bfdaeca7d7 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 3 Apr 2019 16:07:39 -0700 Subject: [PATCH 10/40] Update contributions. --HG-- branch : BUG-226620 --- doc/contributions.txt | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/doc/contributions.txt b/doc/contributions.txt index d1355652e4..c9a382d455 100755 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -483,12 +483,14 @@ Geenz Spad STORM-1900 STORM-1905 NORSPEC-229 - BUG-226611 - BUG-226617 - BUG-226618 - BUG-226646 - BUG-226647 - BUG-226648 + BUG-226611 + BUG-226617 + BUG-226618 + BUG-226646 + BUG-226647 + BUG-226648 + OPEN-339 + BUG-226620 Gene Frostbite GeneJ Composer Geneko Nemeth From 64942c5cd1e497b19ef44bfb9799059d9d484634 Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Thu, 4 Apr 2019 18:09:23 +0300 Subject: [PATCH 11/40] SL-10875 FIXED [EEP] Selecting the Day Cycle window causes the previous keyframe to become selected if keyframes are close together --- indra/newview/llfloatereditextdaycycle.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 4b88b4d7af..613ff30c32 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -1151,8 +1151,19 @@ void LLFloaterEditExtDayCycle::selectFrame(F32 frame, F32 slop_factor) while (iter != end_iter) { F32 keyframe = iter->second.mFrame; - if (fabs(keyframe - frame) <= slop_factor) + F32 frame_dif = fabs(keyframe - frame); + if (frame_dif <= slop_factor) { + keymap_t::iterator next_iter = std::next(iter); + if ((frame_dif != 0) && (next_iter != end_iter)) + { + if (fabs(next_iter->second.mFrame - frame) < frame_dif) + { + mFramesSlider->setCurSlider(next_iter->first); + frame = next_iter->second.mFrame; + break; + } + } mFramesSlider->setCurSlider(iter->first); frame = iter->second.mFrame; break; @@ -1301,7 +1312,6 @@ void LLFloaterEditExtDayCycle::updateSlider() { // update positions mLastFrameSlider = mFramesSlider->getCurSlider(); - updateTabs(); } else { From 4ba6e05469761b647ef490e0bdfc90cb51786685 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 4 Apr 2019 09:58:04 -0700 Subject: [PATCH 12/40] SL-10886 Render sun/moon beacons in non-ALM mode too. --- indra/newview/pipeline.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4606462db7..96a66254ec 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -4507,6 +4507,7 @@ void LLPipeline::renderGeom(LLCamera& camera, bool forceVBOUpdate) // Render debugging beacons. gObjectList.renderObjectBeacons(); gObjectList.resetObjectBeacons(); + gSky.addSunMoonBeacons(); } else { From bfd2a594d746c552443a17c2857ed1f5bfcccd46 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 4 Apr 2019 10:27:43 -0700 Subject: [PATCH 13/40] SL-10887 Disable occlusion culling when rendering water reflection/refraction maps again (still getting probabalistic results for reflection map contents). :/ --- indra/newview/pipeline.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 96a66254ec..bd7c428559 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2446,7 +2446,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl LLVOCachePartition* vo_part = region->getVOCachePartition(); if(vo_part) { - bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe/* && !gViewerWindow->getProgressView()->getVisible()*/; + bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe && 0 > water_clip /* && !gViewerWindow->getProgressView()->getVisible()*/; vo_part->cull(camera, do_occlusion_cull); } } @@ -9276,7 +9276,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) S32 occlusion = LLPipeline::sUseOcclusion; //disable occlusion culling for reflection map for now - //LLPipeline::sUseOcclusion = 0; + LLPipeline::sUseOcclusion = 0; glh::matrix4f current = get_current_modelview(); From dfdeeb353ce20294ff87190fc95313a81581bd49 Mon Sep 17 00:00:00 2001 From: Rider Linden Date: Thu, 4 Apr 2019 11:47:28 -0700 Subject: [PATCH 14/40] SL-10849: Select the correct notification for unchecking the parcel owners may override button. --- indra/newview/llfloaterregioninfo.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/indra/newview/llfloaterregioninfo.cpp b/indra/newview/llfloaterregioninfo.cpp index 9f33feb901..a7887eb9b4 100644 --- a/indra/newview/llfloaterregioninfo.cpp +++ b/indra/newview/llfloaterregioninfo.cpp @@ -3257,13 +3257,14 @@ void LLPanelRegionEnvironment::onChkAllowOverride(bool value) mAllowOverrideRestore = mAllowOverride; mAllowOverride = value; - LLNotification::Params params("ChangeLindenEstate"); - params.functor.function([this](const LLSD& notification, const LLSD& response) { confirmUpdateEstateEnvironment(notification, response); }); std::string notification("EstateParcelEnvironmentOverride"); if (LLPanelEstateInfo::isLindenEstate()) notification = "ChangeLindenEstate"; + LLNotification::Params params(notification); + params.functor.function([this](const LLSD& notification, const LLSD& response) { confirmUpdateEstateEnvironment(notification, response); }); + if (!value || LLPanelEstateInfo::isLindenEstate()) { // warn if turning off or a Linden Estate LLNotifications::instance().add(params); From c699ee9a7f102aa541dcc102e8fa1de2d6c55bde Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 4 Apr 2019 17:19:59 -0700 Subject: [PATCH 15/40] SL-10854 Clamp ambient contrib to get darker shadows. New PCF sampling func. --- .../shaders/class1/deferred/alphaF.glsl | 12 ++++-- .../shaders/class1/deferred/materialF.glsl | 2 +- .../shaders/class1/deferred/shadowUtil.glsl | 43 ++++++++++++++++--- .../shaders/class2/deferred/softenLightF.glsl | 15 ++++--- 4 files changed, 55 insertions(+), 17 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index dac93cee3a..d560a49c1f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -194,8 +194,12 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; float da = dot(norm.xyz, light_dir.xyz); - da = clamp(da, 0.0, 1.0); - da = pow(da, 1.0 / 1.3); + + float final_da = da; + final_da = min(final_da, shadow); + final_da = max(final_da, 0.0f); + final_da = min(final_da, 1.0f); + final_da = pow(final_da, 1.0/1.3); vec4 color = vec4(0,0,0,0); @@ -205,9 +209,9 @@ void main() float ambient = abs(da); ambient *= 0.5; ambient *= ambient; - ambient = 1.0 - ambient; + ambient = 1.0 - max(0.9, ambient); - vec3 sun_contrib = min(da, shadow) * sunlit; + vec3 sun_contrib = final_da * 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 c43b5b22bf..d389d975fa 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -302,7 +302,7 @@ void main() float ambient = abs(da); ambient *= 0.5; ambient *= ambient; - ambient = 1.0 - ambient; + ambient = 1.0 - max(0.9, ambient); float final_da = min(da, shadow); vec3 sun_contrib = final_da * sunlit; diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 6ff49c7dac..2d2d00cb51 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -46,21 +46,52 @@ uniform mat4 inv_proj; uniform vec2 screen_res; uniform int sun_up_factor; +const float sample_count = 5; + +float cGoldenAngle = 2.39996323f; + float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) { stc.xyz /= stc.w; + stc.z += shadow_bias * bias_mul * 4.0; + + float shadow = 0.0; + float cs = shadow2D(shadowMap, stc.xyz).x; + float initialTheta = cGoldenAngle*fract((pos_screen.y+pos_screen.x)*shadow_res.y); + float theta = initialTheta; + int i; + for (i = 0; i < sample_count; i++) + { + float r = float(i) / float(sample_count); + float weight = sqrt(1.0 - r); + r = sqrt(r); + vec2 sampleOffset; + sampleOffset.x = cos(theta); + sampleOffset.y = sin(theta); + sampleOffset *= r * 2.0; + float s = shadow2D(shadowMap, stc.xyz + vec3(sampleOffset, 0)).x; + shadow += weight * s; + theta += cGoldenAngle; + } + shadow /= float(sample_count); + shadow += cs; + shadow *= 0.5; + return shadow; +} + +float pcfShadowOld(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) +{ + stc.xyz /= stc.w; + + float cs = shadow2D(shadowMap, stc.xyz).x; stc.z += shadow_bias * bias_mul * 2.0; stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here - - float cs = shadow2D(shadowMap, stc.xyz).x; - float shadow = cs * 4.0; - + float shadow = cs; shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - - return shadow * 0.125; + return shadow * 0.2; } float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen) diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 7f1d518dd6..0c9dc5da58 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -98,15 +98,18 @@ void main() vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; float da = dot(normalize(norm.xyz), light_dir.xyz); - da = clamp(da, 0.0, 1.0); - - float light_gamma = 1.0/1.3; - da = pow(da, light_gamma); vec4 diffuse = texture2DRect(diffuseRect, tc); scol = max(scol_ambocc.r, diffuse.a); + float final_da = da; + final_da = min(final_da, scol); + final_da = clamp(final_da, 0.0, 1.0); + + float light_gamma = 1.0/1.3; + final_da = pow(final_da, light_gamma); + vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); vec3 col; float bloom = 0.0; @@ -123,9 +126,9 @@ void main() float ambient = abs(da); ambient *= 0.5; ambient *= ambient; - ambient = 1.0 - ambient; + ambient = 1.0 - max(0.9, ambient); - vec3 sun_contrib = min(da,scol) * sunlit; + vec3 sun_contrib = final_da * sunlit; col.rgb = amblit; col.rgb *= ambient; From d7789999cb6bab7b4e28236d99c4c2a8006497ff Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Fri, 5 Apr 2019 17:05:01 +0300 Subject: [PATCH 16/40] SL-10897 FIXED [EEP] Sliding a keyframe will not prompt to save changes before closing the window. --- indra/newview/llfloatereditextdaycycle.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 613ff30c32..3846dfd2a4 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -776,7 +776,7 @@ void LLFloaterEditExtDayCycle::onAddFrame() setting = sky; mEditDay->setSkyAtKeyframe(sky, frame, mCurrentTrack); } - + setDirtyFlag(); addSliderFrame(frame, setting); updateTabs(); } @@ -788,6 +788,7 @@ void LLFloaterEditExtDayCycle::onRemoveFrame() { return; } + setDirtyFlag(); removeCurrentSliderFrame(); updateTabs(); } @@ -964,6 +965,7 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback(const LLSD &data) // reselect new frame mFramesSlider->setCurSlider(it->first); mShiftCopyEnabled = false; + setDirtyFlag(); } } else @@ -971,6 +973,7 @@ void LLFloaterEditExtDayCycle::onFrameSliderCallback(const LLSD &data) if (mEditDay->moveTrackKeyframe(mCurrentTrack, (*it).second.mFrame, sliderpos) && mCanMod) { (*it).second.mFrame = sliderpos; + setDirtyFlag(); } else { From 09bb0336f15027e907fbd28130b4ffda28a830cd Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 5 Apr 2019 09:19:46 -0700 Subject: [PATCH 17/40] SL-10854 part 2 Clamp ambient to keep shadows dark. Apply min with shadow value after we've pow'd by light gamma consistently between forward and deferred. --- .../shaders/class1/deferred/alphaF.glsl | 9 ++--- .../shaders/class1/deferred/materialF.glsl | 12 +++--- .../shaders/class1/deferred/shadowUtil.glsl | 40 ++----------------- .../shaders/class2/deferred/softenLightF.glsl | 10 ++--- 4 files changed, 19 insertions(+), 52 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index d560a49c1f..1bc576a4ec 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -196,9 +196,7 @@ void main() float da = dot(norm.xyz, light_dir.xyz); float final_da = da; - final_da = min(final_da, shadow); - final_da = max(final_da, 0.0f); - final_da = min(final_da, 1.0f); + 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); @@ -209,9 +207,10 @@ void main() float ambient = abs(da); ambient *= 0.5; ambient *= ambient; - ambient = 1.0 - max(0.9, ambient); + ambient = max(0.9, ambient); // keeps shadows dark + ambient = 1.0 - ambient; - vec3 sun_contrib = final_da * sunlit; + vec3 sun_contrib = min(final_da, shadow) * 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 d389d975fa..4e24e61018 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -296,16 +296,18 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; float da = dot(norm.xyz, light_dir.xyz); - da = clamp(da, 0.0, 1.0); - da = pow(da, 1.0 / 1.3); + + 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); ambient *= 0.5; ambient *= ambient; - ambient = 1.0 - max(0.9, ambient); + ambient = max(0.9, ambient); + ambient = 1.0 - ambient; - float final_da = min(da, shadow); - vec3 sun_contrib = final_da * sunlit; + vec3 sun_contrib = min(final_da, shadow) * sunlit; col.rgb = amblit; col.rgb *= ambient; diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 2d2d00cb51..642aff6c41 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -46,52 +46,18 @@ uniform mat4 inv_proj; uniform vec2 screen_res; uniform int sun_up_factor; -const float sample_count = 5; - -float cGoldenAngle = 2.39996323f; - float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) { stc.xyz /= stc.w; - stc.z += shadow_bias * bias_mul * 4.0; - - float shadow = 0.0; - float cs = shadow2D(shadowMap, stc.xyz).x; - float initialTheta = cGoldenAngle*fract((pos_screen.y+pos_screen.x)*shadow_res.y); - float theta = initialTheta; - int i; - for (i = 0; i < sample_count; i++) - { - float r = float(i) / float(sample_count); - float weight = sqrt(1.0 - r); - r = sqrt(r); - vec2 sampleOffset; - sampleOffset.x = cos(theta); - sampleOffset.y = sin(theta); - sampleOffset *= r * 2.0; - float s = shadow2D(shadowMap, stc.xyz + vec3(sampleOffset, 0)).x; - shadow += weight * s; - theta += cGoldenAngle; - } - shadow /= float(sample_count); - shadow += cs; - shadow *= 0.5; - return shadow; -} - -float pcfShadowOld(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) -{ - stc.xyz /= stc.w; - - float cs = shadow2D(shadowMap, stc.xyz).x; stc.z += shadow_bias * bias_mul * 2.0; stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here - float shadow = cs; + float cs = shadow2D(shadowMap, stc.xyz).x; + float shadow = cs * 4.0; shadow += shadow2D(shadowMap, stc.xyz+vec3(2.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - return shadow * 0.2; + return shadow * 0.125; } float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen) diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 0c9dc5da58..92888e0fd2 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -94,6 +94,7 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; + float light_gamma = 1.0/1.3; float scol = 1.0; vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; @@ -102,12 +103,10 @@ void main() vec4 diffuse = texture2DRect(diffuseRect, tc); scol = max(scol_ambocc.r, diffuse.a); + //scol = pow(scol, light_gamma); float final_da = da; - final_da = min(final_da, scol); final_da = clamp(final_da, 0.0, 1.0); - - float light_gamma = 1.0/1.3; final_da = pow(final_da, light_gamma); vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); @@ -126,9 +125,10 @@ void main() float ambient = abs(da); ambient *= 0.5; ambient *= ambient; - ambient = 1.0 - max(0.9, ambient); + ambient = max(0.9, ambient); + ambient = 1.0 - ambient; - vec3 sun_contrib = final_da * sunlit; + vec3 sun_contrib = min(scol, final_da) * sunlit; col.rgb = amblit; col.rgb *= ambient; From f0fcbeff745a04d5a6d7188fb12ec46fdc79fd6b Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 5 Apr 2019 10:07:17 -0700 Subject: [PATCH 18/40] SL-10748 Clamp far_clip for sun shadows to >= 256.0 to prevent issues when draw distance < ~100m. --- indra/newview/pipeline.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index bd7c428559..260292d3fb 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -10282,6 +10282,7 @@ void LLPipeline::generateSunShadow(LLCamera& camera) //far_clip = llmin(far_clip, 128.f); far_clip = llmin(far_clip, camera.getFar()); + far_clip = llmax(far_clip, 256.0f); F32 range = far_clip-near_clip; From 39803f29c6b8dec710fb4b0244a81734bd95644a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 5 Apr 2019 11:39:14 -0700 Subject: [PATCH 19/40] Fix spec gone wild in ALM water rendering. --- .../app_settings/shaders/class1/deferred/waterF.glsl | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index c3c8683f6b..e0af521511 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -153,12 +153,9 @@ void main() vec4 pos = vary_position; - //color.rgb = atmosTransport(color.rgb); - //color.rgb = scaleSoftClipFrag(color.rgb) * 0; - vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz); - frag_data[0] = vec4(color.rgb, 1); // diffuse - frag_data[1] = vec4(specular * 0.4, 0.75); // speccolor, spec + frag_data[0] = vec4(color.rgb, 0.25); // diffuse + frag_data[1] = vec4(specular * 0.15, 0.5); // speccolor, spec frag_data[2] = vec4(encode_normal(screenspacewavef.xyz), 0.05, 0);// normalxy, 0, 0 } From fff2aecf7f96de9e53620887210487a48dd45580 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 5 Apr 2019 14:35:55 -0700 Subject: [PATCH 20/40] SL-10821 Fix directionality of da and preserve bumps on completely shadowed areas. --- .../app_settings/shaders/class1/deferred/alphaF.glsl | 7 ++++--- .../shaders/class1/deferred/materialF.glsl | 5 +++-- .../shaders/class1/deferred/softenLightF.glsl | 12 +++++++----- .../shaders/class2/deferred/softenLightF.glsl | 5 +++-- indra/newview/llviewershadermgr.cpp | 4 ++-- 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 From fe589170d3faa5ca681baca7b9a664e2d851cd6e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 5 Apr 2019 15:54:21 -0700 Subject: [PATCH 21/40] SL-10896 Fix deferred water soften prog lightnorm getting stomped with rotated lightnorm, because it's a water shader and needs water atmo uniform values, but it's a deferred lighting shader that needs not-so-rotated lightnorms. Make sunlight_color not get auto-updated so we can get the correct value from mSunDiffuse. Remove mix to preserve bumps as it was washing out shadows. --- indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl | 2 +- .../newview/app_settings/shaders/class1/deferred/materialF.glsl | 2 +- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 2 +- .../app_settings/shaders/class2/windlight/atmosphericsF.glsl | 2 +- indra/newview/llsettingsvo.cpp | 2 +- indra/newview/pipeline.cpp | 1 + 6 files changed, 6 insertions(+), 5 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 68a735e813..6e693bd33b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -211,7 +211,7 @@ void main() ambient = max(0.9, ambient); // keeps shadows dark ambient = 1.0 - ambient; - vec3 sun_contrib = mix(final_da, min(final_da, shadow), 0.1) * sunlit; + vec3 sun_contrib = min(final_da, shadow) * 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 8691e729ee..4a47311eb7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -308,7 +308,7 @@ void main() ambient = max(0.9, ambient); ambient = 1.0 - ambient; - vec3 sun_contrib = mix(final_da, min(final_da, shadow), 0.1) * sunlit; + vec3 sun_contrib = min(final_da, shadow) * 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 688e4e1d59..12115082a9 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -129,7 +129,7 @@ void main() ambient = max(0.9, ambient); ambient = 1.0 - ambient; - vec3 sun_contrib = mix(final_da, min(scol, final_da), 0.1) * sunlit; + vec3 sun_contrib = min(scol, final_da) * sunlit; col.rgb = amblit; col.rgb *= ambient; diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 7bfdb9f753..40c521cd2c 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -152,7 +152,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, + tmpAmbient)); //brightness of surface both sunlight and ambient - sunlit = srgb_to_linear(sunlight.rgb); + sunlit = vec3(sunlight.rgb* 0.5); amblit = vec3(tmpAmbient * .25); additive = normalize(additive); additive *= vec3(1.0 - exp(-temp2.z * distance_multiplier)) * 0.5; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 10a0527fe2..6556380f28 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -719,7 +719,7 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); - param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + //param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 260292d3fb..7139788c18 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8612,6 +8612,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) LLEnvironment& environment = LLEnvironment::instance(); soften_shader.uniform1i(LLShaderMgr::SUN_UP_FACTOR, environment.getIsSunUp() ? 1 : 0); + soften_shader.uniform4fv(LLShaderMgr::LIGHTNORM, 1, environment.getClampedLightNorm().mV); { LLGLDepthTest depth(GL_FALSE); From 66aa3d390d78eab482ce51bc916789a35b6dd50f Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Mon, 8 Apr 2019 15:26:59 +0300 Subject: [PATCH 22/40] SL-10893 Remove "Show Empty Folders" option --- indra/newview/llfloatermyenvironment.cpp | 16 ---------------- indra/newview/llfloatermyenvironment.h | 2 -- .../default/xui/en/floater_my_environments.xml | 16 ---------------- 3 files changed, 34 deletions(-) diff --git a/indra/newview/llfloatermyenvironment.cpp b/indra/newview/llfloatermyenvironment.cpp index 1edec248d9..3a83042d4f 100644 --- a/indra/newview/llfloatermyenvironment.cpp +++ b/indra/newview/llfloatermyenvironment.cpp @@ -58,7 +58,6 @@ namespace const std::string CHECK_SKIES("chk_skies"); const std::string CHECK_WATER("chk_water"); const std::string PANEL_SETTINGS("pnl_settings"); - const std::string CHECK_SHOWFOLDERS("chk_showfolders"); const std::string BUTTON_NEWSETTINGS("btn_gear"); const std::string BUTTON_GEAR("btn_newsettings"); const std::string BUTTON_DELETE("btn_del"); @@ -152,7 +151,6 @@ public: LLFloaterMyEnvironment::LLFloaterMyEnvironment(const LLSD& key) : LLFloater(key), mInventoryList(nullptr), - mShowFolders(LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS), mTypeFilter((0x01 << static_cast(LLSettingsType::ST_DAYCYCLE)) | (0x01 << static_cast(LLSettingsType::ST_SKY)) | (0x01 << static_cast(LLSettingsType::ST_WATER))), mSelectedAsset() { @@ -188,14 +186,12 @@ BOOL LLFloaterMyEnvironment::postBuild() mInventoryList->setFilterTypes(filter_types); mInventoryList->setSelectCallback([this](const std::deque&, BOOL) { onSelectionChange(); }); - mInventoryList->setShowFolderState(mShowFolders); mInventoryList->setFilterSettingsTypes(mTypeFilter); } childSetCommitCallback(CHECK_DAYS, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); childSetCommitCallback(CHECK_SKIES, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); childSetCommitCallback(CHECK_WATER, [this](LLUICtrl*, void*) { onFilterCheckChange(); }, nullptr); - childSetCommitCallback(CHECK_SHOWFOLDERS, [this](LLUICtrl*, void*) { onShowFoldersChange(); }, nullptr); childSetCommitCallback(BUTTON_DELETE, [this](LLUICtrl *, void*) { onDeleteSelected(); }, nullptr); @@ -204,8 +200,6 @@ BOOL LLFloaterMyEnvironment::postBuild() void LLFloaterMyEnvironment::refresh() { - getChild(CHECK_SHOWFOLDERS)->setValue(LLSD::Boolean(mShowFolders == LLInventoryFilter::SHOW_ALL_FOLDERS)); - getChild(CHECK_DAYS)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_DAYCYCLE)))); getChild(CHECK_SKIES)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_SKY)))); getChild(CHECK_WATER)->setValue(LLSD::Boolean(mTypeFilter & (0x01 << static_cast(LLSettingsType::ST_WATER)))); @@ -238,16 +232,6 @@ void LLFloaterMyEnvironment::onOpen(const LLSD& key) } //------------------------------------------------------------------------- -void LLFloaterMyEnvironment::onShowFoldersChange() -{ - bool show_check (getChild(CHECK_SHOWFOLDERS)->getValue().asBoolean()); - - mShowFolders = (show_check) ? LLInventoryFilter::SHOW_ALL_FOLDERS : LLInventoryFilter::SHOW_NON_EMPTY_FOLDERS; - - if (mInventoryList) - mInventoryList->setShowFolderState(mShowFolders); -} - void LLFloaterMyEnvironment::onFilterCheckChange() { mTypeFilter = 0x0; diff --git a/indra/newview/llfloatermyenvironment.h b/indra/newview/llfloatermyenvironment.h index 10d64eaa93..9472fb63e2 100644 --- a/indra/newview/llfloatermyenvironment.h +++ b/indra/newview/llfloatermyenvironment.h @@ -61,10 +61,8 @@ public: private: LLInventoryPanel * mInventoryList; U64 mTypeFilter; - LLInventoryFilter::EFolderShow mShowFolders; LLUUID mSelectedAsset; - void onShowFoldersChange(); void onFilterCheckChange(); void onSelectionChange(); void onDeleteSelected(); diff --git a/indra/newview/skins/default/xui/en/floater_my_environments.xml b/indra/newview/skins/default/xui/en/floater_my_environments.xml index c9238b80b3..854ac8b758 100644 --- a/indra/newview/skins/default/xui/en/floater_my_environments.xml +++ b/indra/newview/skins/default/xui/en/floater_my_environments.xml @@ -114,22 +114,6 @@ filter_asset_type="settings"/> - - - Date: Mon, 8 Apr 2019 10:34:59 -0700 Subject: [PATCH 23/40] Make ambient clamping consistent between class1/2 deferred lighting and forward rendering. Add decls for intermediate lighting values for debug. --- .../shaders/class1/deferred/alphaF.glsl | 20 +++++++++++++++++-- .../shaders/class1/deferred/materialF.glsl | 16 ++++++++++++++- .../shaders/class1/deferred/softenLightF.glsl | 11 ++++++++++ .../shaders/class1/lighting/sumLightsV.glsl | 2 +- .../shaders/class2/deferred/softenLightF.glsl | 10 +++++++++- .../class2/windlight/atmosphericsF.glsl | 2 +- 6 files changed, 55 insertions(+), 6 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 6e693bd33b..fb24927b26 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -190,7 +190,7 @@ void main() calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); - vec2 abnormal = encode_normal(norm.xyz); + vec2 abnormal = encode_normal(norm.xyz); vec3 light_dir = (sun_up_factor == 1) ? sun_dir: moon_dir; float da = dot(norm.xyz, light_dir.xyz); @@ -208,15 +208,23 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; - ambient = max(0.9, ambient); // keeps shadows dark + ambient = max(0.66, ambient); // keeps shadows dark ambient = 1.0 - ambient; vec3 sun_contrib = min(final_da, shadow) * sunlit; color.rgb *= ambient; + +vec3 post_ambient = color.rgb; + color.rgb += sun_contrib; + +vec3 post_sunlight = color.rgb; + color.rgb *= diff.rgb; +vec3 post_diffuse = color.rgb; + //color.rgb = mix(diff.rgb, color.rgb, final_alpha); color.rgb = atmosFragLighting(color.rgb, additive, atten); @@ -224,6 +232,8 @@ void main() vec4 light = vec4(0,0,0,0); +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); LIGHT_LOOP(1) @@ -238,13 +248,19 @@ void main() // color.rgb += light.rgb; +vec3 postlight_linear = color.rgb; + +color.rgb = prelight_linearish_maybe; + color.rgb = linear_to_srgb(color.rgb); + #endif #ifdef WATER_FOG color = applyWaterFogView(pos.xyz, color); #endif + frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 4a47311eb7..4bb01824bf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -305,16 +305,24 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; - ambient = max(0.9, ambient); + ambient = max(0.66, ambient); ambient = 1.0 - ambient; vec3 sun_contrib = min(final_da, shadow) * sunlit; col.rgb = amblit; col.rgb *= ambient; + +vec3 post_ambient = col.rgb; + col.rgb += sun_contrib; + +vec3 post_sunlight = col.rgb; + col.rgb *= diffuse.rgb; +vec3 post_diffuse = col.rgb; + float glare = 0.0; if (spec.a > 0.0) // specular reflection @@ -363,6 +371,8 @@ vec3 post_spec = col.rgb; vec3 light = vec3(0,0,0); + 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); LIGHT_LOOP(1) @@ -375,6 +385,8 @@ vec3 post_spec = col.rgb; col.rgb += light.rgb; +vec3 postlight_linear = col.rgb; + glare = min(glare, 1.0); float al = max(diffcol.a,glare)*vertex_color.a; @@ -384,6 +396,8 @@ vec3 post_spec = col.rgb; al = temp.a; #endif +//col.rgb = prelight_linearish_maybe; + col.rgb = linear_to_srgb(col.rgb); frag_color.rgb = 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 361ed40eaf..4b9e8290dd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -112,15 +112,24 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; + ambient = max(0.66, ambient); ambient = 1.0 - ambient; vec3 sun_contrib = final_da * sunlit; col.rgb = amblit; col.rgb *= ambient; + +vec3 post_ambient = col.rgb; + col.rgb += sun_contrib; + +vec3 post_sunlight = col.rgb; + col.rgb *= diffuse.rgb; +vec3 post_diffuse = col.rgb; + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); if (spec.a > 0.0) // specular reflection @@ -168,6 +177,8 @@ void main() col = fogged.rgb; bloom = fogged.a; #endif + +//col.rgb = post_diffuse; } frag_color.rgb = col.rgb; diff --git a/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl b/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl index 7d699a4967..4d7cff37c6 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/sumLightsV.glsl @@ -34,7 +34,7 @@ vec3 scaleDownLight(vec3 light); vec4 sumLights(vec3 pos, vec3 norm, vec4 color, vec4 baseLight) { - vec4 col; + vec4 col = vec4(0); col.a = color.a; col.rgb = light_diffuse[1].rgb * calcDirectionalLight(norm, light_position[1].xyz); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 12115082a9..8814587fbc 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -126,16 +126,24 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; - ambient = max(0.9, ambient); + ambient = max(0.66, ambient); ambient = 1.0 - ambient; vec3 sun_contrib = min(scol, final_da) * sunlit; col.rgb = amblit; col.rgb *= ambient; + +vec3 post_ambient = col.rgb; + col.rgb += sun_contrib; + +vec3 post_sunlight = col.rgb; + col.rgb *= diffuse.rgb; +vec3 post_diffuse = col.rgb; + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); if (spec.a > 0.0) // specular reflection diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 40c521cd2c..f1398afb99 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -152,7 +152,7 @@ void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, + tmpAmbient)); //brightness of surface both sunlight and ambient - sunlit = vec3(sunlight.rgb* 0.5); + sunlit = vec3(sunlight.rgb); amblit = vec3(tmpAmbient * .25); additive = normalize(additive); additive *= vec3(1.0 - exp(-temp2.z * distance_multiplier)) * 0.5; From 759525040ac11a2edee541c944ad0c6e9cc04d0f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 8 Apr 2019 13:07:44 -0700 Subject: [PATCH 24/40] SL-10912 Fix conversion of star brightness, density mult, and distance mult to legacy ranges. Make settings look in both legacyhaze and top-level settings for haze params. --- indra/llinventory/llsettingssky.cpp | 75 +++++++++++++---------------- indra/llinventory/llsettingssky.h | 3 ++ indra/newview/llsettingsvo.cpp | 4 +- 3 files changed, 40 insertions(+), 42 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 9211a48a8e..a0d81e6d99 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -737,7 +737,7 @@ LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position) dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue(); dfltsetting[SETTING_MOON_BRIGHTNESS] = LLSD::Real(0.5f); - dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(256.0000); + dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(250.0000); dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue(); dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); @@ -1037,72 +1037,65 @@ LLColor3 LLSettingsSky::getLightDiffuse() const return LLColor3::white; } +LLColor3 LLSettingsSky::getColor(const std::string& key, const LLColor3& default_value) const +{ + if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(key)) + { + return LLColor3(mSettings[SETTING_LEGACY_HAZE][key]); + } + if (mSettings.has(key)) + { + return LLColor3(mSettings[key]); + } + return default_value; +} + +F32 LLSettingsSky::getFloat(const std::string& key, F32 default_value) const +{ + if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(key)) + { + return mSettings[SETTING_LEGACY_HAZE][key].asReal(); + } + if (mSettings.has(key)) + { + return mSettings[key].asReal(); + } + return default_value; +} + LLColor3 LLSettingsSky::getAmbientColor() const { - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_AMBIENT)) - { - return LLColor3(mSettings[SETTING_LEGACY_HAZE][SETTING_AMBIENT]); - } - if (mSettings.has(SETTING_AMBIENT)) - { - return LLColor3(mSettings[SETTING_AMBIENT]); - } - return LLColor3(0.25f, 0.25f, 0.25f); + return getColor(SETTING_AMBIENT, LLColor3(0.25f, 0.25f, 0.25f)); } LLColor3 LLSettingsSky::getBlueDensity() const { - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_BLUE_DENSITY)) - { - return LLColor3(mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_DENSITY]); - } - return LLColor3(0.2447f, 0.4487f, 0.7599f); + return getColor(SETTING_BLUE_DENSITY, LLColor3(0.2447f, 0.4487f, 0.7599f)); } LLColor3 LLSettingsSky::getBlueHorizon() const { - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_BLUE_HORIZON)) - { - return LLColor3(mSettings[SETTING_LEGACY_HAZE][SETTING_BLUE_HORIZON]); - } - return LLColor3(0.4954f, 0.4954f, 0.6399f); + return getColor(SETTING_BLUE_HORIZON, LLColor3(0.4954f, 0.4954f, 0.6399f)); } F32 LLSettingsSky::getHazeDensity() const { - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_HAZE_DENSITY)) - { - return mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_DENSITY].asReal(); - } - return 0.7f; + return getFloat(SETTING_HAZE_DENSITY, 0.7f); } F32 LLSettingsSky::getHazeHorizon() const { - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_HAZE_HORIZON)) - { - return mSettings[SETTING_LEGACY_HAZE][SETTING_HAZE_HORIZON].asReal(); - } - return 0.19f; + return getFloat(SETTING_HAZE_HORIZON, 0.19f); } F32 LLSettingsSky::getDensityMultiplier() const { - F32 density_multiplier = 0.0001f; - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_DENSITY_MULTIPLIER)) - { - density_multiplier = mSettings[SETTING_LEGACY_HAZE][SETTING_DENSITY_MULTIPLIER].asReal(); - } - return density_multiplier; + return getFloat(SETTING_DENSITY_MULTIPLIER, 0.0001f); } F32 LLSettingsSky::getDistanceMultiplier() const { - if (mSettings.has(SETTING_LEGACY_HAZE) && mSettings[SETTING_LEGACY_HAZE].has(SETTING_DISTANCE_MULTIPLIER)) - { - return mSettings[SETTING_LEGACY_HAZE][SETTING_DISTANCE_MULTIPLIER].asReal(); - } - return 0.8f; + return getFloat(SETTING_DISTANCE_MULTIPLIER, 0.8f); } void LLSettingsSky::setPlanetRadius(F32 radius) diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index cd173a6b18..d585eeddfa 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -337,6 +337,9 @@ private: static LLSD absorptionConfigDefault(); static LLSD mieConfigDefault(); + LLColor3 getColor(const std::string& key, const LLColor3& default_value) const; + F32 getFloat(const std::string& key, F32 default_value) const; + void calculateHeavenlyBodyPositions() const; void calculateLightSettings() const; diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 6556380f28..60f4cd3f5a 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -568,9 +568,11 @@ void LLSettingsVOSky::convertAtmosphericsToLegacy(LLSD& legacy, LLSD& settings) F32 density_multiplier = legacyhaze[SETTING_DENSITY_MULTIPLIER].asReal(); density_multiplier = (density_multiplier < 0.0001f) ? 0.0001f : density_multiplier; + density_multiplier *= 0.9f / 2.0f; // take 0 - 2.0 range to 0 - 0.9 range legacy[SETTING_DENSITY_MULTIPLIER] = LLSDArray(density_multiplier)(0.0f)(0.0f)(1.0f); F32 distance_multiplier = legacyhaze[SETTING_DISTANCE_MULTIPLIER].asReal(); + distance_multiplier *= 0.1f; // take 0 - 1000 range to 0 - 100 range legacy[SETTING_DISTANCE_MULTIPLIER] = LLSDArray(distance_multiplier)(0.0f)(0.0f)(1.0f); legacy[SETTING_HAZE_DENSITY] = LLSDArray(legacyhaze[SETTING_HAZE_DENSITY])(0.0f)(0.0f)(1.0f); @@ -597,7 +599,7 @@ LLSD LLSettingsVOSky::convertToLegacy(const LLSettingsSky::ptr_t &psky, bool isA legacy[SETTING_GLOW] = ensure_array_4(settings[SETTING_GLOW], 1.0); legacy[SETTING_LIGHT_NORMAL] = ensure_array_4(psky->getLightDirection().getValue(), 0.0f); legacy[SETTING_MAX_Y] = LLSDArray(settings[SETTING_MAX_Y])(0.0f)(0.0f)(1.0f); - legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS]; + legacy[SETTING_STAR_BRIGHTNESS] = settings[SETTING_STAR_BRIGHTNESS].asReal() / 250.0f; // convert from 0-500 -> 0-2 ala pre-FS-compat changes legacy[SETTING_SUNLIGHT_COLOR] = ensure_array_4(settings[SETTING_SUNLIGHT_COLOR], 1.0f); LLVector3 dir = psky->getLightDirection(); From 996d441ddc64996711b5a4eb3135607686992b86 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 8 Apr 2019 16:53:57 -0700 Subject: [PATCH 25/40] SL-5186 Make projector ambiance unshadowed in both forward and deferred for consistency. --- .../shaders/class1/deferred/alphaF.glsl | 19 ++++++++----------- .../shaders/class1/deferred/materialF.glsl | 17 ++++++++--------- .../class2/deferred/multiSpotLightF.glsl | 12 ++++++++---- .../shaders/class2/deferred/spotLightF.glsl | 10 ++++++---- 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; } } From a50590ec4b685e4a4f4c5d8f4bf0c14dae684fc3 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 9 Apr 2019 10:40:49 -0700 Subject: [PATCH 26/40] SL-10925, SL-10926 Restore letting env auto-update sunlight_color uniform (other shaders expect it even if lighting does not). --- indra/newview/llsettingsvo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 60f4cd3f5a..eb92c11952 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -721,7 +721,7 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); - //param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); From 07739f5d74b3bbdf98e8e6422782e07c9a5775a5 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 9 Apr 2019 10:43:58 -0700 Subject: [PATCH 27/40] Fix viewer version to restore update to 6.2.0 for EEP --- indra/newview/VIEWER_VERSION.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/VIEWER_VERSION.txt b/indra/newview/VIEWER_VERSION.txt index 5e3254243a..6abaeb2f90 100644 --- a/indra/newview/VIEWER_VERSION.txt +++ b/indra/newview/VIEWER_VERSION.txt @@ -1 +1 @@ -6.1.2 +6.2.0 From f9c0b021ea1a695c0d5d4042981045fe265e7918 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 9 Apr 2019 13:02:58 -0700 Subject: [PATCH 28/40] SL-5186 Fix falloff on projectors in forward rendering (different falloff calcs than deferred). --- .../shaders/class1/deferred/alphaF.glsl | 10 +++++----- .../shaders/class1/deferred/materialF.glsl | 16 ++++++++++------ indra/newview/pipeline.cpp | 2 +- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 4b99592dbb..4fe0d1351d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -92,8 +92,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float d = length(lv); float da = 1.0; vec3 col = vec3(0); - - if (d > 0.0 && fa > 0.0) + if (d > 0.0) { //normalize light vector lv = normalize(lv); @@ -103,8 +102,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec da = clamp(da, 0.0, 1.0); //distance attenuation - float dist = d/la; - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + float dist = (la > 0) ? d/la : 1.0f; + fa += 1.0f; + float dist_atten = (fa > 0) ? clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0) : 1.0f; dist_atten *= dist_atten; dist_atten *= 2.0f; @@ -230,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, 1.0); + #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 * 0.5, 1.0); LIGHT_LOOP(1) LIGHT_LOOP(2) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 8c5a0ef297..6d7162b5a2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -95,14 +95,15 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe vec3 col = vec3(0,0,0); - if (d > 0.0 && la > 0.0 && fa > 0.0) + if (d > 0.0) { //normalize light vector lv = normalize(lv); //distance attenuation - float dist = d/la; - float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); + float dist = (la > 0) ? d/la : 1.0f; + fa += 1.0f; + float dist_atten = ( fa > 0) ? clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0) : 1.0f; dist_atten *= dist_atten; dist_atten *= 2.0f; @@ -121,8 +122,11 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe col = light_col*lit*diffuse*shadow; float amb_da = ambiance; - amb_da += (da*0.5+0.5) * (1.0 - shadow) * ambiance; - amb_da += (da*da*0.5 + 0.5) * (1.0 - shadow) * ambiance; + if (da > 0) + { + amb_da += (da*0.5 + 0.5) * ambiance; + } + amb_da += (da*da*0.5+0.5) * ambiance; amb_da = min(amb_da, 1.0f - lit); col.rgb += amb_da * 0.5 * light_col * diffuse; @@ -370,7 +374,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, 1.0); + #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, 1.0); LIGHT_LOOP(1) LIGHT_LOOP(2) diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 7139788c18..27b280a4a8 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6321,7 +6321,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) { F32 size = light_radius*1.5f; light_state->setLinearAttenuation(size); - light_state->setQuadraticAttenuation(light->getLightFalloff()*0.5f+1.f); + light_state->setQuadraticAttenuation(light->getLightFalloff()*0.5f); } else { From dcd8117b85f45886f78a1a2e9756cb1709d6572a Mon Sep 17 00:00:00 2001 From: Geenz Date: Tue, 9 Apr 2019 22:35:40 -0700 Subject: [PATCH 29/40] First stab at moving atmospheric var calcs to its own utility shader. Still some work to go here. Largely related to how certain values (i.e., SSAO mix values) are supplied. But so far, so good. --HG-- branch : OPEN-340 --- doc/contributions.txt | 1 + indra/llrender/llshadermgr.cpp | 8 ++ .../class1/windlight/atmosphericsFuncs.glsl | 116 ++++++++++++++++++ .../shaders/class2/deferred/softenLightF.glsl | 6 +- indra/newview/llviewershadermgr.cpp | 4 +- 5 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl diff --git a/doc/contributions.txt b/doc/contributions.txt index c9a382d455..5bf45bc6c7 100755 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -491,6 +491,7 @@ Geenz Spad BUG-226648 OPEN-339 BUG-226620 + OPEN-340 Gene Frostbite GeneJ Composer Geneko Nemeth diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 4303c3ed11..071f40d924 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -96,6 +96,10 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { return FALSE; } + + if (!shader->attachObject("windlight/atmosphericsFuncs.glsl")) { + return FALSE; + } } if (features->calculatesLighting) @@ -194,6 +198,10 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { return FALSE; } + + if (!shader->attachObject("windlight/atmosphericsFuncs.glsl")) { + return FALSE; + } } // we want this BEFORE shadows and AO because those facilities use pos/norm access diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl new file mode 100644 index 0000000000..2854fb8139 --- /dev/null +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -0,0 +1,116 @@ +uniform vec4 gamma; +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; +uniform vec4 ambient; +uniform vec4 blue_horizon; +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; +uniform mat3 ssao_effect_mat; +uniform int no_atmo; +uniform float sun_moon_glow_factor; + +vec3 nothing() { + return vec3(0, 0, 0); +} + +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten) { + + vec3 P = inPositionEye; + + //(TERRAIN) limit altitude + if (P.y > max_y) P *= (max_y / P.y); + if (P.y < -max_y) P *= (-max_y / P.y); + + vec3 tmpLightnorm = lightnorm.xyz; + + vec3 Pn = normalize(P); + float Plen = length(P); + + vec4 temp1 = vec4(0); + vec3 temp2 = vec3(0); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec4 light_atten; + + //sunlight attenuation effect (hue and brightness) due to atmosphere + //this is used later for sunlight modulation at various altitudes + light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + //I had thought blue_density and haze_density should have equal weighting, + //but attenuation due to haze_density tends to seem too strong + + temp1 = blue_density + vec4(haze_density); + blue_weight = blue_density / temp1; + haze_weight = vec4(haze_density) / temp1; + + //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) + temp2.y = max(0.0, tmpLightnorm.y); + if (temp2.y > 0.001f) + { + temp2.y = 1. / temp2.y; + } + temp2.y = max(0.001f, temp2.y); + sunlight *= exp(-light_atten * temp2.y); + + // main atmospheric scattering line integral + temp2.z = Plen * density_multiplier; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z * distance_multiplier); + + //final atmosphere attenuation factor + atten = temp1.rgb; + + //compute haze glow + //(can use temp2.x as temp because we haven't used it yet) + temp2.x = dot(Pn, tmpLightnorm.xyz); + temp2.x = 1. - temp2.x; + //temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .03); //was glow.y + //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + //higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + //glow.z should be negative, so we're doing a sort of (1 / "angle") function + + //add "minimum anti-solar illumination" + temp2.x += .25; + + temp2.x *= sun_moon_glow_factor; + + //increase ambient when there are more clouds + vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; + + /* decrease value and saturation (that in HSV, not HSL) for occluded areas + * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html + * // The following line of code performs the equivalent of: + * float ambAlpha = tmpAmbient.a; + * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis + * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); + * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); + */ + tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); + + //haze color + additive = + vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x + + tmpAmbient)); + + //brightness of surface both sunlight and ambient + sunlit = vec3(sunlight.rgb); + amblit = vec3(tmpAmbient * .25); + additive = normalize(additive); + additive *= vec3(1.0 - exp(-temp2.z * distance_multiplier)) * 0.5; +} \ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 8814587fbc..4c7c50315f 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -72,6 +72,8 @@ vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 fullbrightScaleSoftClipFrag(vec3 l, vec3 add, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); + vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten); vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten); vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten); @@ -79,6 +81,8 @@ vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten); vec4 getPositionWithDepth(vec2 pos_screen, float depth); vec4 getPosition(vec2 pos_screen); +vec3 nothing(); + #ifdef WATER_FOG vec4 applyWaterFogView(vec3 pos, vec4 color); #endif @@ -121,7 +125,7 @@ void main() vec3 additive; vec3 atten; - calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten); + calcAtmosphericVars(pos.xyz, ambocc, sunlit, amblit, additive, atten); float ambient = da; ambient *= 0.5; diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index c6d727430c..cc5b0a090c 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -932,6 +932,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders() shaders.push_back( make_pair( "windlight/atmosphericsVarsV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); shaders.push_back( make_pair( "windlight/atmosphericsVarsWaterV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); shaders.push_back( make_pair( "windlight/atmosphericsHelpersV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + shaders.push_back( make_pair( "windlight/atmosphericsFuncs.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); shaders.push_back( make_pair( "lighting/lightFuncV.glsl", mShaderLevel[SHADER_LIGHTING] ) ); shaders.push_back( make_pair( "lighting/sumLightsV.glsl", sum_lights_class ) ); shaders.push_back( make_pair( "lighting/lightV.glsl", mShaderLevel[SHADER_LIGHTING] ) ); @@ -977,6 +978,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsWaterF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsHelpersF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsFuncs.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/gammaF.glsl", mShaderLevel[SHADER_WINDLIGHT]) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/transportF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); @@ -1006,7 +1008,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); From 08812cbe060e62cb8b61e91bc2f878a74a0015e5 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 10 Apr 2019 02:11:07 -0700 Subject: [PATCH 30/40] Separate out vertex program objects from fragment program objects and use it. Given that mShaderObjects only ever expects one copy of a given shader object (leading to lots of "shaderV" and "shaderF"), it made having utility shaders a bit more difficult to incorporate. This change makes sure the two are separated. Using this over a multimap largely for readibility. Also, actually, you know, use this functionality. --HG-- branch : OPEN-340 --- indra/llrender/llglslshader.cpp | 23 +++- indra/llrender/llglslshader.h | 3 +- indra/llrender/llshadermgr.cpp | 129 +++++++++--------- indra/llrender/llshadermgr.h | 3 +- .../shaders/class1/deferred/softenLightF.glsl | 6 +- .../class1/windlight/atmosphericsFuncs.glsl | 6 +- .../shaders/class2/deferred/softenLightF.glsl | 2 +- .../class2/windlight/atmosphericsV.glsl | 128 ++--------------- indra/newview/llviewershadermgr.cpp | 7 +- 9 files changed, 112 insertions(+), 195 deletions(-) diff --git a/indra/llrender/llglslshader.cpp b/indra/llrender/llglslshader.cpp index f8b5dd0559..babf649ece 100644 --- a/indra/llrender/llglslshader.cpp +++ b/indra/llrender/llglslshader.cpp @@ -485,12 +485,27 @@ BOOL LLGLSLShader::createShader(std::vector * attributes, return success; } -BOOL LLGLSLShader::attachObject(std::string object_path) -{ - if (LLShaderMgr::instance()->mShaderObjects.count(object_path) > 0) +BOOL LLGLSLShader::attachVertexObject(std::string object_path) { + if (LLShaderMgr::instance()->mVertexShaderObjects.count(object_path) > 0) { stop_glerror(); - glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mShaderObjects[object_path]); + glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mVertexShaderObjects[object_path]); + stop_glerror(); + return TRUE; + } + else + { + LL_SHADER_LOADING_WARNS() << "Attempting to attach shader object: '" << object_path << "' that hasn't been compiled." << LL_ENDL; + return FALSE; + } +} + +BOOL LLGLSLShader::attachFragmentObject(std::string object_path) +{ + if (LLShaderMgr::instance()->mFragmentShaderObjects.count(object_path) > 0) + { + stop_glerror(); + glAttachObjectARB(mProgramObject, LLShaderMgr::instance()->mFragmentShaderObjects[object_path]); stop_glerror(); return TRUE; } diff --git a/indra/llrender/llglslshader.h b/indra/llrender/llglslshader.h index 974d0ea005..38dc980a97 100644 --- a/indra/llrender/llglslshader.h +++ b/indra/llrender/llglslshader.h @@ -102,7 +102,8 @@ public: std::vector * uniforms, U32 varying_count = 0, const char** varyings = NULL); - BOOL attachObject(std::string object); + BOOL attachFragmentObject(std::string object); + BOOL attachVertexObject(std::string object); void attachObject(GLhandleARB object); void attachObjects(GLhandleARB* objects = NULL, S32 count = 0); BOOL mapAttributes(const std::vector * attributes); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 071f40d924..27f9e36f0f 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -79,12 +79,12 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->hasWaterFog) { - if (!shader->attachObject("windlight/atmosphericsVarsWaterV.glsl")) + if (!shader->attachVertexObject("windlight/atmosphericsVarsWaterV.glsl")) { return FALSE; } } - else if (!shader->attachObject("windlight/atmosphericsVarsV.glsl")) + else if (!shader->attachVertexObject("windlight/atmosphericsVarsV.glsl")) { return FALSE; } @@ -92,54 +92,50 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->calculatesLighting || features->calculatesAtmospherics) { - if (!shader->attachObject("windlight/atmosphericsHelpersV.glsl")) + if (!shader->attachVertexObject("windlight/atmosphericsHelpersV.glsl")) { return FALSE; } - - if (!shader->attachObject("windlight/atmosphericsFuncs.glsl")) { - return FALSE; - } } if (features->calculatesLighting) { if (features->isSpecular) { - if (!shader->attachObject("lighting/lightFuncSpecularV.glsl")) + if (!shader->attachVertexObject("lighting/lightFuncSpecularV.glsl")) { return FALSE; } if (!features->isAlphaLighting) { - if (!shader->attachObject("lighting/sumLightsSpecularV.glsl")) + if (!shader->attachVertexObject("lighting/sumLightsSpecularV.glsl")) { return FALSE; } } - if (!shader->attachObject("lighting/lightSpecularV.glsl")) + if (!shader->attachVertexObject("lighting/lightSpecularV.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightFuncV.glsl")) + if (!shader->attachVertexObject("lighting/lightFuncV.glsl")) { return FALSE; } if (!features->isAlphaLighting) { - if (!shader->attachObject("lighting/sumLightsV.glsl")) + if (!shader->attachVertexObject("lighting/sumLightsV.glsl")) { return FALSE; } } - if (!shader->attachObject("lighting/lightV.glsl")) + if (!shader->attachVertexObject("lighting/lightV.glsl")) { return FALSE; } @@ -148,8 +144,12 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) // NOTE order of shader object attaching is VERY IMPORTANT!!! if (features->calculatesAtmospherics) - { - if (!shader->attachObject("windlight/atmosphericsV.glsl")) + { + if (!shader->attachVertexObject("windlight/atmosphericsFuncs.glsl")) { + return FALSE; + } + + if (!shader->attachVertexObject("windlight/atmosphericsV.glsl")) { return FALSE; } @@ -157,7 +157,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasSkinning) { - if (!shader->attachObject("avatar/avatarSkinV.glsl")) + if (!shader->attachVertexObject("avatar/avatarSkinV.glsl")) { return FALSE; } @@ -165,7 +165,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasObjectSkinning) { - if (!shader->attachObject("avatar/objectSkinV.glsl")) + if (!shader->attachVertexObject("avatar/objectSkinV.glsl")) { return FALSE; } @@ -181,12 +181,12 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->hasWaterFog) { - if (!shader->attachObject("windlight/atmosphericsVarsWaterF.glsl")) + if (!shader->attachFragmentObject("windlight/atmosphericsVarsWaterF.glsl")) { return FALSE; } } - else if (!shader->attachObject("windlight/atmosphericsVarsF.glsl")) + else if (!shader->attachFragmentObject("windlight/atmosphericsVarsF.glsl")) { return FALSE; } @@ -194,20 +194,16 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->calculatesLighting || features->calculatesAtmospherics) { - if (!shader->attachObject("windlight/atmosphericsHelpersF.glsl")) + if (!shader->attachFragmentObject("windlight/atmosphericsHelpersF.glsl")) { return FALSE; } - - if (!shader->attachObject("windlight/atmosphericsFuncs.glsl")) { - return FALSE; - } } // we want this BEFORE shadows and AO because those facilities use pos/norm access if (features->isDeferred) { - if (!shader->attachObject("deferred/deferredUtil.glsl")) + if (!shader->attachFragmentObject("deferred/deferredUtil.glsl")) { return FALSE; } @@ -215,7 +211,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasShadows) { - if (!shader->attachObject("deferred/shadowUtil.glsl")) + if (!shader->attachFragmentObject("deferred/shadowUtil.glsl")) { return FALSE; } @@ -223,7 +219,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasAmbientOcclusion) { - if (!shader->attachObject("deferred/aoUtil.glsl")) + if (!shader->attachFragmentObject("deferred/aoUtil.glsl")) { return FALSE; } @@ -231,7 +227,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasIndirect) { - if (!shader->attachObject("deferred/indirect.glsl")) + if (!shader->attachFragmentObject("deferred/indirect.glsl")) { return FALSE; } @@ -239,7 +235,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasGamma) { - if (!shader->attachObject("windlight/gammaF.glsl")) + if (!shader->attachFragmentObject("windlight/gammaF.glsl")) { return FALSE; } @@ -247,7 +243,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasSrgb) { - if (!shader->attachObject("environment/srgbF.glsl")) + if (!shader->attachFragmentObject("environment/srgbF.glsl")) { return FALSE; } @@ -255,15 +251,19 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->encodesNormal) { - if (!shader->attachObject("environment/encodeNormF.glsl")) + if (!shader->attachFragmentObject("environment/encodeNormF.glsl")) { return FALSE; } } if (features->hasAtmospherics) - { - if (!shader->attachObject("windlight/atmosphericsF.glsl")) + { + if (!shader->attachFragmentObject("windlight/atmosphericsFuncs.glsl")) { + return FALSE; + } + + if (!shader->attachFragmentObject("windlight/atmosphericsF.glsl")) { return FALSE; } @@ -271,7 +271,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasTransport) { - if (!shader->attachObject("windlight/transportF.glsl")) + if (!shader->attachFragmentObject("windlight/transportF.glsl")) { return FALSE; } @@ -283,7 +283,7 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) // NOTE order of shader object attaching is VERY IMPORTANT!!! if (features->hasWaterFog) { - if (!shader->attachObject("environment/waterFogF.glsl")) + if (!shader->attachFragmentObject("environment/waterFogF.glsl")) { return FALSE; } @@ -297,14 +297,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->hasAlphaMask) { - if (!shader->attachObject("lighting/lightWaterAlphaMaskNonIndexedF.glsl")) + if (!shader->attachFragmentObject("lighting/lightWaterAlphaMaskNonIndexedF.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightWaterNonIndexedF.glsl")) + if (!shader->attachFragmentObject("lighting/lightWaterNonIndexedF.glsl")) { return FALSE; } @@ -314,14 +314,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->hasAlphaMask) { - if (!shader->attachObject("lighting/lightWaterAlphaMaskF.glsl")) + if (!shader->attachFragmentObject("lighting/lightWaterAlphaMaskF.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightWaterF.glsl")) + if (!shader->attachFragmentObject("lighting/lightWaterF.glsl")) { return FALSE; } @@ -336,14 +336,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->hasAlphaMask) { - if (!shader->attachObject("lighting/lightAlphaMaskNonIndexedF.glsl")) + if (!shader->attachFragmentObject("lighting/lightAlphaMaskNonIndexedF.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightNonIndexedF.glsl")) + if (!shader->attachFragmentObject("lighting/lightNonIndexedF.glsl")) { return FALSE; } @@ -353,14 +353,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->hasAlphaMask) { - if (!shader->attachObject("lighting/lightAlphaMaskF.glsl")) + if (!shader->attachFragmentObject("lighting/lightAlphaMaskF.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightF.glsl")) + if (!shader->attachFragmentObject("lighting/lightF.glsl")) { return FALSE; } @@ -378,14 +378,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->disableTextureIndex) { - if (!shader->attachObject("lighting/lightFullbrightShinyWaterNonIndexedF.glsl")) + if (!shader->attachFragmentObject("lighting/lightFullbrightShinyWaterNonIndexedF.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightFullbrightShinyWaterF.glsl")) + if (!shader->attachFragmentObject("lighting/lightFullbrightShinyWaterF.glsl")) { return FALSE; } @@ -398,12 +398,12 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->hasAlphaMask) { - if (!shader->attachObject("lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl")) + if (!shader->attachFragmentObject("lighting/lightFullbrightWaterNonIndexedAlphaMaskF.glsl")) { return FALSE; } } - else if (!shader->attachObject("lighting/lightFullbrightWaterNonIndexedF.glsl")) + else if (!shader->attachFragmentObject("lighting/lightFullbrightWaterNonIndexedF.glsl")) { return FALSE; } @@ -412,12 +412,12 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->hasAlphaMask) { - if (!shader->attachObject("lighting/lightFullbrightWaterAlphaMaskF.glsl")) + if (!shader->attachFragmentObject("lighting/lightFullbrightWaterAlphaMaskF.glsl")) { return FALSE; } } - else if (!shader->attachObject("lighting/lightFullbrightWaterF.glsl")) + else if (!shader->attachFragmentObject("lighting/lightFullbrightWaterF.glsl")) { return FALSE; } @@ -429,14 +429,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->disableTextureIndex) { - if (!shader->attachObject("lighting/lightFullbrightShinyNonIndexedF.glsl")) + if (!shader->attachFragmentObject("lighting/lightFullbrightShinyNonIndexedF.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightFullbrightShinyF.glsl")) + if (!shader->attachFragmentObject("lighting/lightFullbrightShinyF.glsl")) { return FALSE; } @@ -451,14 +451,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->hasAlphaMask) { - if (!shader->attachObject("lighting/lightFullbrightNonIndexedAlphaMaskF.glsl")) + if (!shader->attachFragmentObject("lighting/lightFullbrightNonIndexedAlphaMaskF.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightFullbrightNonIndexedF.glsl")) + if (!shader->attachFragmentObject("lighting/lightFullbrightNonIndexedF.glsl")) { return FALSE; } @@ -468,14 +468,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->hasAlphaMask) { - if (!shader->attachObject("lighting/lightFullbrightAlphaMaskF.glsl")) + if (!shader->attachFragmentObject("lighting/lightFullbrightAlphaMaskF.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightFullbrightF.glsl")) + if (!shader->attachFragmentObject("lighting/lightFullbrightF.glsl")) { return FALSE; } @@ -493,14 +493,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->disableTextureIndex) { - if (!shader->attachObject("lighting/lightShinyWaterNonIndexedF.glsl")) + if (!shader->attachFragmentObject("lighting/lightShinyWaterNonIndexedF.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightShinyWaterF.glsl")) + if (!shader->attachFragmentObject("lighting/lightShinyWaterF.glsl")) { return FALSE; } @@ -512,14 +512,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) { if (features->disableTextureIndex) { - if (!shader->attachObject("lighting/lightShinyNonIndexedF.glsl")) + if (!shader->attachFragmentObject("lighting/lightShinyNonIndexedF.glsl")) { return FALSE; } } else { - if (!shader->attachObject("lighting/lightShinyF.glsl")) + if (!shader->attachFragmentObject("lighting/lightShinyF.glsl")) { return FALSE; } @@ -530,14 +530,14 @@ BOOL LLShaderMgr::attachShaderFeatures(LLGLSLShader * shader) if (features->mIndexedTextureChannels <= 1) { - if (!shader->attachObject("objects/nonindexedTextureV.glsl")) + if (!shader->attachVertexObject("objects/nonindexedTextureV.glsl")) { return FALSE; } } else { - if (!shader->attachObject("objects/indexedTextureV.glsl")) + if (!shader->attachVertexObject("objects/indexedTextureV.glsl")) { return FALSE; } @@ -1007,7 +1007,12 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade if (ret) { // Add shader file to map - mShaderObjects[filename] = ret; + if (type == GL_VERTEX_SHADER_ARB) { + mVertexShaderObjects[filename] = ret; + } + else if (type == GL_FRAGMENT_SHADER_ARB) { + mFragmentShaderObjects[filename] = ret; + } shader_level = try_gpu_class; } else diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index e0a67e6198..98caa9295e 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -275,7 +275,8 @@ public: public: // Map of shader names to compiled - std::map mShaderObjects; + std::map mVertexShaderObjects; + std::map mFragmentShaderObjects; //global (reserved slot) shader parameters std::vector mReservedAttribs; diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 4b9e8290dd..c599c14b43 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -73,6 +73,8 @@ vec3 fullbrightAtmosTransportFrag(vec3 l, vec3 additive, vec3 atten); void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); + vec3 scaleSoftClipFrag(vec3 l); vec4 getPositionWithDepth(vec2 pos_screen, float depth); @@ -107,8 +109,8 @@ void main() vec3 additive; vec3 atten; - calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, 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/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index 2854fb8139..a099083883 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -77,7 +77,7 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o temp2.x = dot(Pn, tmpLightnorm.xyz); temp2.x = 1. - temp2.x; //temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .03); //was glow.y + temp2.x = max(temp2.x, .001); //was glow.y //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) temp2.x *= glow.x; //higher glow.x gives dimmer glow (because next step is 1 / "angle") @@ -109,8 +109,8 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o + tmpAmbient)); //brightness of surface both sunlight and ambient - sunlit = vec3(sunlight.rgb); - amblit = vec3(tmpAmbient * .25); + sunlit = sunlight.rgb; + amblit = tmpAmbient.rgb * .25; additive = normalize(additive); additive *= vec3(1.0 - exp(-temp2.z * distance_multiplier)) * 0.5; } \ No newline at end of file diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 4c7c50315f..2a772e6741 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -126,7 +126,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/class2/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl index 6c4098b9fb..ac7931209e 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsV.glsl @@ -34,128 +34,20 @@ void setPositionEye(vec3 v); vec3 getAdditiveColor(); -//VARYING vec4 vary_CloudUVs; -//VARYING float vary_CloudDensity; - -// Inputs -uniform vec4 morphFactor; -uniform vec3 camPosLocal; -//uniform vec4 camPosWorld; - -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; -uniform int sun_up_factor; -uniform vec4 ambient; -uniform vec4 blue_horizon; -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 sun_moon_glow_factor; +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); void calcAtmospherics(vec3 inPositionEye) { vec3 P = inPositionEye; setPositionEye(P); - - //(TERRAIN) limit altitude - if (P.y > max_y) P *= (max_y / P.y); - if (P.y < -max_y) P *= (-max_y / P.y); - - vec3 tmpLightnorm = lightnorm.xyz; - - vec3 Pn = normalize(P); - float Plen = length(P); - - vec4 temp1 = vec4(0); - vec3 temp2 = vec3(0); - vec4 blue_weight; - vec4 haze_weight; - vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; - vec4 light_atten; - - //sunlight attenuation effect (hue and brightness) due to atmosphere - //this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); - //I had thought blue_density and haze_density should have equal weighting, - //but attenuation due to haze_density tends to seem too strong - - temp1 = blue_density + vec4(haze_density); - blue_weight = blue_density / temp1; - haze_weight = vec4(haze_density) / temp1; - - //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) - temp2.y = max(0.0, tmpLightnorm.y); - if (temp2.y > 0.001f) - { - temp2.y = 1. / temp2.y; - } - temp2.y = max(0.001f, temp2.y); - sunlight *= exp( - light_atten * temp2.y); - - // main atmospheric scattering line integral - temp2.z = Plen * density_multiplier; - - // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z * distance_multiplier); - - //final atmosphere attenuation factor - setAtmosAttenuation(temp1.rgb); - //vary_AtmosAttenuation = distance_multiplier / 10000.; - //vary_AtmosAttenuation = density_multiplier * 100.; - //vary_AtmosAttenuation = vec4(Plen / 100000., 0., 0., 1.); - - //compute haze glow - //(can use temp2.x as temp because we haven't used it yet) - temp2.x = dot(Pn, tmpLightnorm.xyz); - temp2.x = 1. - temp2.x; - //temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .03); //was glow.y - //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.x *= glow.x; - //higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); - //glow.z should be negative, so we're doing a sort of (1 / "angle") function - - temp2.x *= sun_moon_glow_factor; - - //add "minimum anti-solar illumination" - temp2.x += .25; - - //increase ambient when there are more clouds - vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; - - vec3 additive = - vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) - + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x - + tmpAmbient)); - additive = normalize(additive); - - //brightness of surface both sunlight and ambient - setSunlitColor(vec3(sunlight * .5)); - setAmblitColor(vec3(tmpAmbient * .25)); - setAdditiveColor(additive * vec3(1.0 - exp(-temp2.z * distance_multiplier)) * 0.5); - - /* - const float cloudShadowScale = 100.; - // Get cloud uvs for shadowing - vec3 cloudPos = inPositionEye + camPosWorld - cloudShadowScale / 2.; - vary_CloudUVs.xy = cloudPos.xz / cloudShadowScale; - - // We can take uv1 and multiply it by (TerrainSpan / CloudSpan) -// cloudUVs *= (((worldMaxZ - worldMinZ) * 20) /40000.); - vary_CloudUVs *= (10000./40000.); - - // Offset by sun vector * (CloudAltitude / CloudSpan) - vary_CloudUVs.x += tmpLightnorm.x / tmpLightnorm.y * (3000./40000.); - vary_CloudUVs.y += tmpLightnorm.z / tmpLightnorm.y * (3000./40000.); - */ + vec3 tmpsunlit = vec3(1); + vec3 tmpamblit = vec3(1); + vec3 tmpaddlit = vec3(1); + vec3 tmpattenlit = vec3(1); + calcAtmosphericVars(inPositionEye, 1, tmpsunlit, tmpamblit, tmpaddlit, tmpattenlit); + setSunlitColor(tmpsunlit); + setAmblitColor(tmpamblit); + setAdditiveColor(tmpaddlit); + setAtmosAttenuation(tmpattenlit); } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index cc5b0a090c..da25001d8c 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -424,7 +424,8 @@ void LLViewerShaderMgr::setShaders() LLShaderMgr::instance()->mDefinitions["NUM_TEX_UNITS"] = llformat("%d", gGLManager.mNumTextureImageUnits); // Make sure the compiled shader map is cleared before we recompile shaders. - mShaderObjects.clear(); + mVertexShaderObjects.clear(); + mFragmentShaderObjects.clear(); initAttribsAndUniforms(); gPipeline.releaseGLBuffers(); @@ -932,13 +933,13 @@ BOOL LLViewerShaderMgr::loadBasicShaders() shaders.push_back( make_pair( "windlight/atmosphericsVarsV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); shaders.push_back( make_pair( "windlight/atmosphericsVarsWaterV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); shaders.push_back( make_pair( "windlight/atmosphericsHelpersV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); - shaders.push_back( make_pair( "windlight/atmosphericsFuncs.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); shaders.push_back( make_pair( "lighting/lightFuncV.glsl", mShaderLevel[SHADER_LIGHTING] ) ); shaders.push_back( make_pair( "lighting/sumLightsV.glsl", sum_lights_class ) ); shaders.push_back( make_pair( "lighting/lightV.glsl", mShaderLevel[SHADER_LIGHTING] ) ); shaders.push_back( make_pair( "lighting/lightFuncSpecularV.glsl", mShaderLevel[SHADER_LIGHTING] ) ); shaders.push_back( make_pair( "lighting/sumLightsSpecularV.glsl", sum_lights_class ) ); shaders.push_back( make_pair( "lighting/lightSpecularV.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + shaders.push_back( make_pair( "windlight/atmosphericsFuncs.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); shaders.push_back( make_pair( "windlight/atmosphericsV.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); shaders.push_back( make_pair( "avatar/avatarSkinV.glsl", 1 ) ); shaders.push_back( make_pair( "avatar/objectSkinV.glsl", 1 ) ); @@ -978,8 +979,8 @@ BOOL LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsVarsWaterF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsHelpersF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); - index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsFuncs.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/gammaF.glsl", mShaderLevel[SHADER_WINDLIGHT]) ); + index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsFuncs.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/atmosphericsF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "windlight/transportF.glsl", mShaderLevel[SHADER_WINDLIGHT] ) ); index_channels.push_back(-1); shaders.push_back( make_pair( "environment/waterFogF.glsl", mShaderLevel[SHADER_WATER] ) ); From d7d8a15092c91f6fa55547515b243b61a78868ff Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 10 Apr 2019 02:49:25 -0700 Subject: [PATCH 31/40] Fullbright + elimination of all references to calcFragAtmospherics. --HG-- branch : OPEN-340 --- doc/contributions.txt | 2 ++ .../newview/app_settings/shaders/class1/deferred/alphaF.glsl | 4 ++-- .../app_settings/shaders/class1/deferred/fullbrightF.glsl | 5 +++++ .../app_settings/shaders/class1/deferred/materialF.glsl | 4 ++-- .../app_settings/shaders/class1/deferred/softenLightF.glsl | 4 +--- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 3 +-- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/doc/contributions.txt b/doc/contributions.txt index 5bf45bc6c7..cfc98584bc 100755 --- a/doc/contributions.txt +++ b/doc/contributions.txt @@ -492,6 +492,7 @@ Geenz Spad OPEN-339 BUG-226620 OPEN-340 + OPEN-343 Gene Frostbite GeneJ Composer Geneko Nemeth @@ -1327,6 +1328,7 @@ Sovereign Engineer STORM-2143 STORM-2148 MAINT-7343 + OPEN-343 SpacedOut Frye VWR-34 VWR-45 diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 4fe0d1351d..ca82dd9432 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -77,7 +77,7 @@ vec2 encode_normal (vec3 n); vec3 scaleSoftClipFrag(vec3 l); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten); -void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 atten, out vec3 additive); #ifdef HAS_SHADOW float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); @@ -184,7 +184,7 @@ void main() vec3 additive; vec3 atten; - calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); + calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); vec2 abnormal = encode_normal(norm.xyz); diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index d5ef010017..f98fc0d518 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -45,6 +45,9 @@ VARYING vec2 vary_texcoord0; vec4 applyWaterFogView(vec3 pos, vec4 color); #endif +vec3 fullbrightAtmosTransport(vec3 light); +vec3 fullbrightScaleSoftClip(vec3 light); + #ifdef HAS_ALPHA_MASK uniform float minimum_alpha; #endif @@ -74,6 +77,8 @@ void main() color.rgb = fogged.rgb; color.a = fogged.a; #else + color.rgb = fullbrightAtmosTransport(color.rgb); + color.rgb = fullbrightScaleSoftClip(color.rgb); color.a = final_alpha; #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 6d7162b5a2..9b07c11361 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -41,7 +41,7 @@ vec4 applyWaterFogView(vec3 pos, vec4 color); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); -void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); vec3 srgb_to_linear(vec3 cs); vec3 linear_to_srgb(vec3 cs); @@ -290,7 +290,7 @@ void main() vec3 additive; vec3 atten; - calcFragAtmospherics(pos.xyz, 1.0, sunlit, amblit, additive, atten); + calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index c599c14b43..b166f45bce 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -71,8 +71,6 @@ vec3 getNorm(vec2 pos_screen); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 fullbrightAtmosTransportFrag(vec3 l, vec3 additive, vec3 atten); -void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); - void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); vec3 scaleSoftClipFrag(vec3 l); @@ -168,7 +166,7 @@ vec3 post_diffuse = col.rgb; col = mix(col.rgb, refcol, envIntensity); } - if (norm.w < 0.5) + //if (norm.w < 0.5) { col = atmosFragLighting(col, additive, atten); col = scaleSoftClipFrag(col); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 2a772e6741..e1e299edee 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -67,7 +67,6 @@ uniform vec2 screen_res; vec3 getNorm(vec2 pos_screen); -void calcFragAtmospherics(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 fullbrightScaleSoftClipFrag(vec3 l, vec3 add, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); @@ -184,7 +183,7 @@ vec3 post_diffuse = col.rgb; col = mix(col.rgb, refcol, envIntensity); } - if (norm.w < 0.5) + //if (norm.w < 0.5) { //col = mix(atmosFragLighting(col, additive, atten), fullbrightAtmosTransportFrag(col, additive, atten), diffuse.a); //col = mix(scaleSoftClipFrag(col), fullbrightScaleSoftClipFrag(col, additive, atten), diffuse.a); From 3d0c05ba3aef00dfe8388e2081b3125bf252c1c0 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 10 Apr 2019 03:12:05 -0700 Subject: [PATCH 32/40] I don't think the class3 variant is used, but just in case. --HG-- branch : OPEN-340 --- .../class3/windlight/atmosphericsV.glsl | 110 +++--------------- 1 file changed, 13 insertions(+), 97 deletions(-) diff --git a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl index 9bd75cf118..b8c0547102 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/atmosphericsV.glsl @@ -32,104 +32,20 @@ void setPositionEye(vec3 v); vec3 getAdditiveColor(); -// Inputs -uniform vec4 morphFactor; -uniform vec3 camPosLocal; - -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; -uniform int sun_up_factor; -uniform vec4 ambient; -uniform vec4 blue_horizon; -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; +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); void calcAtmospherics(vec3 inPositionEye) { - vec3 P = inPositionEye; - setPositionEye(P); - - vec3 tmpLightnorm = lightnorm.xyz; - - vec3 Pn = normalize(P); - float Plen = length(P); - - vec4 temp1 = vec4(0); - vec3 temp2 = vec3(0); - vec4 blue_weight; - vec4 haze_weight; - vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; - vec4 light_atten; - - //sunlight attenuation effect (hue and brightness) due to atmosphere - //this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); - //I had thought blue_density and haze_density should have equal weighting, - //but attenuation due to haze_density tends to seem too strong - - temp1 = blue_density + vec4(haze_density); - blue_weight = blue_density / temp1; - haze_weight = vec4(haze_density) / temp1; - - //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) - temp2.y = max(0.0, tmpLightnorm.y); - temp2.y = 1. / temp2.y; - sunlight *= exp( - light_atten * temp2.y); - - // main atmospheric scattering line integral - temp2.z = Plen * density_multiplier; - - // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z * distance_multiplier); - - //final atmosphere attenuation factor - setAtmosAttenuation(temp1.rgb); - - //compute haze glow - //(can use temp2.x as temp because we haven't used it yet) - temp2.x = dot(Pn, tmpLightnorm.xyz); - temp2.x = 1. - temp2.x; - //temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .03); //was glow.y - //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.x *= glow.x; - //higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); - //glow.z should be negative, so we're doing a sort of (1 / "angle") function - - //add "minimum anti-solar illumination" - temp2.x += .25; - - //increase ambient when there are more clouds - vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; - - /* decrease value and saturation (that in HSV, not HSL) for occluded areas - * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html - * // The following line of code performs the equivalent of: - * float ambAlpha = tmpAmbient.a; - * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis - * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); - * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); - */ - //tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); - - //haze color - setAdditiveColor( - vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) - + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x - + tmpAmbient))); - - //brightness of surface both sunlight and ambient - setSunlitColor(vec3(sunlight * .5)); - setAmblitColor(vec3(tmpAmbient * .25)); - setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1)); + vec3 P = inPositionEye; + setPositionEye(P); + vec3 tmpsunlit = vec3(1); + vec3 tmpamblit = vec3(1); + vec3 tmpaddlit = vec3(1); + vec3 tmpattenlit = vec3(1); + calcAtmosphericVars(inPositionEye, 1, tmpsunlit, tmpamblit, tmpaddlit, tmpattenlit); + setSunlitColor(tmpsunlit); + setAmblitColor(tmpamblit); + setAdditiveColor(tmpaddlit); + setAtmosAttenuation(tmpattenlit); } + From de1a88d6bb17e767a9db8979ea2f7c0b3ba4cb41 Mon Sep 17 00:00:00 2001 From: Geenz Date: Wed, 10 Apr 2019 03:20:04 -0700 Subject: [PATCH 33/40] Revive the shading model that masks fog. --HG-- branch : OPEN-340 --- .../app_settings/shaders/class1/deferred/softenLightF.glsl | 2 +- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index b166f45bce..ff30004ffd 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -166,7 +166,7 @@ vec3 post_diffuse = col.rgb; col = mix(col.rgb, refcol, envIntensity); } - //if (norm.w < 0.5) + if (norm.w < 1) { col = atmosFragLighting(col, additive, atten); col = scaleSoftClipFrag(col); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index e1e299edee..d87b2560ce 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -183,7 +183,7 @@ vec3 post_diffuse = col.rgb; col = mix(col.rgb, refcol, envIntensity); } - //if (norm.w < 0.5) + if (norm.w < 1) { //col = mix(atmosFragLighting(col, additive, atten), fullbrightAtmosTransportFrag(col, additive, atten), diffuse.a); //col = mix(scaleSoftClipFrag(col), fullbrightScaleSoftClipFrag(col, additive, atten), diffuse.a); From b172ced57afd334db2aba19308e8793fd43ea5ec Mon Sep 17 00:00:00 2001 From: maxim_productengine Date: Wed, 10 Apr 2019 15:00:21 +0300 Subject: [PATCH 34/40] SL-10927 FIXED [EEP] Unable to share environment settings from My Environments floater --- indra/newview/llavataractions.cpp | 27 +++++++++++++++------------ indra/newview/llavataractions.h | 2 +- 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/indra/newview/llavataractions.cpp b/indra/newview/llavataractions.cpp index f0b74e7439..1797d2dd6e 100644 --- a/indra/newview/llavataractions.cpp +++ b/indra/newview/llavataractions.cpp @@ -626,10 +626,10 @@ namespace action_give_inventory * Checks My Inventory visibility. */ - static bool is_give_inventory_acceptable() + static bool is_give_inventory_acceptable(LLInventoryPanel* panel = NULL) { // check selection in the panel - const std::set inventory_selected_uuids = LLAvatarActions::getInventorySelectedUUIDs(); + const std::set inventory_selected_uuids = LLAvatarActions::getInventorySelectedUUIDs(panel); if (inventory_selected_uuids.empty()) return false; // nothing selected bool acceptable = false; @@ -694,7 +694,7 @@ namespace action_give_inventory uuid_vec_t mAvatarUuids; }; - static void give_inventory_cb(const LLSD& notification, const LLSD& response) + static void give_inventory_cb(const LLSD& notification, const LLSD& response, std::set inventory_selected_uuids) { S32 option = LLNotificationsUtil::getSelectedOption(notification, response); // if Cancel pressed @@ -703,7 +703,6 @@ namespace action_give_inventory return; } - const std::set inventory_selected_uuids = LLAvatarActions::getInventorySelectedUUIDs(); if (inventory_selected_uuids.empty()) { return; @@ -786,11 +785,11 @@ namespace action_give_inventory * @param avatar_names - avatar names request to be sent. * @param avatar_uuids - avatar names request to be sent. */ - static void give_inventory(const uuid_vec_t& avatar_uuids, const std::vector avatar_names) + static void give_inventory(const uuid_vec_t& avatar_uuids, const std::vector avatar_names, LLInventoryPanel* panel = NULL) { llassert(avatar_names.size() == avatar_uuids.size()); - const std::set inventory_selected_uuids = LLAvatarActions::getInventorySelectedUUIDs(); + const std::set inventory_selected_uuids = LLAvatarActions::getInventorySelectedUUIDs(panel); if (inventory_selected_uuids.empty()) { return; @@ -824,7 +823,7 @@ namespace action_give_inventory substitutions["ITEMS"] = items; LLShareInfo::instance().mAvatarNames = avatar_names; LLShareInfo::instance().mAvatarUuids = avatar_uuids; - LLNotificationsUtil::add(notification, substitutions, LLSD(), &give_inventory_cb); + LLNotificationsUtil::add(notification, substitutions, LLSD(), boost::bind(&give_inventory_cb, _1, _2, inventory_selected_uuids)); } } @@ -877,11 +876,14 @@ void LLAvatarActions::buildResidentsString(const uuid_vec_t& avatar_uuids, std:: } //static -std::set LLAvatarActions::getInventorySelectedUUIDs() +std::set LLAvatarActions::getInventorySelectedUUIDs(LLInventoryPanel* active_panel) { std::set inventory_selected; - LLInventoryPanel* active_panel = action_give_inventory::get_active_inventory_panel(); + if (!active_panel) + { + active_panel = action_give_inventory::get_active_inventory_panel(); + } if (active_panel) { inventory_selected= active_panel->getRootFolder()->getSelectionList(); @@ -911,15 +913,16 @@ void LLAvatarActions::shareWithAvatars(LLView * panel) { using namespace action_give_inventory; - LLFloater* root_floater = gFloaterView->getParentFloater(panel); + LLFloater* root_floater = gFloaterView->getParentFloater(panel); + LLInventoryPanel* inv_panel = dynamic_cast(panel); LLFloaterAvatarPicker* picker = - LLFloaterAvatarPicker::show(boost::bind(give_inventory, _1, _2), TRUE, FALSE, FALSE, root_floater->getName()); + LLFloaterAvatarPicker::show(boost::bind(give_inventory, _1, _2, inv_panel), TRUE, FALSE, FALSE, root_floater->getName()); if (!picker) { return; } - picker->setOkBtnEnableCb(boost::bind(is_give_inventory_acceptable)); + picker->setOkBtnEnableCb(boost::bind(is_give_inventory_acceptable, inv_panel)); picker->openFriendsTab(); if (root_floater) diff --git a/indra/newview/llavataractions.h b/indra/newview/llavataractions.h index b56d5b0fb9..7c721076c8 100644 --- a/indra/newview/llavataractions.h +++ b/indra/newview/llavataractions.h @@ -244,7 +244,7 @@ public: */ static void viewChatHistory(const LLUUID& id); - static std::set getInventorySelectedUUIDs(); + static std::set getInventorySelectedUUIDs(LLInventoryPanel* active_panel = NULL); private: static bool callbackAddFriendWithMessage(const LLSD& notification, const LLSD& response); From 2c568e7584ed4a5c000b2064a4d06f4b2347a34a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 10 Apr 2019 10:11:50 -0700 Subject: [PATCH 35/40] SL-10925, SL-10926, SL-10896 New fix for 925/926 that doesn't cause 896 again. Also linearize moon disc tex color. --- .../shaders/class1/deferred/moonF.glsl | 4 ++++ indra/newview/llsettingsvo.cpp | 24 ++++++++++++++++++- indra/newview/llviewershadermgr.cpp | 1 + 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 7732cf986e..aae6158673 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -44,6 +44,8 @@ uniform sampler2D altDiffuseMap; uniform float blend_factor; // interp factor between moon A/B VARYING vec2 vary_texcoord0; +vec3 srgb_to_linear(vec3 c); + void main() { vec4 moonA = texture2D(diffuseMap, vary_texcoord0.xy); @@ -58,6 +60,8 @@ void main() vec3 exp = vec3(1.0 - mix * moon_brightness) * 2.0 - 1.0; c.rgb = pow(c.rgb, exp); + c.rgb = srgb_to_linear(c.rgb); + //c.rgb *= moonlight_color.rgb; frag_data[0] = vec4(c.rgb, c.a); diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index eb92c11952..628666c3ed 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -685,6 +685,28 @@ void LLSettingsVOSky::applySpecial(void *ptarget) LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); vect_c_p_d1 += LLVector4(LLEnvironment::instance().getCloudScrollDelta()); shader->uniform4fv(LLShaderMgr::CLOUD_POS_DENSITY1, 1, vect_c_p_d1.mV); + + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLColor4 sunDiffuse = psky->getSunDiffuse(); + LLColor4 moonDiffuse = psky->getMoonDiffuse(); + + F32 max_color = llmax(sunDiffuse.mV[0], sunDiffuse.mV[1], sunDiffuse.mV[2]); + if (max_color > 1.f) + { + sunDiffuse *= 1.f/max_color; + } + sunDiffuse.clamp(); + + max_color = llmax(moonDiffuse.mV[0], moonDiffuse.mV[1], moonDiffuse.mV[2]); + if (max_color > 1.f) + { + moonDiffuse *= 1.f/max_color; + } + moonDiffuse.clamp(); + + shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sunDiffuse.mV); + shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, moonDiffuse.mV); } F32 g = getGamma(); @@ -721,7 +743,7 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); - param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + //param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index c6d727430c..cf0cd693ae 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -2522,6 +2522,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLMoonProgram.mFeatures.hasTransport = true; gDeferredWLMoonProgram.mFeatures.hasGamma = true; gDeferredWLMoonProgram.mFeatures.hasAtmospherics = true; + gDeferredWLMoonProgram.mFeatures.hasSrgb = true; gDeferredWLMoonProgram.mFeatures.isFullbright = true; gDeferredWLMoonProgram.mFeatures.disableTextureIndex = true; From 0b8ff3a8b22ccfdff320acba127ad631823b5644 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 10 Apr 2019 10:55:30 -0700 Subject: [PATCH 36/40] Fix missing sentinel in shader file to avoid spurious complaints for hg policy hooks. --- .../class1/windlight/atmosphericsFuncs.glsl | 26 ++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index a099083883..845c45cc07 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -1,3 +1,27 @@ +/** + * @file class1\windlight\atmosphericsFuncs.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2019, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ uniform vec4 gamma; uniform vec4 lightnorm; uniform vec4 sunlight_color; @@ -113,4 +137,4 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o amblit = tmpAmbient.rgb * .25; additive = normalize(additive); additive *= vec3(1.0 - exp(-temp2.z * distance_multiplier)) * 0.5; -} \ No newline at end of file +} From 27184c74b4b8085e362c6e21d5d1071889476fe9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 10 Apr 2019 13:43:58 -0700 Subject: [PATCH 37/40] SL-10901 Fix up shadow sampling and tweak shadow biasing. Clean up shader decls of unused funcs. Clean up whitespace diffs from release. --- .../shaders/class1/deferred/alphaF.glsl | 17 +++++++++++------ .../shaders/class1/deferred/materialF.glsl | 15 +++++++-------- .../shaders/class1/deferred/shadowUtil.glsl | 4 ++-- .../shaders/class1/deferred/softenLightF.glsl | 4 ++-- .../shaders/class2/deferred/softenLightF.glsl | 9 ++------- indra/newview/llviewershadermgr.cpp | 2 +- 6 files changed, 25 insertions(+), 26 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ca82dd9432..ab7f779a39 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -83,7 +83,7 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen); #endif -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance ,float shadow) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, float ambiance) { //get light vector vec3 lv = lp.xyz-v; @@ -115,15 +115,19 @@ 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); - col = lit * light_col * diffuse * shadow; + col = lit * light_col * diffuse; float amb_da = ambiance; - amb_da += (da*0.5+0.5) * (1.0 - shadow) * ambiance; - amb_da += (da*da*0.5 + 0.5) * (1.0 - shadow) * ambiance; + if (da > 0) + { + amb_da += (da*0.5+0.5) * ambiance; + } + amb_da += (da*da*0.5 + 0.5) * ambiance; amb_da *= dist_atten; amb_da = min(amb_da, 1.0f - lit); col.rgb += amb_da * 0.5 * light_col * diffuse; + // no spec for alpha shader... } col = max(col, vec3(0)); @@ -185,6 +189,7 @@ void main() vec3 atten; calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); + sunlit *= 0.5; vec2 abnormal = encode_normal(norm.xyz); @@ -228,9 +233,9 @@ vec3 post_diffuse = color.rgb; vec4 light = vec4(0,0,0,0); -vec3 prelight_linearish_maybe = color.rgb; +vec3 prelight_linearish_maybe = srgb_to_linear(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 * 0.5, 1.0); + #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 * 0.5); LIGHT_LOOP(1) LIGHT_LOOP(2) diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 9b07c11361..d14e67fc73 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -83,7 +83,7 @@ uniform vec3 light_direction[8]; uniform vec4 light_attenuation[8]; uniform vec3 light_diffuse[8]; -vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance, float shadow) +vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spec, vec3 v, vec3 n, vec4 lp, vec3 ln, float la, float fa, float is_pointlight, inout float glare, float ambiance) { //get light vector vec3 lv = lp.xyz-v; @@ -109,17 +109,16 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); - da *= spot*spot; // GL_SPOT_EXPONENT=2 //angular attenuation da = dot(n, lv); da = clamp(da, 0.0, 1.0); + da *= spot*spot; // GL_SPOT_EXPONENT=2 + 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; float amb_da = ambiance; if (da > 0) @@ -148,7 +147,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = lit*scol*light_col.rgb*spec.rgb; - speccol = max(speccol, vec3(0)); + speccol = clamp(speccol, vec3(0), vec3(1)); col += speccol; float cur_glare = max(speccol.r, speccol.g); @@ -372,9 +371,9 @@ vec3 post_spec = col.rgb; vec3 light = vec3(0,0,0); - vec3 prelight_linearish_maybe = col.rgb; + vec3 prelight_linearish_maybe = srgb_to_linear(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, 1.0); + #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); LIGHT_LOOP(1) LIGHT_LOOP(2) diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index 642aff6c41..0a714f0013 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -49,7 +49,7 @@ uniform int sun_up_factor; float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, vec2 pos_screen, vec3 light_dir) { stc.xyz /= stc.w; - stc.z += shadow_bias * bias_mul * 2.0; + stc.z += shadow_bias * bias_mul * 16.0; stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here float cs = shadow2D(shadowMap, stc.xyz).x; float shadow = cs * 4.0; @@ -57,7 +57,7 @@ float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, shadow += shadow2D(shadowMap, stc.xyz+vec3(1.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(-1.0/shadow_res.x, 1.5/shadow_res.y, 0.0)).x; shadow += shadow2D(shadowMap, stc.xyz+vec3(-2.0/shadow_res.x, -1.5/shadow_res.y, 0.0)).x; - return shadow * 0.125; + return clamp(shadow * 0.125, 0.0, 1.0); } float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float bias_scale, vec2 pos_screen) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index ff30004ffd..476a1216d3 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -151,8 +151,8 @@ vec3 post_diffuse = col.rgb; { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = sun_contrib*scol*spec.rgb; - speccol = max(speccol, vec3(0)); - bloom = dot (speccol, speccol) / 2; + speccol = clamp(speccol, vec3(0), vec3(1)); + bloom = dot(speccol, speccol) / 2; col += speccol; } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index d87b2560ce..6bebb79f31 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -68,7 +68,6 @@ uniform vec2 screen_res; vec3 getNorm(vec2 pos_screen); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); -vec3 fullbrightScaleSoftClipFrag(vec3 l, vec3 add, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); @@ -80,8 +79,6 @@ vec3 fullbrightShinyAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten); vec4 getPositionWithDepth(vec2 pos_screen, float depth); vec4 getPosition(vec2 pos_screen); -vec3 nothing(); - #ifdef WATER_FOG vec4 applyWaterFogView(vec3 pos, vec4 color); #endif @@ -132,7 +129,7 @@ void main() ambient = max(0.66, ambient); ambient = 1.0 - ambient; - vec3 sun_contrib = min(scol, final_da) * sunlit; + vec3 sun_contrib = scol * final_da * sunlit; col.rgb = amblit; col.rgb *= ambient; @@ -168,7 +165,7 @@ vec3 post_diffuse = col.rgb; { float scontrib = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = sun_contrib*scontrib*spec.rgb; - speccol = max(speccol, vec3(0)); + speccol = clamp(speccol, vec3(0), vec3(1)); bloom += dot (speccol, speccol) / 2; col += speccol; } @@ -185,8 +182,6 @@ vec3 post_diffuse = col.rgb; if (norm.w < 1) { - //col = mix(atmosFragLighting(col, additive, atten), fullbrightAtmosTransportFrag(col, additive, atten), diffuse.a); - //col = mix(scaleSoftClipFrag(col), fullbrightScaleSoftClipFrag(col, additive, atten), diffuse.a); col = atmosFragLighting(col, additive, atten); col = scaleSoftClipFrag(col); } diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 1b1759aeaf..ebfdc38d50 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1009,7 +1009,7 @@ BOOL LLViewerShaderMgr::loadBasicShaders() index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightWaterAlphaMaskF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); - index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); + index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightShinyWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); index_channels.push_back(ch); shaders.push_back( make_pair( "lighting/lightFullbrightShinyWaterF.glsl", mShaderLevel[SHADER_LIGHTING] ) ); From 37a7c96f1724332ccddde36bf5095b99af95fe8f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 15 Apr 2019 09:41:12 -0700 Subject: [PATCH 38/40] Fix line-endings on new shader file from contribution. --- .../class1/windlight/atmosphericsFuncs.glsl | 280 +++++++++--------- 1 file changed, 140 insertions(+), 140 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index 845c45cc07..91760e05bf 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -1,140 +1,140 @@ -/** - * @file class1\windlight\atmosphericsFuncs.glsl - * - * $LicenseInfo:firstyear=2005&license=viewerlgpl$ - * Second Life Viewer Source Code - * Copyright (C) 2019, Linden Research, Inc. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; - * version 2.1 of the License only. - * - * This library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - * - * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA - * $/LicenseInfo$ - */ -uniform vec4 gamma; -uniform vec4 lightnorm; -uniform vec4 sunlight_color; -uniform vec4 moonlight_color; -uniform int sun_up_factor; -uniform vec4 ambient; -uniform vec4 blue_horizon; -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; -uniform mat3 ssao_effect_mat; -uniform int no_atmo; -uniform float sun_moon_glow_factor; - -vec3 nothing() { - return vec3(0, 0, 0); -} - -void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten) { - - vec3 P = inPositionEye; - - //(TERRAIN) limit altitude - if (P.y > max_y) P *= (max_y / P.y); - if (P.y < -max_y) P *= (-max_y / P.y); - - vec3 tmpLightnorm = lightnorm.xyz; - - vec3 Pn = normalize(P); - float Plen = length(P); - - vec4 temp1 = vec4(0); - vec3 temp2 = vec3(0); - vec4 blue_weight; - vec4 haze_weight; - vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; - vec4 light_atten; - - //sunlight attenuation effect (hue and brightness) due to atmosphere - //this is used later for sunlight modulation at various altitudes - light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); - //I had thought blue_density and haze_density should have equal weighting, - //but attenuation due to haze_density tends to seem too strong - - temp1 = blue_density + vec4(haze_density); - blue_weight = blue_density / temp1; - haze_weight = vec4(haze_density) / temp1; - - //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) - temp2.y = max(0.0, tmpLightnorm.y); - if (temp2.y > 0.001f) - { - temp2.y = 1. / temp2.y; - } - temp2.y = max(0.001f, temp2.y); - sunlight *= exp(-light_atten * temp2.y); - - // main atmospheric scattering line integral - temp2.z = Plen * density_multiplier; - - // Transparency (-> temp1) - // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati - // compiler gets confused. - temp1 = exp(-temp1 * temp2.z * distance_multiplier); - - //final atmosphere attenuation factor - atten = temp1.rgb; - - //compute haze glow - //(can use temp2.x as temp because we haven't used it yet) - temp2.x = dot(Pn, tmpLightnorm.xyz); - temp2.x = 1. - temp2.x; - //temp2.x is 0 at the sun and increases away from sun - temp2.x = max(temp2.x, .001); //was glow.y - //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) - temp2.x *= glow.x; - //higher glow.x gives dimmer glow (because next step is 1 / "angle") - temp2.x = pow(temp2.x, glow.z); - //glow.z should be negative, so we're doing a sort of (1 / "angle") function - - //add "minimum anti-solar illumination" - temp2.x += .25; - - temp2.x *= sun_moon_glow_factor; - - //increase ambient when there are more clouds - vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; - - /* decrease value and saturation (that in HSV, not HSL) for occluded areas - * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html - * // The following line of code performs the equivalent of: - * float ambAlpha = tmpAmbient.a; - * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis - * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); - * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); - */ - tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); - - //haze color - additive = - vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) - + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x - + tmpAmbient)); - - //brightness of surface both sunlight and ambient - sunlit = sunlight.rgb; - amblit = tmpAmbient.rgb * .25; - additive = normalize(additive); - additive *= vec3(1.0 - exp(-temp2.z * distance_multiplier)) * 0.5; -} +/** + * @file class1\windlight\atmosphericsFuncs.glsl + * + * $LicenseInfo:firstyear=2005&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2019, Linden Research, Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA + * $/LicenseInfo$ + */ +uniform vec4 gamma; +uniform vec4 lightnorm; +uniform vec4 sunlight_color; +uniform vec4 moonlight_color; +uniform int sun_up_factor; +uniform vec4 ambient; +uniform vec4 blue_horizon; +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; +uniform mat3 ssao_effect_mat; +uniform int no_atmo; +uniform float sun_moon_glow_factor; + +vec3 nothing() { + return vec3(0, 0, 0); +} + +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten) { + + vec3 P = inPositionEye; + + //(TERRAIN) limit altitude + if (P.y > max_y) P *= (max_y / P.y); + if (P.y < -max_y) P *= (-max_y / P.y); + + vec3 tmpLightnorm = lightnorm.xyz; + + vec3 Pn = normalize(P); + float Plen = length(P); + + vec4 temp1 = vec4(0); + vec3 temp2 = vec3(0); + vec4 blue_weight; + vec4 haze_weight; + vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; + vec4 light_atten; + + //sunlight attenuation effect (hue and brightness) due to atmosphere + //this is used later for sunlight modulation at various altitudes + light_atten = (blue_density + vec4(haze_density * 0.25)) * (density_multiplier * max_y); + //I had thought blue_density and haze_density should have equal weighting, + //but attenuation due to haze_density tends to seem too strong + + temp1 = blue_density + vec4(haze_density); + blue_weight = blue_density / temp1; + haze_weight = vec4(haze_density) / temp1; + + //(TERRAIN) compute sunlight from lightnorm only (for short rays like terrain) + temp2.y = max(0.0, tmpLightnorm.y); + if (temp2.y > 0.001f) + { + temp2.y = 1. / temp2.y; + } + temp2.y = max(0.001f, temp2.y); + sunlight *= exp(-light_atten * temp2.y); + + // main atmospheric scattering line integral + temp2.z = Plen * density_multiplier; + + // Transparency (-> temp1) + // ATI Bugfix -- can't store temp1*temp2.z*distance_multiplier in a variable because the ati + // compiler gets confused. + temp1 = exp(-temp1 * temp2.z * distance_multiplier); + + //final atmosphere attenuation factor + atten = temp1.rgb; + + //compute haze glow + //(can use temp2.x as temp because we haven't used it yet) + temp2.x = dot(Pn, tmpLightnorm.xyz); + temp2.x = 1. - temp2.x; + //temp2.x is 0 at the sun and increases away from sun + temp2.x = max(temp2.x, .001); //was glow.y + //set a minimum "angle" (smaller glow.y allows tighter, brighter hotspot) + temp2.x *= glow.x; + //higher glow.x gives dimmer glow (because next step is 1 / "angle") + temp2.x = pow(temp2.x, glow.z); + //glow.z should be negative, so we're doing a sort of (1 / "angle") function + + //add "minimum anti-solar illumination" + temp2.x += .25; + + temp2.x *= sun_moon_glow_factor; + + //increase ambient when there are more clouds + vec4 tmpAmbient = ambient + (vec4(1.) - ambient) * cloud_shadow * 0.5; + + /* decrease value and saturation (that in HSV, not HSL) for occluded areas + * // for HSV color/geometry used here, see http://gimp-savvy.com/BOOK/index.html?node52.html + * // The following line of code performs the equivalent of: + * float ambAlpha = tmpAmbient.a; + * float ambValue = dot(vec3(tmpAmbient), vec3(0.577)); // projection onto <1/rt(3), 1/rt(3), 1/rt(3)>, the neutral white-black axis + * vec3 ambHueSat = vec3(tmpAmbient) - vec3(ambValue); + * tmpAmbient = vec4(RenderSSAOEffect.valueFactor * vec3(ambValue) + RenderSSAOEffect.saturationFactor *(1.0 - ambFactor) * ambHueSat, ambAlpha); + */ + tmpAmbient = vec4(mix(ssao_effect_mat * tmpAmbient.rgb, tmpAmbient.rgb, ambFactor), tmpAmbient.a); + + //haze color + additive = + vec3(blue_horizon * blue_weight * (sunlight*(1.-cloud_shadow) + tmpAmbient) + + (haze_horizon * haze_weight) * (sunlight*(1.-cloud_shadow) * temp2.x + + tmpAmbient)); + + //brightness of surface both sunlight and ambient + sunlit = sunlight.rgb; + amblit = tmpAmbient.rgb * .25; + additive = normalize(additive); + additive *= vec3(1.0 - exp(-temp2.z * distance_multiplier)) * 0.5; +} From 508ca2d458b6ae23909c88615498b629da0ca76e Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 15 Apr 2019 11:52:24 -0700 Subject: [PATCH 39/40] SL-10959 Scale down of bloom was off by a factor of 3 or so. --- .../app_settings/shaders/class1/deferred/softenLightF.glsl | 2 +- .../app_settings/shaders/class2/deferred/softenLightF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 476a1216d3..71fbe5df57 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -152,7 +152,7 @@ vec3 post_diffuse = col.rgb; float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = sun_contrib*scol*spec.rgb; speccol = clamp(speccol, vec3(0), vec3(1)); - bloom = dot(speccol, speccol) / 2; + bloom = dot(speccol, speccol) / 6; col += speccol; } } diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 6bebb79f31..737fb0fef7 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -166,7 +166,7 @@ vec3 post_diffuse = col.rgb; float scontrib = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); vec3 speccol = sun_contrib*scontrib*spec.rgb; speccol = clamp(speccol, vec3(0), vec3(1)); - bloom += dot (speccol, speccol) / 2; + bloom += dot (speccol, speccol) / 6; col += speccol; } } From 479385c97fa2d433c85598f6871274c970a6f9a7 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 15 Apr 2019 16:31:01 -0700 Subject: [PATCH 40/40] SL-10968 Tweak forced frag depths for sun/moon disc images to resolve depth fighting with hills etc. --- indra/newview/app_settings/shaders/class1/deferred/moonF.glsl | 2 +- .../newview/app_settings/shaders/class1/deferred/sunDiscF.glsl | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index aae6158673..cc1636d89d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -68,6 +68,6 @@ void main() frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0f); - gl_FragDepth = 0.99985f; + gl_FragDepth = 0.999985f; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl index d06cb43129..e240c130c6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl @@ -59,6 +59,6 @@ void main() frag_data[1] = vec4(0.0f); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); - gl_FragDepth = 0.99988f; + gl_FragDepth = 0.999988f; }