From 7da3a1eb4f14b67c698977eb1947ce06a312d507 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 6 Aug 2018 17:49:50 +0100 Subject: WIP check-in to allow merge of upstream changes. --- indra/llinventory/llsettingssky.cpp | 88 +++++--- indra/llinventory/llsettingssky.h | 24 ++- indra/newview/CMakeLists.txt | 2 + indra/newview/lldensityctrl.cpp | 225 +++++++++++++++++++++ indra/newview/lldensityctrl.h | 104 ++++++++++ indra/newview/llfloatereditextdaycycle.cpp | 11 + indra/newview/llpaneleditsky.cpp | 94 ++++++++- indra/newview/llpaneleditsky.h | 43 +++- .../default/xui/en/floater_edit_ext_day_cycle.xml | 9 + .../default/xui/en/panel_settings_sky_density.xml | 32 +++ .../skins/default/xui/en/widgets/density_ctrl.xml | 164 +++++++++++++++ 11 files changed, 759 insertions(+), 37 deletions(-) create mode 100644 indra/newview/lldensityctrl.cpp create mode 100644 indra/newview/lldensityctrl.h create mode 100644 indra/newview/skins/default/xui/en/panel_settings_sky_density.xml create mode 100644 indra/newview/skins/default/xui/en/widgets/density_ctrl.xml diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 4451bd753b..a7f9aa7842 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -554,36 +554,53 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList() return validation; } +LLSD LLSettingsSky::createDensityProfileLayer( + F32 width, + F32 exponential_term, + F32 exponential_scale_factor, + F32 linear_term, + F32 constant_term, + F32 aniso_factor) +{ + LLSD dflt_layer; + dflt_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere + dflt_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f; + dflt_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 8000.0f; + dflt_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f; + dflt_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f; + + if (aniso_factor != 0.0f) + { + dflt_layer[SETTING_MIE_ANISOTROPY_FACTOR] = aniso_factor; + } + + return dflt_layer; +} + +LLSD LLSettingsSky::createSingleLayerDensityProfile( + F32 width, + F32 exponential_term, + F32 exponential_scale_factor, + F32 linear_term, + F32 constant_term, + F32 aniso_factor) +{ + LLSD dflt; + LLSD dflt_layer = createDensityProfileLayer(width, exponential_term, exponential_scale_factor, linear_term, constant_term, aniso_factor); + dflt.append(dflt_layer); + return dflt; +} + LLSD LLSettingsSky::rayleighConfigDefault() { - LLSD dflt_rayleigh; - LLSD dflt_rayleigh_layer; - dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere - dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f; - dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 8000.0f; - dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f; - dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f; - dflt_rayleigh.append(dflt_rayleigh_layer); - return dflt_rayleigh; + return createSingleLayerDensityProfile(0.0f, 1.0f, -1.0f / 8000.0f, 0.0f, 0.0f); } LLSD LLSettingsSky::absorptionConfigDefault() { // absorption (ozone) has two linear ramping zones - LLSD dflt_absorption_layer_a; - dflt_absorption_layer_a[SETTING_DENSITY_PROFILE_WIDTH] = 25000.0f; // 0 -> the entire atmosphere - dflt_absorption_layer_a[SETTING_DENSITY_PROFILE_EXP_TERM] = 0.0f; - dflt_absorption_layer_a[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = 0.0f; - dflt_absorption_layer_a[SETTING_DENSITY_PROFILE_LINEAR_TERM] = -1.0f / 25000.0f; - dflt_absorption_layer_a[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = -2.0f / 3.0f; - - LLSD dflt_absorption_layer_b; - dflt_absorption_layer_b[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> remainder of the atmosphere - dflt_absorption_layer_b[SETTING_DENSITY_PROFILE_EXP_TERM] = 0.0f; - dflt_absorption_layer_b[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = 0.0f; - dflt_absorption_layer_b[SETTING_DENSITY_PROFILE_LINEAR_TERM] = -1.0f / 15000.0f; - dflt_absorption_layer_b[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 8.0f / 3.0f; - + LLSD dflt_absorption_layer_a = createDensityProfileLayer(25000.0f, 0.0f, 0.0f, -1.0f / 25000.0f, -2.0f / 3.0f); + LLSD dflt_absorption_layer_b = createDensityProfileLayer(0.0f, 0.0f, 0.0f, -1.0f / 15000.0f, 8.0f / 3.0f); LLSD dflt_absorption; dflt_absorption.append(dflt_absorption_layer_a); dflt_absorption.append(dflt_absorption_layer_b); @@ -592,15 +609,7 @@ LLSD LLSettingsSky::absorptionConfigDefault() LLSD LLSettingsSky::mieConfigDefault() { - LLSD dflt_mie; - LLSD dflt_mie_layer; - dflt_mie_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere - dflt_mie_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f; - dflt_mie_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 1200.0f; - dflt_mie_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f; - dflt_mie_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f; - dflt_mie_layer[SETTING_MIE_ANISOTROPY_FACTOR] = 0.8f; - dflt_mie.append(dflt_mie_layer); + LLSD dflt_mie = createSingleLayerDensityProfile(0.0f, 1.0f, -1.0f / 1200.0f, 0.0f, 0.0f, 0.8f); return dflt_mie; } @@ -1154,6 +1163,21 @@ LLSD LLSettingsSky::getAbsorptionConfigs() const return mSettings[SETTING_ABSORPTION_CONFIG]; } +void LLSettingsSky::setRayleighConfigs(const LLSD& rayleighConfig) +{ + mSettings[SETTING_RAYLEIGH_CONFIG] = rayleighConfig; +} + +void LLSettingsSky::setMieConfigs(const LLSD& mieConfig) +{ + mSettings[SETTING_MIE_CONFIG] = mieConfig; +} + +void LLSettingsSky::setAbsorptionConfigs(const LLSD& absorptionConfig) +{ + mSettings[SETTING_ABSORPTION_CONFIG] = absorptionConfig; +} + LLUUID LLSettingsSky::getBloomTextureId() const { return mSettings[SETTING_BLOOM_TEXTUREID].asUUID(); diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 19a5656644..36d1053cf6 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -72,7 +72,6 @@ public: static const std::string SETTING_SKY_BOTTOM_RADIUS; static const std::string SETTING_SKY_TOP_RADIUS; static const std::string SETTING_SUN_ARC_RADIANS; - static const std::string SETTING_MIE_ANISOTROPY_FACTOR; static const std::string SETTING_RAYLEIGH_CONFIG; static const std::string SETTING_MIE_CONFIG; @@ -84,7 +83,7 @@ public: static const std::string SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR; static const std::string SETTING_DENSITY_PROFILE_LINEAR_TERM; static const std::string SETTING_DENSITY_PROFILE_CONSTANT_TERM; - + static const std::string SETTING_MIE_ANISOTROPY_FACTOR; static const std::string SETTING_LEGACY_HAZE; @@ -116,10 +115,13 @@ public: F32 getMieAnisotropy() const; LLSD getRayleighConfigs() const; LLSD getMieConfigs() const; - LLSD getAbsorptionConfigs() const; LLUUID getBloomTextureId() const; + void setRayleighConfigs(const LLSD& rayleighConfig); + void setMieConfigs(const LLSD& mieConfig); + void setAbsorptionConfigs(const LLSD& absorptionConfig); + //--------------------------------------------------------------------- LLColor3 getAmbientColor() const; void setAmbientColor(const LLColor3 &val); @@ -239,6 +241,22 @@ public: static LLUUID GetDefaultCloudNoiseTextureId(); static LLUUID GetDefaultBloomTextureId(); + static LLSD createDensityProfileLayer( + F32 width, + F32 exponential_term, + F32 exponential_scale_factor, + F32 linear_term, + F32 constant_term, + F32 aniso_factor = 0.0f); + + static LLSD createSingleLayerDensityProfile( + F32 width, + F32 exponential_term, + F32 exponential_scale_factor, + F32 linear_term, + F32 constant_term, + F32 aniso_factor = 0.0f); + protected: static const std::string SETTING_LEGACY_EAST_ANGLE; static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index 5dd0c15a5f..bdc9ce57da 100644 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -163,6 +163,7 @@ set(viewer_SOURCE_FILES lldebugview.cpp lldeferredsounds.cpp lldelayedgestureerror.cpp + lldensityctrl.cpp lldirpicker.cpp lldonotdisturbnotificationstorage.cpp lldndbutton.cpp @@ -783,6 +784,7 @@ set(viewer_HEADER_FILES lldebugview.h lldeferredsounds.h lldelayedgestureerror.h + lldensityctrl.h lldirpicker.h lldonotdisturbnotificationstorage.h lldndbutton.h diff --git a/indra/newview/lldensityctrl.cpp b/indra/newview/lldensityctrl.cpp new file mode 100644 index 0000000000..298a309e7c --- /dev/null +++ b/indra/newview/lldensityctrl.cpp @@ -0,0 +1,225 @@ +/** +* @file lldensityctrl.cpp +* @brief Control for specifying density over a height range for sky settings. +* +* $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 "lldensityctrl.h" + +#include "llslider.h" +#include "llsliderctrl.h" +#include "llsettingssky.h" + +static LLDefaultChildRegistry::Register register_density_control("densityctrl"); + +const std::string LLDensityCtrl::DENSITY_RAYLEIGH("density_rayleigh"); +const std::string LLDensityCtrl::DENSITY_MIE("density_mie"); +const std::string LLDensityCtrl::DENSITY_ABSORPTION("density_absorption"); + +namespace +{ + const std::string FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL("level_exponential"); + const std::string FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL_SCALE("exponential_scale"); + const std::string FIELD_SKY_DENSITY_PROFILE_LINEAR("level_linear"); + const std::string FIELD_SKY_DENSITY_PROFILE_CONSTANT("level_constant"); + const std::string FIELD_SKY_DENSITY_MAX_ALTITUDE("max_altitude"); + const std::string FIELD_SKY_DENSITY_ANISO_FACTOR("aniso_factor"); + const std::string FIELD_SKY_DENSITY_ANISO_FACTOR_LABEL("aniso_factor_label"); +} + +const std::string& LLDensityCtrl::NameForDensityProfileType(DensityProfileType t) +{ + switch (t) + { + case Rayleigh: return DENSITY_RAYLEIGH; + case Mie: return DENSITY_MIE; + case Absorption: return DENSITY_ABSORPTION; + default: + break; + } + + llassert(false); + return DENSITY_RAYLEIGH; +} + +LLDensityCtrl::Params::Params() +: image_density_feedback("image_density_feedback") +, lbl_exponential("label_exponential") +, lbl_exponential_scale("label_exponential_scale") +, lbl_linear("label_linear") +, lbl_constant("label_constant") +, lbl_max_altitude("label_max_altitude") +, lbl_aniso_factor("label_aniso_factor") +, profile_type(LLDensityCtrl::Rayleigh) +{ +} + +LLDensityCtrl::LLDensityCtrl(const Params& params) +: mProfileType(params.profile_type) +, mImgDensityFeedback(params.image_density_feedback) +{ + +} + +LLSD LLDensityCtrl::getProfileConfig() +{ + LLSD config; + switch (mProfileType) + { + case Rayleigh: return mSkySettings->getRayleighConfigs(); + case Mie: return mSkySettings->getMieConfigs(); + case Absorption: return mSkySettings->getAbsorptionConfigs(); + default: + break; + } + llassert(false); + return config; +} + +BOOL LLDensityCtrl::postBuild() +{ + getChild(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onExponentialChanged(); }); + getChild(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onExponentialScaleFactorChanged(); }); + getChild(FIELD_SKY_DENSITY_PROFILE_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onLinearChanged(); }); + getChild(FIELD_SKY_DENSITY_PROFILE_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onConstantChanged(); }); + getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMaxAltitudeChanged(); }); + getChild(FIELD_SKY_DENSITY_ANISO_FACTOR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAnisoFactorChanged(); }); + + if (mProfileType != Mie) + { + getChild(FIELD_SKY_DENSITY_ANISO_FACTOR_LABEL)->setValue(false); + getChild(FIELD_SKY_DENSITY_ANISO_FACTOR)->setVisible(false); + } + + return TRUE; +} + +void LLDensityCtrl::setEnabled(BOOL enabled) +{ + getChild(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL)->setEnabled(enabled); + getChild(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL_SCALE)->setEnabled(enabled); + getChild(FIELD_SKY_DENSITY_PROFILE_LINEAR)->setEnabled(enabled); + getChild(FIELD_SKY_DENSITY_PROFILE_CONSTANT)->setEnabled(enabled); + getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setEnabled(enabled); + + if (mProfileType == Mie) + { + getChild(FIELD_SKY_DENSITY_ANISO_FACTOR)->setEnabled(enabled); + } +} + +void LLDensityCtrl::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + LLSD config = getProfileConfig(); + + getChild(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL)->setValue(config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM]); + getChild(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL_SCALE)->setValue(config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR]); + getChild(FIELD_SKY_DENSITY_PROFILE_LINEAR)->setValue(config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM]); + getChild(FIELD_SKY_DENSITY_PROFILE_CONSTANT)->setValue(config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM]); + getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setValue(config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH]); + + if (mProfileType == Mie) + { + getChild(FIELD_SKY_DENSITY_ANISO_FACTOR)->setValue(config[LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR]); + } +} + +void LLDensityCtrl::updateProfile() +{ + F32 exponential_term = getChild(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL)->getValueF32(); + F32 exponential_scale = getChild(FIELD_SKY_DENSITY_PROFILE_EXPONENTIAL_SCALE)->getValueF32(); + F32 linear_term = getChild(FIELD_SKY_DENSITY_PROFILE_LINEAR)->getValueF32(); + F32 constant_term = getChild(FIELD_SKY_DENSITY_PROFILE_CONSTANT)->getValueF32(); + F32 max_alt = getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->getValueF32(); + F32 aniso_factor = 0.0f; + + if (mProfileType == Mie) + { + aniso_factor = getChild(FIELD_SKY_DENSITY_ANISO_FACTOR)->getValueF32(); + } + + LLSD profile = LLSettingsSky::createSingleLayerDensityProfile(max_alt, exponential_term, exponential_scale, linear_term, constant_term, aniso_factor); + + switch (mProfileType) + { + case Rayleigh: mSkySettings->setRayleighConfigs(profile); break; + case Mie: mSkySettings->setMieConfigs(profile); break; + case Absorption: mSkySettings->setAbsorptionConfigs(profile); break; + default: + break; + } +} + +void LLDensityCtrl::onExponentialChanged() +{ + updateProfile(); + updatePreview(); +} + +void LLDensityCtrl::onExponentialScaleFactorChanged() +{ + updateProfile(); + updatePreview(); +} + +void LLDensityCtrl::onLinearChanged() +{ + updateProfile(); + updatePreview(); +} + +void LLDensityCtrl::onConstantChanged() +{ + updateProfile(); + updatePreview(); +} + +void LLDensityCtrl::onMaxAltitudeChanged() +{ + updateProfile(); + updatePreview(); +} + +void LLDensityCtrl::onAnisoFactorChanged() +{ + updateProfile(); +} + +void LLDensityCtrl::updatePreview() +{ + // AdvancedAtmospherics TODO + // Generate image according to current density profile +} + diff --git a/indra/newview/lldensityctrl.h b/indra/newview/lldensityctrl.h new file mode 100644 index 0000000000..789022803c --- /dev/null +++ b/indra/newview/lldensityctrl.h @@ -0,0 +1,104 @@ +/** +* @file lldensityctrl.h +* @brief Control for specifying density over a height range for sky settings. +* +* $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 LLDENSITY_CTRL_H +#define LLDENSITY_CTRL_H + +#include "lluictrl.h" +#include "llsettingssky.h" +#include "lltextbox.h" +#include "llsliderctrl.h" + +class LLDensityCtrl : public LLUICtrl +{ +public: + static const std::string DENSITY_RAYLEIGH; + static const std::string DENSITY_MIE; + static const std::string DENSITY_ABSORPTION; + + // Type of density profile this tab is updating + enum DensityProfileType + { + Rayleigh, + Mie, + Absorption + }; + + static const std::string& NameForDensityProfileType(DensityProfileType t); + + struct Params : public LLInitParam::Block + { + Optional lbl_exponential, + lbl_exponential_scale, + lbl_linear, + lbl_constant, + lbl_max_altitude, + lbl_aniso_factor; + + Optional exponential_slider, + exponential_scale_slider, + linear_slider, + constant_slider, + aniso_factor_slider; + + Optional image_density_feedback; + + DensityProfileType profile_type; + Params(); + }; + + virtual BOOL postBuild() override; + virtual void setEnabled(BOOL enabled) override; + + void setProfileType(DensityProfileType t) { mProfileType = t; } + + void refresh(); + void updateProfile(); + + LLSettingsSky::ptr_t getSky() const { return mSkySettings; } + void setSky(const LLSettingsSky::ptr_t &sky) { mSkySettings = sky; refresh(); } + +protected: + friend class LLUICtrlFactory; + LLDensityCtrl(const Params&); + + LLSD getProfileConfig(); + void updatePreview(); + +private: + void onExponentialChanged(); + void onExponentialScaleFactorChanged(); + void onLinearChanged(); + void onConstantChanged(); + void onMaxAltitudeChanged(); + void onAnisoFactorChanged(); + + DensityProfileType mProfileType = Rayleigh; + LLUIImage* mImgDensityFeedback = nullptr; + LLSettingsSky::ptr_t mSkySettings; +}; + +#endif LLDENSITY_CTRL_H diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 554757840f..81d098b9a3 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -693,6 +693,11 @@ void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) { panel->setSky(p_sky); } + panel = dynamic_cast(tab_container->getChildView("advanced_atmo_panel")); + if (panel) + { + panel->setSky(p_sky); + } } void LLFloaterEditExtDayCycle::setWaterTabsEnabled(BOOL enable) @@ -729,6 +734,12 @@ void LLFloaterEditExtDayCycle::setSkyTabsEnabled(BOOL enable) panel->setEnabled(enable); panel->setAllChildrenEnabled(enable); } + panel = dynamic_cast(tab_container->getChildView("advanced_atmo_panel")); + if (panel) + { + panel->setEnabled(enable); + panel->setAllChildrenEnabled(enable); + } } void LLFloaterEditExtDayCycle::updateButtons() diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index 87c0a21c42..16cdc7994d 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -29,10 +29,13 @@ #include "llpaneleditsky.h" #include "llslider.h" +#include "llsliderctrl.h" #include "lltexturectrl.h" #include "llcolorswatch.h" #include "llvirtualtrackball.h" +#include "llsettingssky.h" +static LLDefaultChildRegistry::Register register_density_control("densityctrl"); namespace { @@ -59,7 +62,7 @@ namespace const std::string FIELD_SKY_CLOUD_DETAIL_Y("cloud_detail_y"); const std::string FIELD_SKY_CLOUD_DETAIL_D("cloud_detail_d"); - const std::string FIELD_SKY_SUN_MOON_COLOR("sun_moon_color"); + const std::string FIELD_SKY_SUN_MOON_COLOR("-m_moon_color"); 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"); @@ -79,6 +82,7 @@ namespace static LLPanelInjector t_settings_atmos("panel_settings_atmos"); static LLPanelInjector t_settings_cloud("panel_settings_cloud"); static LLPanelInjector t_settings_sunmoon("panel_settings_sunmoon"); +static LLPanelInjector t_settings_density("panel_settings_density"); //========================================================================== LLPanelSettingsSky::LLPanelSettingsSky() : @@ -424,3 +428,91 @@ void LLPanelSettingsSkySunMoonTab::onMoonImageChanged() mSkySettings->setMoonTextureId(getChild(FIELD_SKY_MOON_IMAGE)->getValue().asUUID()); mSkySettings->update(); } + +LLPanelSettingsDensityTab::LLPanelSettingsDensityTab() +{ +} + +BOOL LLPanelSettingsDensityTab::postBuild() +{ + mControlName = LLDensityCtrl::NameForDensityProfileType(mProfileType); + getChild(mControlName)->setProfileType(mProfileType); + refresh(); + return TRUE; +} + +void LLPanelSettingsDensityTab::setEnabled(BOOL enabled) +{ + LLPanelSettingsSky::setEnabled(enabled); + getChild(mControlName)->setEnabled(enabled); +} + +void LLPanelSettingsDensityTab::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + getChild(mControlName)->setSky(mSkySettings); + getChild(mControlName)->refresh(); +} + +void LLPanelSettingsDensityTab::updateProfile() +{ + getChild(mControlName)->setSky(mSkySettings); + getChild(mControlName)->updateProfile(); + mSkySettings->update(); +} + +LLPanelSettingsDensity::LLPanelSettingsDensity() +{ +} + +BOOL LLPanelSettingsDensity::postBuild() +{ + //static_cast(getChild(LLDensityCtrl::DENSITY_RAYLEIGH))->setProfileType(LLDensityCtrl::Rayleigh); + //static_cast(getChild(LLDensityCtrl::DENSITY_MIE))->setProfileType(LLDensityCtrl::Mie); + //static_cast(getChild(LLDensityCtrl::DENSITY_ABSORPTION))->setProfileType(LLDensityCtrl::Absorption); + refresh(); + return TRUE; +} + +void LLPanelSettingsDensity::setEnabled(BOOL enabled) +{ + LLPanelSettingsSky::setEnabled(enabled); + + //getChild(LLDensityCtrl::DENSITY_RAYLEIGH)->setEnabled(enabled); + //getChild(LLDensityCtrl::DENSITY_MIE)->setEnabled(enabled); + //getChild(LLDensityCtrl::DENSITY_ABSORPTION)->setEnabled(enabled); +} + +void LLPanelSettingsDensity::refresh() +{ + if (!mSkySettings) + { + setAllChildrenEnabled(FALSE); + setEnabled(FALSE); + return; + } + + setEnabled(TRUE); + setAllChildrenEnabled(TRUE); + + //getChild(LLDensityCtrl::DENSITY_RAYLEIGH)->refresh(); + //getChild(LLDensityCtrl::DENSITY_MIE)->refresh(); + //getChild(LLDensityCtrl::DENSITY_ABSORPTION)->refresh(); +} + +void LLPanelSettingsDensity::updateProfile() +{ + //getChild(LLDensityCtrl::DENSITY_RAYLEIGH)->updateProfile(); + //getChild(LLDensityCtrl::DENSITY_MIE)->updateProfile(); + //getChild(LLDensityCtrl::DENSITY_ABSORPTION)->updateProfile(); + mSkySettings->update(); +} + diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index 7c49c839ec..c9e0e3bd56 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -29,13 +29,14 @@ #include "llpanel.h" #include "llsettingssky.h" - #include "llfloaterfixedenvironment.h" +#include "lldensityctrl.h" //========================================================================= class LLSlider; class LLColorSwatchCtrl; class LLTextureCtrl; +class LLDensityCtrl; // custom control for specifying various sky density settings //========================================================================= class LLPanelSettingsSky : public LLSettingsEditPanel @@ -124,4 +125,44 @@ private: void onMoonRotationChanged(); void onMoonImageChanged(); }; + +// single subtab of the density settings tab +class LLPanelSettingsDensityTab : public LLPanelSettingsSky +{ + LOG_CLASS(LLPanelSettingsDensityTab); + +public: + LLPanelSettingsDensityTab(); + + virtual BOOL postBuild() override; + virtual void setEnabled(BOOL enabled) override; + + void setProfileType(LLDensityCtrl::DensityProfileType t) { mProfileType = t; } + +protected: + virtual void refresh() override; + + // update the settings for our profile type + void updateProfile(); + + LLDensityCtrl::DensityProfileType mProfileType; + std::string mControlName; +}; + +class LLPanelSettingsDensity : public LLPanelSettingsSky +{ + LOG_CLASS(LLPanelSettingsDensity); + +public: + LLPanelSettingsDensity(); + + virtual BOOL postBuild() override; + virtual void setEnabled(BOOL enabled) override; + +protected: + virtual void refresh() override; + + // update the settings for our profile type + void updateProfile(); +}; #endif // LLPANEL_EDIT_SKY_H diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml index caf7153a5c..80e58c8248 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -526,6 +526,15 @@ left_delta="0" top_pad="5" name="moon_panel" /> + diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml new file mode 100644 index 0000000000..05bd3c336a --- /dev/null +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml @@ -0,0 +1,32 @@ + + + + + name="panel_settings_sky_density_rayleigh" + + name = "density_rayleigh" + + + + name="panel_settings_sky_density_mie" + + name = "density_mie" + + + + name="panel_settings_sky_density_absorption" + + name = "density_absorption" + + + + diff --git a/indra/newview/skins/default/xui/en/widgets/density_ctrl.xml b/indra/newview/skins/default/xui/en/widgets/density_ctrl.xml new file mode 100644 index 0000000000..0f3f0159db --- /dev/null +++ b/indra/newview/skins/default/xui/en/widgets/density_ctrl.xml @@ -0,0 +1,164 @@ + + + +Exponential Term + + + + + +Exponential Scale Factor + + + + +Linear Term + + + + +Constant Term + + + + +Max Altitude + + + + +Anisotropy Factor + + + -- cgit v1.2.3 From b45a7144aa5be95ffc8edd406ef9ab14c4192890 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 22 Aug 2018 00:49:48 +0100 Subject: Fix up dropped new funcs for settings density profile configs in sky settings. --- indra/llinventory/llsettingssky.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 14caca36a7..d15e084878 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -120,6 +120,10 @@ public: LLSD getAbsorptionConfigs() const; LLUUID getBloomTextureId() const; + void setRayleighConfigs(const LLSD& rayleighConfig); + void setMieConfigs(const LLSD& mieConfig); + void setAbsorptionConfigs(const LLSD& absorptionConfig); + //--------------------------------------------------------------------- LLColor3 getAmbientColor() const; void setAmbientColor(const LLColor3 &val); -- cgit v1.2.3 From ab1c7087e944ea9ded217770176e3444c8c39c0d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 22 Aug 2018 00:52:47 +0100 Subject: Restore funcs to create LLSD for density layers and profiles with single density layers. --- indra/llinventory/llsettingssky.cpp | 73 +++++++++++++++++++++---------------- 1 file changed, 41 insertions(+), 32 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index bc02867ce6..3ede670d35 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -554,36 +554,53 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList() return validation; } +LLSD LLSettingsSky::createDensityProfileLayer( + F32 width, + F32 exponential_term, + F32 exponential_scale_factor, + F32 linear_term, + F32 constant_term, + F32 aniso_factor) +{ + LLSD dflt_layer; + dflt_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere + dflt_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f; + dflt_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 8000.0f; + dflt_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f; + dflt_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f; + + if (aniso_factor != 0.0f) + { + dflt_layer[SETTING_MIE_ANISOTROPY_FACTOR] = aniso_factor; + } + + return dflt_layer; +} + +LLSD LLSettingsSky::createSingleLayerDensityProfile( + F32 width, + F32 exponential_term, + F32 exponential_scale_factor, + F32 linear_term, + F32 constant_term, + F32 aniso_factor) +{ + LLSD dflt; + LLSD dflt_layer = createDensityProfileLayer(width, exponential_term, exponential_scale_factor, linear_term, constant_term, aniso_factor); + dflt.append(dflt_layer); + return dflt; +} + LLSD LLSettingsSky::rayleighConfigDefault() { - LLSD dflt_rayleigh; - LLSD dflt_rayleigh_layer; - dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere - dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f; - dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 8000.0f; - dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f; - dflt_rayleigh_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f; - dflt_rayleigh.append(dflt_rayleigh_layer); - return dflt_rayleigh; + return createSingleLayerDensityProfile(0.0f, 1.0f, -1.0f / 8000.0f, 0.0f, 0.0f); } LLSD LLSettingsSky::absorptionConfigDefault() { // absorption (ozone) has two linear ramping zones - LLSD dflt_absorption_layer_a; - dflt_absorption_layer_a[SETTING_DENSITY_PROFILE_WIDTH] = 25000.0f; // 0 -> the entire atmosphere - dflt_absorption_layer_a[SETTING_DENSITY_PROFILE_EXP_TERM] = 0.0f; - dflt_absorption_layer_a[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = 0.0f; - dflt_absorption_layer_a[SETTING_DENSITY_PROFILE_LINEAR_TERM] = -1.0f / 25000.0f; - dflt_absorption_layer_a[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = -2.0f / 3.0f; - - LLSD dflt_absorption_layer_b; - dflt_absorption_layer_b[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> remainder of the atmosphere - dflt_absorption_layer_b[SETTING_DENSITY_PROFILE_EXP_TERM] = 0.0f; - dflt_absorption_layer_b[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = 0.0f; - dflt_absorption_layer_b[SETTING_DENSITY_PROFILE_LINEAR_TERM] = -1.0f / 15000.0f; - dflt_absorption_layer_b[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 8.0f / 3.0f; - + LLSD dflt_absorption_layer_a = createDensityProfileLayer(25000.0f, 0.0f, 0.0f, -1.0f / 25000.0f, -2.0f / 3.0f); + LLSD dflt_absorption_layer_b = createDensityProfileLayer(0.0f, 0.0f, 0.0f, -1.0f / 15000.0f, 8.0f / 3.0f); LLSD dflt_absorption; dflt_absorption.append(dflt_absorption_layer_a); dflt_absorption.append(dflt_absorption_layer_b); @@ -592,15 +609,7 @@ LLSD LLSettingsSky::absorptionConfigDefault() LLSD LLSettingsSky::mieConfigDefault() { - LLSD dflt_mie; - LLSD dflt_mie_layer; - dflt_mie_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere - dflt_mie_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f; - dflt_mie_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 1200.0f; - dflt_mie_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f; - dflt_mie_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f; - dflt_mie_layer[SETTING_MIE_ANISOTROPY_FACTOR] = 0.8f; - dflt_mie.append(dflt_mie_layer); + LLSD dflt_mie = createSingleLayerDensityProfile(0.0f, 1.0f, -1.0f / 1200.0f, 0.0f, 0.0f, 0.8f); return dflt_mie; } -- cgit v1.2.3 From cb00370c4ac3722d9962db502fc15cdd0efffe10 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 29 Aug 2018 19:22:47 +0100 Subject: Remove func referring to LLDensityCtrl which we no longer include in the header. --- indra/newview/llpaneleditsky.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index aadbd85a37..a1b8a4b17e 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -137,8 +137,6 @@ public: virtual BOOL postBuild() override; virtual void setEnabled(BOOL enabled) override; - void setProfileType(LLDensityCtrl::DensityProfileType t) { mProfileType = t; } - protected: virtual void refresh() override; -- cgit v1.2.3 From 964a472461bed91b3efa383aaea34d425b96111d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 29 Aug 2018 21:13:09 +0100 Subject: Hook up sky density panel to fixedenv and edit_ext_daycycle UI. Fix retrieving LLSD for density configs (element not array) in density UI. Tweak layout of sky density controls. --- indra/llinventory/llsettingssky.cpp | 29 +++++- indra/llinventory/llsettingssky.h | 9 +- indra/newview/llfloatereditextdaycycle.cpp | 4 +- indra/newview/llfloaterfixedenvironment.cpp | 6 ++ indra/newview/llpaneleditsky.cpp | 103 ++++++++++++--------- indra/newview/llpaneleditsky.h | 6 +- .../default/xui/en/floater_edit_ext_day_cycle.xml | 4 +- .../default/xui/en/panel_settings_sky_density.xml | 84 ++++++++--------- 8 files changed, 144 insertions(+), 101 deletions(-) diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 0d789590fa..5f55018387 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -1161,20 +1161,41 @@ F32 LLSettingsSky::getMieAnisotropy() const { return mSettings[SETTING_MIE_ANISOTROPY_FACTOR].asReal(); } - + +LLSD LLSettingsSky::getRayleighConfig() const +{ + LLSD copy = *(mSettings[SETTING_RAYLEIGH_CONFIG].beginArray()); + return copy; +} + +LLSD LLSettingsSky::getMieConfig() const +{ + LLSD copy = *(mSettings[SETTING_MIE_CONFIG].beginArray()); + return copy; +} + +LLSD LLSettingsSky::getAbsorptionConfig() const +{ + LLSD copy = *(mSettings[SETTING_ABSORPTION_CONFIG].beginArray()); + return copy; +} + LLSD LLSettingsSky::getRayleighConfigs() const { - return mSettings[SETTING_RAYLEIGH_CONFIG]; + LLSD copy = *(mSettings[SETTING_RAYLEIGH_CONFIG].beginArray()); + return copy; } LLSD LLSettingsSky::getMieConfigs() const { - return mSettings[SETTING_MIE_CONFIG]; + LLSD copy = *(mSettings[SETTING_MIE_CONFIG].beginArray()); + return copy; } LLSD LLSettingsSky::getAbsorptionConfigs() const { - return mSettings[SETTING_ABSORPTION_CONFIG]; + LLSD copy = *(mSettings[SETTING_ABSORPTION_CONFIG].beginArray()); + return copy; } void LLSettingsSky::setRayleighConfigs(const LLSD& rayleighConfig) diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 8030bfeb39..a4ea8c98f4 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -116,10 +116,17 @@ public: F32 getSkyTopRadius() const; F32 getSunArcRadians() const; F32 getMieAnisotropy() const; + + // Return first (only) profile layer represented in LLSD + LLSD getRayleighConfig() const; + LLSD getMieConfig() const; + LLSD getAbsorptionConfig() const; + + // Return entire LLSDArray of profile layers represented in LLSD LLSD getRayleighConfigs() const; LLSD getMieConfigs() const; - LLSD getAbsorptionConfigs() const; + LLUUID getBloomTextureId() const; void setRayleighConfigs(const LLSD& rayleighConfig); diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 38f90a327d..9c3a48c412 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -818,7 +818,7 @@ void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) { panel->setSky(p_sky); } - panel = dynamic_cast(tab_container->getChildView("advanced_atmo_panel")); + panel = dynamic_cast(tab_container->getChildView("advanced_atmo_panel")); if (panel) { panel->setSky(p_sky); @@ -859,7 +859,7 @@ void LLFloaterEditExtDayCycle::setSkyTabsEnabled(BOOL enable) panel->setEnabled(enable); panel->setAllChildrenEnabled(enable); } - panel = dynamic_cast(tab_container->getChildView("advanced_atmo_panel")); + panel = dynamic_cast(tab_container->getChildView("advanced_atmo_panel")); if (panel) { panel->setEnabled(enable); diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index ece4898935..7ff1663942 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -596,6 +596,12 @@ BOOL LLFloaterFixedEnvironmentSky::postBuild() panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); + panel = new LLPanelSettingsSkyDensityTab; + panel->buildFromFile("panel_settings_sky_density.xml"); + panel->setSky(std::static_pointer_cast(mSettings)); + panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); + return TRUE; } diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index 0799180a19..a9cf9a00d6 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -35,7 +35,6 @@ #include "llvirtualtrackball.h" #include "llsettingssky.h" - namespace { // Atmosphere Tab @@ -100,7 +99,7 @@ namespace static LLPanelInjector t_settings_atmos("panel_settings_atmos"); static LLPanelInjector t_settings_cloud("panel_settings_cloud"); static LLPanelInjector t_settings_sunmoon("panel_settings_sunmoon"); -static LLPanelInjector t_settings_density("panel_settings_density"); +static LLPanelInjector t_settings_density("panel_settings_density"); //========================================================================== LLPanelSettingsSky::LLPanelSettingsSky() : @@ -511,11 +510,11 @@ void LLPanelSettingsSkySunMoonTab::onMoonScaleChanged() } -LLPanelSettingsDensityTab::LLPanelSettingsDensityTab() +LLPanelSettingsSkyDensityTab::LLPanelSettingsSkyDensityTab() { } -BOOL LLPanelSettingsDensityTab::postBuild() +BOOL LLPanelSettingsSkyDensityTab::postBuild() { getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighExponentialChanged(); }); getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighExponentialScaleChanged(); }); @@ -539,7 +538,7 @@ BOOL LLPanelSettingsDensityTab::postBuild() return TRUE; } -void LLPanelSettingsDensityTab::setEnabled(BOOL enabled) +void LLPanelSettingsSkyDensityTab::setEnabled(BOOL enabled) { LLPanelSettingsSky::setEnabled(enabled); @@ -562,7 +561,7 @@ void LLPanelSettingsDensityTab::setEnabled(BOOL enabled) getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setEnabled(enabled); } -void LLPanelSettingsDensityTab::refresh() +void LLPanelSettingsSkyDensityTab::refresh() { if (!mSkySettings) { @@ -574,30 +573,46 @@ void LLPanelSettingsDensityTab::refresh() setEnabled(TRUE); setAllChildrenEnabled(TRUE); - LLSD rayleigh_config = mSkySettings->getRayleighConfigs(); - LLSD mie_config = mSkySettings->getMieConfigs(); - LLSD absorption_config = mSkySettings->getAbsorptionConfigs(); - - getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setValue(rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM]); - getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setValue(rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR]); - getChild(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setValue(rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM]); - getChild(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setValue(rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM]); - - getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setValue(mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM]); - getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setValue(mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR]); - getChild(FIELD_SKY_DENSITY_MIE_LINEAR)->setValue(mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM]); - getChild(FIELD_SKY_DENSITY_MIE_CONSTANT)->setValue(mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM]); - getChild(FIELD_SKY_DENSITY_MIE_ANISO)->setValue(mie_config[LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR]); - - getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setValue(absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM]); - getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setValue(absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR]); - getChild(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setValue(absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM]); - getChild(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setValue(absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM]); - - getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setValue(rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH]); -} - -void LLPanelSettingsDensityTab::updateProfile() + // Get first (only) profile layer of each type for editing + LLSD rayleigh_config = mSkySettings->getRayleighConfig(); + LLSD mie_config = mSkySettings->getMieConfig(); + LLSD absorption_config = mSkySettings->getAbsorptionConfig(); + + F32 rayleigh_exponential_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 rayleigh_exponential_scale = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + F32 rayleigh_linear_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + F32 rayleigh_constant_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + F32 mie_exponential_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 mie_exponential_scale = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + F32 mie_linear_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + F32 mie_constant_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + F32 mie_aniso_factor = mie_config[LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR].asReal(); + F32 absorption_exponential_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 absorption_exponential_scale = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); + F32 absorption_linear_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); + F32 absorption_constant_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); + F32 max_alt = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + + getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setValue(rayleigh_exponential_term); + getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setValue(rayleigh_exponential_scale); + getChild(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setValue(rayleigh_linear_term); + getChild(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setValue(rayleigh_constant_term); + + getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setValue(mie_exponential_term); + getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setValue(mie_exponential_scale); + getChild(FIELD_SKY_DENSITY_MIE_LINEAR)->setValue(mie_linear_term); + getChild(FIELD_SKY_DENSITY_MIE_CONSTANT)->setValue(mie_constant_term); + getChild(FIELD_SKY_DENSITY_MIE_ANISO)->setValue(mie_aniso_factor); + + getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setValue(absorption_exponential_term); + getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setValue(absorption_exponential_scale); + getChild(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setValue(absorption_linear_term); + getChild(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setValue(absorption_constant_term); + + getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setValue(max_alt); +} + +void LLPanelSettingsSkyDensityTab::updateProfile() { F32 rayleigh_exponential_term = getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->getValueF32(); F32 rayleigh_exponential_scale = getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->getValueF32(); @@ -625,72 +640,72 @@ void LLPanelSettingsDensityTab::updateProfile() mSkySettings->update(); } -void LLPanelSettingsDensityTab::onRayleighExponentialChanged() +void LLPanelSettingsSkyDensityTab::onRayleighExponentialChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onRayleighExponentialScaleChanged() +void LLPanelSettingsSkyDensityTab::onRayleighExponentialScaleChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onRayleighLinearChanged() +void LLPanelSettingsSkyDensityTab::onRayleighLinearChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onRayleighConstantChanged() +void LLPanelSettingsSkyDensityTab::onRayleighConstantChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onMieExponentialChanged() +void LLPanelSettingsSkyDensityTab::onMieExponentialChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onMieExponentialScaleChanged() +void LLPanelSettingsSkyDensityTab::onMieExponentialScaleChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onMieLinearChanged() +void LLPanelSettingsSkyDensityTab::onMieLinearChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onMieConstantChanged() +void LLPanelSettingsSkyDensityTab::onMieConstantChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onMieAnisoFactorChanged() +void LLPanelSettingsSkyDensityTab::onMieAnisoFactorChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onAbsorptionExponentialChanged() +void LLPanelSettingsSkyDensityTab::onAbsorptionExponentialChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onAbsorptionExponentialScaleChanged() +void LLPanelSettingsSkyDensityTab::onAbsorptionExponentialScaleChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onAbsorptionLinearChanged() +void LLPanelSettingsSkyDensityTab::onAbsorptionLinearChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onAbsorptionConstantChanged() +void LLPanelSettingsSkyDensityTab::onAbsorptionConstantChanged() { updateProfile(); } -void LLPanelSettingsDensityTab::onMaxAltitudeChanged() +void LLPanelSettingsSkyDensityTab::onMaxAltitudeChanged() { updateProfile(); } diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index a1b8a4b17e..a9022ec86b 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -127,12 +127,12 @@ private: }; // single subtab of the density settings tab -class LLPanelSettingsDensityTab : public LLPanelSettingsSky +class LLPanelSettingsSkyDensityTab : public LLPanelSettingsSky { - LOG_CLASS(LLPanelSettingsDensityTab); + LOG_CLASS(LLPanelSettingsSkyDensityTab); public: - LLPanelSettingsDensityTab(); + LLPanelSettingsSkyDensityTab(); virtual BOOL postBuild() override; virtual void setEnabled(BOOL enabled) override; diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml index c3f94f9aa3..61299a43bd 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -524,11 +524,11 @@ Select a key frame from the timeline above to edit settings. border="true" class="panel_settings_density" filename="panel_settings_sky_density.xml" - label="Advanced Atmospherics" + label="Density" layout="topleft" left_delta="0" top_pad="5" - name="sky_density_panel" /> + name="panel_settings_sky_density" /> diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml index b97dfcd0fe..d82cdb30be 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml @@ -22,11 +22,11 @@ auto_resize="true" user_resize="true" visible="true" - height="28"> + height="16"> + height="18"> + height="16"> + height="10"> - + -- cgit v1.2.3 From 52f949d71a57415e372381fffeb126d8939522be Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Wed, 29 Aug 2018 21:14:56 +0100 Subject: Fix range on rayleigh exponential scale factor to include negative values. --- indra/newview/skins/default/xui/en/panel_settings_sky_density.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml index d82cdb30be..5159a2714e 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml @@ -46,7 +46,7 @@ increment="0.01" initial_value="0" layout="topleft" - min_val="0" + min_val="-1" max_val="1" name="rayleigh_exponential_scale" label="Rayleigh Exponential Scale:" -- cgit v1.2.3 From 8b4d61bd2271338c51360939cac3e58c227870df Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 30 Aug 2018 18:01:04 +0100 Subject: Merge --- indra/newview/app_settings/settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index d30657a30a..f0f7095ca1 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10165,7 +10165,7 @@ Type Boolean Value - 0 + 1 RenderUseTriStrips -- cgit v1.2.3 From 3b0ab35ac1325b164cc8ffa05d9ea4d3532ac40a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 30 Aug 2018 18:08:16 +0100 Subject: Merge --- indra/newview/app_settings/settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index f0f7095ca1..d30657a30a 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10165,7 +10165,7 @@ Type Boolean Value - 1 + 0 RenderUseTriStrips -- cgit v1.2.3 From b51972bac7f0b11955474baebebd3f1d7c9e60e3 Mon Sep 17 00:00:00 2001 From: Oz Linden Date: Tue, 4 Sep 2018 12:39:56 -0400 Subject: use copy_if_different to copy CrashReporter.nib so that it creates the directory if needed --- indra/mac_crash_logger/CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/mac_crash_logger/CMakeLists.txt b/indra/mac_crash_logger/CMakeLists.txt index ab20388261..f6c4dfb59d 100644 --- a/indra/mac_crash_logger/CMakeLists.txt +++ b/indra/mac_crash_logger/CMakeLists.txt @@ -85,7 +85,7 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} ARGS -E - copy_directory + copy_if_different ${CMAKE_CURRENT_SOURCE_DIR}/CrashReporter.nib ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/mac-crash-logger.app/Contents/Resources/CrashReporter.nib ) -- cgit v1.2.3 From 32631f09a57548c2bbf7e09211a2053ff2e4e47d Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 4 Sep 2018 23:41:36 +0100 Subject: 8283/4 WIP --- autobuild.xml | 16 ++--- indra/llinventory/llsettingssky.cpp | 2 + indra/llrender/llatmosphere.cpp | 8 ++- indra/newview/app_settings/settings.xml | 4 +- .../app_settings/shaders/class3/deferred/skyF.glsl | 2 +- indra/newview/lldrawpoolwlsky.cpp | 6 +- indra/newview/llenvironment.cpp | 3 +- indra/newview/llpaneleditsky.cpp | 69 ++++++++++++++++++---- indra/newview/llpaneleditsky.h | 5 +- .../default/xui/en/panel_settings_sky_density.xml | 54 +++++++++++------ 10 files changed, 121 insertions(+), 48 deletions(-) diff --git a/autobuild.xml b/autobuild.xml index 1c328ddb3e..b5e336948a 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -64,9 +64,9 @@ archive hash - 2679e9960e5a1c14e8c6a4e8baf70040 + 722693009586e18aa4d611218c26c5e3 url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/21515/158137/libatmosphere-1.0.0.100-darwin-517661.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/23969/184338/libatmosphere-1.0.0.100-darwin-519274.tar.bz2 name darwin @@ -76,9 +76,9 @@ archive hash - 3b509a8b85a05c53fa19f5f06f0e546b + 9ecdbb77a18a5dea905ebd3d7faf1f8f url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/21514/158129/libatmosphere-1.0.0.100-darwin64-517661.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/23968/184333/libatmosphere-1.0.0.100-darwin64-519274.tar.bz2 name darwin64 @@ -88,9 +88,9 @@ archive hash - b0f7b131d0a7d8d6a6404f27f2697872 + 05e113c2988bf77dcde7df0216c26481 url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/21517/158147/libatmosphere-1.0.0.100-windows-517661.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/23971/184350/libatmosphere-1.0.0.100-windows-519274.tar.bz2 name windows @@ -100,9 +100,9 @@ archive hash - a50d05abaca0ae167640171ab814a3db + 1b5fcfbc0123263d68843ac4570c8204 url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/21516/158140/libatmosphere-1.0.0.100-windows64-517661.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/23970/184345/libatmosphere-1.0.0.100-windows64-519274.tar.bz2 name windows64 diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 5f55018387..cd6dfad71d 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -32,6 +32,8 @@ #include "llfasttimer.h" #include "v3colorutil.h" +#pragma optimize("", off) + //========================================================================= static const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees static const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION * DEG_TO_RAD); diff --git a/indra/llrender/llatmosphere.cpp b/indra/llrender/llatmosphere.cpp index 4edfd9efe9..4fd9764e07 100644 --- a/indra/llrender/llatmosphere.cpp +++ b/indra/llrender/llatmosphere.cpp @@ -34,6 +34,8 @@ #include "llshadermgr.h" #include "llglslshader.h" +#pragma optimize("", off) + LLAtmosphere* gAtmosphere = nullptr; // Values from "Reference Solar Spectral Irradiance: ASTM G-173", ETR column @@ -78,6 +80,8 @@ const double kMieScaleHeight = 1200.0; const double kMieAngstromAlpha = 0.0; const double kMieAngstromBeta = 5.328e-3; const double kMieSingleScatteringAlbedo = 0.9; +const double kGroundAlbedo = 0.1; + const double max_sun_zenith_angle = F_PI * 2.0 / 3.0; AtmosphericModelSettings::AtmosphericModelSettings() @@ -201,7 +205,7 @@ LLAtmosphere::LLAtmosphere() m_mie_scattering.push_back(mie * kMieSingleScatteringAlbedo); m_mie_extinction.push_back(mie); m_absorption_extinction.push_back(kMaxOzoneNumberDensity * kOzoneCrossSection[(l - kLambdaMin) / 10]); - m_ground_albedo.push_back(0.6f); + m_ground_albedo.push_back(kGroundAlbedo); } AtmosphericModelSettings defaults; @@ -268,7 +272,7 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) m_ground_albedo, max_sun_zenith_angle, 1000.0, - 15, + 3, false, true); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 214b1a1965..e32eeb4779 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8664,7 +8664,7 @@ Type Boolean Value - 0 + 1 RenderLocalLights @@ -10165,7 +10165,7 @@ Type Boolean Value - 0 + 1 RenderUseTriStrips diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl index 47fa0efe06..01c873584f 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl @@ -1,5 +1,5 @@ /** - * @file advancedAtmoF.glsl + * @file class3/skyF.glsl * * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 4bf47f4fd6..04f358ba79 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -44,6 +44,8 @@ #include "llenvironment.h" #include "llatmosphere.h" +#pragma optimize("", off) + static LLStaticHashedString sCamPosLocal("camPosLocal"); static LLStaticHashedString sCustomAlpha("custom_alpha"); @@ -180,12 +182,12 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m); - // clouds are rendered along with sky in adv atmo + /* clouds are rendered along with sky in adv atmo if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && gSky.mVOSkyp->getCloudNoiseTex()) { sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, gSky.mVOSkyp->getCloudNoiseTex()); sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, gSky.mVOSkyp->getCloudNoiseTexNext()); - } + }*/ sky_shader->uniform3f(sCamPosLocal, camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 6e19df0a94..ed25120241 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1628,13 +1628,14 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mSky->mReplaced |= different_sky; mSky->update(); mBlenderSky.reset(); - +/* if (gAtmosphere) { AtmosphericModelSettings settings; LLEnvironment::getAtmosphericModelSettings(settings, psky); gAtmosphere->configureAtmosphericModel(settings); } +*/ } void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index a9cf9a00d6..451e15c73d 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -34,6 +34,10 @@ #include "llcolorswatch.h" #include "llvirtualtrackball.h" #include "llsettingssky.h" +#include "llenvironment.h" +#include "llatmosphere.h" + +#pragma optimize("", off) namespace { @@ -75,18 +79,20 @@ namespace const std::string FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE("rayleigh_exponential_scale"); const std::string FIELD_SKY_DENSITY_RAYLEIGH_LINEAR("rayleigh_linear"); const std::string FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT("rayleigh_constant"); + const std::string FIELD_SKY_DENSITY_RAYLEIGH_MAX_ALTITUDE("rayleigh_max_altitude"); const std::string FIELD_SKY_DENSITY_MIE_EXPONENTIAL("mie_exponential"); const std::string FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE("mie_exponential_scale"); const std::string FIELD_SKY_DENSITY_MIE_LINEAR("mie_linear"); const std::string FIELD_SKY_DENSITY_MIE_CONSTANT("mie_constant"); const std::string FIELD_SKY_DENSITY_MIE_ANISO("mie_aniso_factor"); + const std::string FIELD_SKY_DENSITY_MIE_MAX_ALTITUDE("mie_max_altitude"); const std::string FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL("absorption_exponential"); const std::string FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE("absorption_exponential_scale"); const std::string FIELD_SKY_DENSITY_ABSORPTION_LINEAR("absorption_linear"); const std::string FIELD_SKY_DENSITY_ABSORPTION_CONSTANT("absorption_constant"); - const std::string FIELD_SKY_DENSITY_MAX_ALTITUDE("max_altitude"); + const std::string FIELD_SKY_DENSITY_ABSORPTION_MAX_ALTITUDE("absorption_max_altitude"); const F32 SLIDER_SCALE_SUN_AMBIENT(3.0f); const F32 SLIDER_SCALE_BLUE_HORIZON_DENSITY(2.0f); @@ -520,19 +526,21 @@ BOOL LLPanelSettingsSkyDensityTab::postBuild() getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighExponentialScaleChanged(); }); getChild(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighLinearChanged(); }); getChild(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighConstantChanged(); }); + getChild(FIELD_SKY_DENSITY_RAYLEIGH_MAX_ALTITUDE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onRayleighMaxAltitudeChanged(); }); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieExponentialChanged(); }); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieExponentialScaleChanged(); }); getChild(FIELD_SKY_DENSITY_MIE_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieLinearChanged(); }); getChild(FIELD_SKY_DENSITY_MIE_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieConstantChanged(); }); getChild(FIELD_SKY_DENSITY_MIE_ANISO)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieAnisoFactorChanged(); }); + getChild(FIELD_SKY_DENSITY_MIE_MAX_ALTITUDE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMieMaxAltitudeChanged(); }); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionExponentialChanged(); }); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionExponentialScaleChanged(); }); getChild(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionLinearChanged(); }); getChild(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionConstantChanged(); }); - getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMaxAltitudeChanged(); }); + getChild(FIELD_SKY_DENSITY_ABSORPTION_MAX_ALTITUDE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onAbsorptionMaxAltitudeChanged(); }); refresh(); return TRUE; @@ -546,19 +554,20 @@ void LLPanelSettingsSkyDensityTab::setEnabled(BOOL enabled) getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setEnabled(enabled); + getChild(FIELD_SKY_DENSITY_RAYLEIGH_MAX_ALTITUDE)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MIE_LINEAR)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MIE_CONSTANT)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_MIE_ANISO)->setEnabled(enabled); + getChild(FIELD_SKY_DENSITY_MIE_MAX_ALTITUDE)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setEnabled(enabled); getChild(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setEnabled(enabled); - - getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setEnabled(enabled); + getChild(FIELD_SKY_DENSITY_ABSORPTION_MAX_ALTITUDE)->setEnabled(enabled); } void LLPanelSettingsSkyDensityTab::refresh() @@ -582,34 +591,39 @@ void LLPanelSettingsSkyDensityTab::refresh() F32 rayleigh_exponential_scale = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); F32 rayleigh_linear_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); F32 rayleigh_constant_term = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); + F32 rayleigh_max_alt = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + F32 mie_exponential_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); F32 mie_exponential_scale = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); F32 mie_linear_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); F32 mie_constant_term = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_CONSTANT_TERM].asReal(); F32 mie_aniso_factor = mie_config[LLSettingsSky::SETTING_MIE_ANISOTROPY_FACTOR].asReal(); + F32 mie_max_alt = mie_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + F32 absorption_exponential_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); F32 absorption_exponential_scale = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR].asReal(); F32 absorption_linear_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_LINEAR_TERM].asReal(); F32 absorption_constant_term = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_EXP_TERM].asReal(); - F32 max_alt = rayleigh_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); + F32 absorption_max_alt = absorption_config[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL)->setValue(rayleigh_exponential_term); getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->setValue(rayleigh_exponential_scale); getChild(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->setValue(rayleigh_linear_term); getChild(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->setValue(rayleigh_constant_term); + getChild(FIELD_SKY_DENSITY_RAYLEIGH_MAX_ALTITUDE)->setValue(rayleigh_max_alt); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->setValue(mie_exponential_term); getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->setValue(mie_exponential_scale); getChild(FIELD_SKY_DENSITY_MIE_LINEAR)->setValue(mie_linear_term); getChild(FIELD_SKY_DENSITY_MIE_CONSTANT)->setValue(mie_constant_term); getChild(FIELD_SKY_DENSITY_MIE_ANISO)->setValue(mie_aniso_factor); + getChild(FIELD_SKY_DENSITY_MIE_MAX_ALTITUDE)->setValue(mie_max_alt); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->setValue(absorption_exponential_term); getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->setValue(absorption_exponential_scale); getChild(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->setValue(absorption_linear_term); getChild(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->setValue(absorption_constant_term); - - getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->setValue(max_alt); + getChild(FIELD_SKY_DENSITY_ABSORPTION_MAX_ALTITUDE)->setValue(absorption_max_alt); } void LLPanelSettingsSkyDensityTab::updateProfile() @@ -618,26 +632,47 @@ void LLPanelSettingsSkyDensityTab::updateProfile() F32 rayleigh_exponential_scale = getChild(FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE)->getValueF32(); F32 rayleigh_linear_term = getChild(FIELD_SKY_DENSITY_RAYLEIGH_LINEAR)->getValueF32(); F32 rayleigh_constant_term = getChild(FIELD_SKY_DENSITY_RAYLEIGH_CONSTANT)->getValueF32(); + F32 rayleigh_max_alt = getChild(FIELD_SKY_DENSITY_RAYLEIGH_MAX_ALTITUDE)->getValueF32(); + F32 mie_exponential_term = getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL)->getValueF32(); F32 mie_exponential_scale = getChild(FIELD_SKY_DENSITY_MIE_EXPONENTIAL_SCALE)->getValueF32(); F32 mie_linear_term = getChild(FIELD_SKY_DENSITY_MIE_LINEAR)->getValueF32(); F32 mie_constant_term = getChild(FIELD_SKY_DENSITY_MIE_CONSTANT)->getValueF32(); F32 mie_aniso_factor = getChild(FIELD_SKY_DENSITY_MIE_ANISO)->getValueF32(); + F32 mie_max_alt = getChild(FIELD_SKY_DENSITY_MIE_MAX_ALTITUDE)->getValueF32(); + F32 absorption_exponential_term = getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL)->getValueF32(); F32 absorption_exponential_scale = getChild(FIELD_SKY_DENSITY_ABSORPTION_EXPONENTIAL_SCALE)->getValueF32(); F32 absorption_linear_term = getChild(FIELD_SKY_DENSITY_ABSORPTION_LINEAR)->getValueF32(); F32 absorption_constant_term = getChild(FIELD_SKY_DENSITY_ABSORPTION_CONSTANT)->getValueF32(); - F32 max_alt = getChild(FIELD_SKY_DENSITY_MAX_ALTITUDE)->getValueF32(); + F32 absorption_max_alt = getChild(FIELD_SKY_DENSITY_ABSORPTION_MAX_ALTITUDE)->getValueF32(); + + LLSD rayleigh_config = LLSettingsSky::createSingleLayerDensityProfile(rayleigh_max_alt, rayleigh_exponential_term, rayleigh_exponential_scale, rayleigh_linear_term, rayleigh_constant_term); + LLSD mie_config = LLSettingsSky::createSingleLayerDensityProfile(mie_max_alt, mie_exponential_term, mie_exponential_scale, mie_linear_term, mie_constant_term, mie_aniso_factor); + LLSD absorption_layer = LLSettingsSky::createSingleLayerDensityProfile(absorption_max_alt, absorption_exponential_term, absorption_exponential_scale, absorption_linear_term, absorption_constant_term); + + static LLSD absorption_layer_ozone = LLSettingsSky::createDensityProfileLayer(0.0f, 0.0f, 0.0f, -1.0f / 15000.0f, 8.0f / 3.0f); - LLSD rayleigh_config = LLSettingsSky::createSingleLayerDensityProfile(max_alt, rayleigh_exponential_term, rayleigh_exponential_scale, rayleigh_linear_term, rayleigh_constant_term); - LLSD mie_config = LLSettingsSky::createSingleLayerDensityProfile(max_alt, mie_exponential_term, mie_exponential_scale, mie_linear_term, mie_constant_term, mie_aniso_factor); - LLSD absorption_config = LLSettingsSky::createSingleLayerDensityProfile(max_alt, absorption_exponential_term, absorption_exponential_scale, absorption_linear_term, absorption_constant_term); + LLSD absorption_config; + absorption_config.append(absorption_layer); + absorption_config.append(absorption_layer_ozone); mSkySettings->setRayleighConfigs(rayleigh_config); mSkySettings->setMieConfigs(mie_config); mSkySettings->setAbsorptionConfigs(absorption_config); mSkySettings->update(); + setIsDirty(); + +/* + if (gAtmosphere) + { + AtmosphericModelSettings atmospheric_settings; + LLEnvironment::getAtmosphericModelSettings(atmospheric_settings, mSkySettings); + gAtmosphere->configureAtmosphericModel(atmospheric_settings); + } +*/ + } void LLPanelSettingsSkyDensityTab::onRayleighExponentialChanged() @@ -660,6 +695,11 @@ void LLPanelSettingsSkyDensityTab::onRayleighConstantChanged() updateProfile(); } +void LLPanelSettingsSkyDensityTab::onRayleighMaxAltitudeChanged() +{ + updateProfile(); +} + void LLPanelSettingsSkyDensityTab::onMieExponentialChanged() { updateProfile(); @@ -685,6 +725,11 @@ void LLPanelSettingsSkyDensityTab::onMieAnisoFactorChanged() updateProfile(); } +void LLPanelSettingsSkyDensityTab::onMieMaxAltitudeChanged() +{ + updateProfile(); +} + void LLPanelSettingsSkyDensityTab::onAbsorptionExponentialChanged() { updateProfile(); @@ -705,7 +750,7 @@ void LLPanelSettingsSkyDensityTab::onAbsorptionConstantChanged() updateProfile(); } -void LLPanelSettingsSkyDensityTab::onMaxAltitudeChanged() +void LLPanelSettingsSkyDensityTab::onAbsorptionMaxAltitudeChanged() { updateProfile(); } diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index a9022ec86b..b34271f610 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -144,19 +144,20 @@ protected: void onRayleighExponentialScaleChanged(); void onRayleighLinearChanged(); void onRayleighConstantChanged(); + void onRayleighMaxAltitudeChanged(); void onMieExponentialChanged(); void onMieExponentialScaleChanged(); void onMieLinearChanged(); void onMieConstantChanged(); void onMieAnisoFactorChanged(); + void onMieMaxAltitudeChanged(); void onAbsorptionExponentialChanged(); void onAbsorptionExponentialScaleChanged(); void onAbsorptionLinearChanged(); void onAbsorptionConstantChanged(); - - void onMaxAltitudeChanged(); + void onAbsorptionMaxAltitudeChanged(); // update the settings for our profile type void updateProfile(); diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml index 5159a2714e..50663e94f6 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml @@ -22,7 +22,7 @@ auto_resize="true" user_resize="true" visible="true" - height="16"> + height="14"> @@ -81,6 +81,20 @@ width="400" label_width="160" can_edit_text="true"/> + + height="16"> @@ -161,6 +175,20 @@ width="400" label_width="160" can_edit_text="true"/> + + height="14"> - - -- cgit v1.2.3 From 451ab80ca65a7ae75316442086f42b6553ea6bbe Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Thu, 6 Sep 2018 22:50:26 +0100 Subject: Fix tex format mismatch between what libatmosphere was generating and what we were claiming to use in rendering. First pass at sky shader using libatmosphere sky radiance lookup. Add atmo density controls to ext daycycle floater tabs. --- indra/llrender/llatmosphere.cpp | 45 +++++++++++++++++--- indra/llrender/llrender.cpp | 10 +---- indra/newview/app_settings/settings.xml | 2 +- .../app_settings/shaders/class3/deferred/skyF.glsl | 49 ++++++++++------------ .../app_settings/shaders/class3/deferred/skyV.glsl | 14 ++----- indra/newview/lldrawpoolwlsky.cpp | 20 ++++----- indra/newview/llenvironment.cpp | 3 ++ indra/newview/llfloatereditextdaycycle.cpp | 13 +++++- indra/newview/llfloaterfixedenvironment.cpp | 16 ++++--- indra/newview/llpaneleditsky.cpp | 2 - .../default/xui/en/floater_edit_ext_day_cycle.xml | 9 ++++ 11 files changed, 109 insertions(+), 74 deletions(-) diff --git a/indra/llrender/llatmosphere.cpp b/indra/llrender/llatmosphere.cpp index 4fd9764e07..aaa1ff65e1 100644 --- a/indra/llrender/llatmosphere.cpp +++ b/indra/llrender/llatmosphere.cpp @@ -34,8 +34,6 @@ #include "llshadermgr.h" #include "llglslshader.h" -#pragma optimize("", off) - LLAtmosphere* gAtmosphere = nullptr; // Values from "Reference Solar Spectral Irradiance: ASTM G-173", ETR column @@ -234,6 +232,26 @@ LLAtmosphere::~LLAtmosphere() m_model = nullptr; } +#if DEBUG_ATMO_TEX_GEN +uint8_t* GetTexture2d(int width, int height, int components, GLuint texture) +{ + glActiveTextureARB(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_2D, texture); + uint8_t* storage = (uint8_t*)malloc(width * height * components * sizeof(float)); + glGetTexImage(GL_TEXTURE_2D, 0, components == 3 ? GL_RGB : GL_RGBA, GL_FLOAT, storage); + return storage; +} + +uint8_t* GetTexture3d(int width, int height, int depth, int components, GLuint texture) +{ + glActiveTextureARB(GL_TEXTURE0); + glBindTexture(GL_TEXTURE_3D, texture); + uint8_t* storage = (uint8_t*)malloc(width * height * depth * components * sizeof(float)); + glGetTexImage(GL_TEXTURE_3D, 0, components == 3 ? GL_RGB : GL_RGBA, GL_FLOAT, storage); + return storage; +} +#endif + bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) { if ((m_model != nullptr) && (settings == m_settings)) @@ -256,6 +274,7 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) m_config.num_scattering_orders = 4; m_model = new atmosphere::Model( + m_config, m_wavelengths, m_solar_irradiance, settings.m_sunArcRadians, @@ -273,8 +292,9 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) max_sun_zenith_angle, 1000.0, 3, - false, - true); + false, // do not combine_scattering...we want indep textures + false, // use 32F for 2d textures to avoid artifacts + true); // use 16F for 3d textures to reduce footprint if (m_model) { @@ -283,6 +303,19 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) getScattering()->setTexName(m_textures.scattering_texture); getMieScattering()->setTexName(m_textures.single_mie_scattering_texture); getIlluminance()->setTexName(m_textures.illuminance_texture); + +#if DEBUG_ATMO_TEX_GEN + // for debug only... + U8* transmittance = GetTexture2d(m_config.transmittanceTextureWidth, m_config.transmittanceTextureHeight, 3, m_textures.transmittance_texture); + U8* scattering = GetTexture3d(m_config.scatteringTextureWidth, m_config.scatteringTextureHeight, m_config.scatteringTextureDepth, 3, m_textures.scattering_texture); + U8* single_mie_scattering = GetTexture3d(m_config.scatteringTextureWidth, m_config.scatteringTextureHeight, m_config.scatteringTextureDepth, 3, m_textures.single_mie_scattering_texture); + U8* illuminance = GetTexture2d(m_config.illuminanceTextureWidth, m_config.illuminanceTextureHeight, 3, m_textures.illuminance_texture); + free(transmittance); + free(scattering); + free(single_mie_scattering); + free(illuminance); +#endif + } return m_model != nullptr; @@ -296,7 +329,7 @@ LLGLTexture* LLAtmosphere::getTransmittance() m_transmittance->generateGLTexture(); m_transmittance->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP); m_transmittance->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR); - m_transmittance->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT); + m_transmittance->setExplicitFormat(GL_RGB32F_ARB, GL_RGB, GL_FLOAT); m_transmittance->setTarget(GL_TEXTURE_2D, LLTexUnit::TT_TEXTURE); } return m_transmittance; @@ -338,7 +371,7 @@ LLGLTexture* LLAtmosphere::getIlluminance() m_illuminance->generateGLTexture(); m_illuminance->setAddressMode(LLTexUnit::eTextureAddressMode::TAM_CLAMP); m_illuminance->setFilteringOption(LLTexUnit::eTextureFilterOptions::TFO_BILINEAR); - m_illuminance->setExplicitFormat(GL_RGB16F_ARB, GL_RGB, GL_FLOAT); + m_illuminance->setExplicitFormat(GL_RGB32F_ARB, GL_RGB, GL_FLOAT); m_illuminance->setTarget(GL_TEXTURE_2D, LLTexUnit::TT_TEXTURE); } return m_illuminance; diff --git a/indra/llrender/llrender.cpp b/indra/llrender/llrender.cpp index 67898f1258..251c02dd77 100644 --- a/indra/llrender/llrender.cpp +++ b/indra/llrender/llrender.cpp @@ -1241,16 +1241,10 @@ void LLRender::syncMatrices() } if (shader->getUniformLocation(LLShaderMgr::INVERSE_MODELVIEW_MATRIX)) - { - glh::matrix4f ogl_to_cfr = copy_matrix((F32*)OGL_TO_CFR_ROTATION); - glh::matrix4f modelview = ogl_to_cfr.inverse() * get_current_modelview(); - - glh::matrix4f inv_modelview = modelview.inverse(); - shader->uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_MATRIX, 1, FALSE, inv_modelview.m); + { + shader->uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_MATRIX, 1, GL_FALSE, cached_inv_mdv.m); } - shader->uniformMatrix4fv(LLShaderMgr::INVERSE_MODELVIEW_MATRIX, 1, GL_FALSE, cached_inv_mdv.m); - //update MVP matrix mvp_done = true; loc = shader->getUniformLocation(LLShaderMgr::MODELVIEW_PROJECTION_MATRIX); diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index e32eeb4779..8f4faf51da 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10165,7 +10165,7 @@ Type Boolean Value - 1 + 0 RenderUseTriStrips diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl index 01c873584f..ef94190d45 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl @@ -24,17 +24,19 @@ */ #ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_color; +out vec4 frag_data[4]; #else -#define frag_color gl_FragColor +#define frag_data gl_FragData #endif -in vec3 view_pos; -in vec3 view_dir; +VARYING vec2 vary_frag; -uniform vec3 cameraPosLocal; +uniform vec3 camPosLocal; uniform vec3 sun_dir; uniform float sun_size; +uniform float far_z; +uniform mat4 inv_proj; +uniform mat4 inv_modelview; uniform sampler2D transmittance_texture; uniform sampler3D scattering_texture; @@ -44,42 +46,33 @@ uniform sampler2D irradiance_texture; vec3 GetSolarLuminance(); vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 dir, out vec3 transmittance); vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 dir, out vec3 transmittance); -vec3 GetSunAndSkyIlluminance(vec3 pos, vec3 norm, vec3 dir, out vec3 sky_irradiance); void main() { - vec3 view_direction = normalize(view_dir); + vec3 pos = vec3((vary_frag * 2.0) - vec2(1.0, 1.0), 0.0); + vec4 view_pos = (inv_proj * vec4(pos, 1.0f)); + view_pos /= view_pos.w; + vec3 view_ray = (inv_modelview * vec4(view_pos.xyz, 0.0f)).xyz; - vec3 sun_direction = sun_dir; + vec3 view_direction = normalize(view_ray); + vec3 sun_direction = normalize(sun_dir); - vec3 camPos = cameraPosLocal + vec3(0, 0, 6360.0f); + vec3 camPos = (camPosLocal / 1000.0f) + vec3(0, 0, 6360.0f); vec3 transmittance; - vec3 sky_illum; - - vec3 radiance_sun = GetSkyLuminance(camPos, view_direction, 0.0f, sun_direction, transmittance); - vec3 radiance2_sun = GetSunAndSkyIlluminance(camPos, view_direction, sun_direction, sky_illum); - - radiance_sun *= transmittance; - + vec3 radiance_sun = GetSkyLuminance(camPos, view_direction, 0.0f, sun_direction, transmittance); vec3 solar_luminance = transmittance * GetSolarLuminance(); // If the view ray intersects the Sun, add the Sun radiance. if (dot(view_direction, sun_direction) >= sun_size) { - radiance_sun = radiance_sun + solar_luminance; + radiance_sun += solar_luminance; } - vec3 color = radiance_sun; - - color = vec3(1.0) - exp(-color * 0.0001); - - //float d = dot(view_direction, sun_direction); - //frag_color.rgb = vec3(d, d >= sun_size ? 1.0f : 0.0f, 0.0f); - - frag_color.rgb = color; - //frag_color.rgb = vec3(dot(view_direction, sun_direction) > 0.95f ? 1.0 : 0.0, 0,0); - //frag_color.rgb = normalize(view_pos); + vec3 color = vec3(1.0) - exp(-radiance_sun * 0.0001); + color = pow(color, vec3(1.0 / 2.2)); - frag_color.a = 1.0; + frag_data[0] = vec4(color, 1.0); + frag_data[1] = vec4(0.0); + frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl index cf3eb658fc..90217aed02 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl @@ -30,22 +30,14 @@ uniform mat4 inv_proj; uniform mat4 inv_modelview; ATTRIBUTE vec3 position; +ATTRIBUTE vec2 texcoord0; -// Inputs -uniform vec3 camPosLocal; - -out vec3 view_pos; -out vec3 view_dir; +VARYING vec2 vary_frag; void main() { // pass through untransformed fullscreen pos (clipspace) gl_Position = vec4(position.xyz, 1.0); - - view_pos = (inv_proj * vec4(position, 1.0f)).xyz; - - // this will be normalized in the frag shader... - //view_dir = (inv_modelview * view_pos).xyz; - view_dir = view_pos - camPosLocal; + vary_frag = texcoord0; } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 8a2941e20a..3b3d67243a 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -93,6 +93,10 @@ void LLDrawPoolWLSky::beginRenderPass( S32 pass ) void LLDrawPoolWLSky::endRenderPass( S32 pass ) { + sky_shader = nullptr; + cloud_shader = nullptr; + sun_shader = nullptr; + moon_shader = nullptr; } void LLDrawPoolWLSky::beginDeferredPass(S32 pass) @@ -113,7 +117,10 @@ void LLDrawPoolWLSky::beginDeferredPass(S32 pass) void LLDrawPoolWLSky::endDeferredPass(S32 pass) { - + sky_shader = nullptr; + cloud_shader = nullptr; + sun_shader = nullptr; + moon_shader = nullptr; } void LLDrawPoolWLSky::renderFsSky(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const @@ -167,8 +174,8 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->bindTexture(LLShaderMgr::ILLUMINANCE_TEX, gAtmosphere->getIlluminance()); LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLVector4 sun_dir = LLEnvironment::instance().getClampedSunNorm(); - LLVector4 moon_dir = LLEnvironment::instance().getClampedMoonNorm(); + LLVector3 sun_dir = LLEnvironment::instance().getSunDirection(); + LLVector3 moon_dir = LLEnvironment::instance().getMoonDirection(); F32 sunSize = (float)cosf(psky->getSunArcRadians()); sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize); @@ -182,13 +189,6 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m); - /* clouds are rendered along with sky in adv atmo - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && gSky.mVOSkyp->getCloudNoiseTex()) - { - sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, gSky.mVOSkyp->getCloudNoiseTex()); - sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, gSky.mVOSkyp->getCloudNoiseTexNext()); - }*/ - sky_shader->uniform3f(sCamPosLocal, camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]); renderFsSky(camPosLocal, camHeightLocal, sky_shader); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index 3a1aec6319..e437003520 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -1633,12 +1633,15 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mSky->update(); mBlenderSky.reset(); +#if 0 if (gAtmosphere) { AtmosphericModelSettings settings; LLEnvironment::getAtmosphericModelSettings(settings, psky); gAtmosphere->configureAtmosphericModel(settings); } +#endif + } void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index ed60dd4303..7d20a27813 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -62,6 +62,8 @@ #include "llenvironment.h" #include "lltrans.h" +extern LLControlGroup gSavedSettings; + //========================================================================= namespace { const std::string track_tabs[] = { @@ -821,10 +823,17 @@ void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) { panel->setSky(p_sky); } - panel = dynamic_cast(tab_container->getChildView("advanced_atmo_panel")); + panel = dynamic_cast(tab_container->getChildView("density_panel")); if (panel) { - panel->setSky(p_sky); + if (gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics")) + { + panel->setSky(p_sky); + } + else + { + panel->setVisible(false); + } } } diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index d38098c0a6..1104717dc1 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -55,6 +55,8 @@ #include "llsettingsvo.h" #include "llinventorymodel.h" +extern LLControlGroup gSavedSettings; + namespace { const std::string FIELD_SETTINGS_NAME("settings_name"); @@ -599,12 +601,14 @@ BOOL LLFloaterFixedEnvironmentSky::postBuild() panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); - panel = new LLPanelSettingsSkyDensityTab; - panel->buildFromFile("panel_settings_sky_density.xml"); - panel->setSky(std::static_pointer_cast(mSettings)); - panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); - mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); - + if (gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics")) + { + panel = new LLPanelSettingsSkyDensityTab; + panel->buildFromFile("panel_settings_sky_density.xml"); + panel->setSky(std::static_pointer_cast(mSettings)); + panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); + mTab->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); + } return TRUE; } diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index 451e15c73d..a13efbc54b 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -37,8 +37,6 @@ #include "llenvironment.h" #include "llatmosphere.h" -#pragma optimize("", off) - namespace { // Atmosphere Tab diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml index c8843db28b..7a5c9cb63f 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -520,6 +520,15 @@ Select a key frame from the timeline above to edit settings. left_delta="0" top_pad="5" name="moon_panel" /> + -- cgit v1.2.3 From 4bd2b8b98ba1c562dfd65975a87ef5ee3db35633 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Fri, 7 Sep 2018 17:24:29 +0100 Subject: Fix createDensityProfileLayer dropping passed in values. Enable sky density panel to update advanced atmo precomputed textures. Take wild stab at appropriate ranges for density parameters in edit panel UI. Clean up debug-only code that isn't necessary anymore. Point autobuild at latest version of libatmosphere package. --- autobuild.xml | 16 ++--- indra/llinventory/llsettingssky.cpp | 23 +++---- indra/llrender/llatmosphere.cpp | 36 +---------- .../app_settings/shaders/class3/deferred/skyV.glsl | 4 +- indra/newview/lldrawpoolwlsky.cpp | 19 +++--- indra/newview/llenvironment.cpp | 4 +- indra/newview/llpaneleditsky.cpp | 3 - .../default/xui/en/panel_settings_sky_density.xml | 73 +++++++++++----------- 8 files changed, 66 insertions(+), 112 deletions(-) diff --git a/autobuild.xml b/autobuild.xml index b5e336948a..bd1b88b2eb 100644 --- a/autobuild.xml +++ b/autobuild.xml @@ -64,9 +64,9 @@ archive hash - 722693009586e18aa4d611218c26c5e3 + bca20bcdf1a2c26b16e71fb2c1316cbe url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/23969/184338/libatmosphere-1.0.0.100-darwin-519274.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/24187/188163/libatmosphere-1.0.0.100-darwin-519422.tar.bz2 name darwin @@ -76,9 +76,9 @@ archive hash - 9ecdbb77a18a5dea905ebd3d7faf1f8f + 9ce4c97f1eda8caa556573abd6e1ebd0 url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/23968/184333/libatmosphere-1.0.0.100-darwin64-519274.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/24188/188166/libatmosphere-1.0.0.100-darwin64-519422.tar.bz2 name darwin64 @@ -88,9 +88,9 @@ archive hash - 05e113c2988bf77dcde7df0216c26481 + 6a61502ab1cca316f85310ded8bf9b9a url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/23971/184350/libatmosphere-1.0.0.100-windows-519274.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/24190/188181/libatmosphere-1.0.0.100-windows-519422.tar.bz2 name windows @@ -100,9 +100,9 @@ archive hash - 1b5fcfbc0123263d68843ac4570c8204 + 496410cb43e03ddf1777cd295c2d5dba url - http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/23970/184345/libatmosphere-1.0.0.100-windows64-519274.tar.bz2 + http://automated-builds-secondlife-com.s3.amazonaws.com/ct2/24189/188175/libatmosphere-1.0.0.100-windows64-519422.tar.bz2 name windows64 diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index ba92a82174..ed8baee204 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -573,11 +573,11 @@ LLSD LLSettingsSky::createDensityProfileLayer( F32 aniso_factor) { LLSD dflt_layer; - dflt_layer[SETTING_DENSITY_PROFILE_WIDTH] = 0.0f; // 0 -> the entire atmosphere - dflt_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = 1.0f; - dflt_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = -1.0f / 8000.0f; - dflt_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = 0.0f; - dflt_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = 0.0f; + dflt_layer[SETTING_DENSITY_PROFILE_WIDTH] = width; // 0 -> the entire atmosphere + dflt_layer[SETTING_DENSITY_PROFILE_EXP_TERM] = exponential_term; + dflt_layer[SETTING_DENSITY_PROFILE_EXP_SCALE_FACTOR] = exponential_scale_factor; + dflt_layer[SETTING_DENSITY_PROFILE_LINEAR_TERM] = linear_term; + dflt_layer[SETTING_DENSITY_PROFILE_CONSTANT_TERM] = constant_term; if (aniso_factor != 0.0f) { @@ -670,7 +670,7 @@ LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position) dfltsetting[SETTING_PLANET_RADIUS] = 6360.0f; dfltsetting[SETTING_SKY_BOTTOM_RADIUS] = 6360.0f; dfltsetting[SETTING_SKY_TOP_RADIUS] = 6420.0f; - dfltsetting[SETTING_SUN_ARC_RADIANS] = 0.00935f / 2.0f; + dfltsetting[SETTING_SUN_ARC_RADIANS] = 0.00045f; dfltsetting[SETTING_RAYLEIGH_CONFIG] = rayleighConfigDefault(); dfltsetting[SETTING_MIE_CONFIG] = mieConfigDefault(); @@ -1160,7 +1160,7 @@ F32 LLSettingsSky::getSunArcRadians() const F32 LLSettingsSky::getMieAnisotropy() const { - return mSettings[SETTING_MIE_ANISOTROPY_FACTOR].asReal(); + return getMieConfig()[SETTING_MIE_ANISOTROPY_FACTOR].asReal(); } LLSD LLSettingsSky::getRayleighConfig() const @@ -1183,20 +1183,17 @@ LLSD LLSettingsSky::getAbsorptionConfig() const LLSD LLSettingsSky::getRayleighConfigs() const { - LLSD copy = *(mSettings[SETTING_RAYLEIGH_CONFIG].beginArray()); - return copy; + return mSettings[SETTING_RAYLEIGH_CONFIG]; } LLSD LLSettingsSky::getMieConfigs() const { - LLSD copy = *(mSettings[SETTING_MIE_CONFIG].beginArray()); - return copy; + return mSettings[SETTING_MIE_CONFIG]; } LLSD LLSettingsSky::getAbsorptionConfigs() const { - LLSD copy = *(mSettings[SETTING_ABSORPTION_CONFIG].beginArray()); - return copy; + return mSettings[SETTING_ABSORPTION_CONFIG]; } void LLSettingsSky::setRayleighConfigs(const LLSD& rayleighConfig) diff --git a/indra/llrender/llatmosphere.cpp b/indra/llrender/llatmosphere.cpp index aaa1ff65e1..12c6685354 100644 --- a/indra/llrender/llatmosphere.cpp +++ b/indra/llrender/llatmosphere.cpp @@ -232,26 +232,6 @@ LLAtmosphere::~LLAtmosphere() m_model = nullptr; } -#if DEBUG_ATMO_TEX_GEN -uint8_t* GetTexture2d(int width, int height, int components, GLuint texture) -{ - glActiveTextureARB(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_2D, texture); - uint8_t* storage = (uint8_t*)malloc(width * height * components * sizeof(float)); - glGetTexImage(GL_TEXTURE_2D, 0, components == 3 ? GL_RGB : GL_RGBA, GL_FLOAT, storage); - return storage; -} - -uint8_t* GetTexture3d(int width, int height, int depth, int components, GLuint texture) -{ - glActiveTextureARB(GL_TEXTURE0); - glBindTexture(GL_TEXTURE_3D, texture); - uint8_t* storage = (uint8_t*)malloc(width * height * depth * components * sizeof(float)); - glGetTexImage(GL_TEXTURE_3D, 0, components == 3 ? GL_RGB : GL_RGBA, GL_FLOAT, storage); - return storage; -} -#endif - bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) { if ((m_model != nullptr) && (settings == m_settings)) @@ -271,8 +251,6 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) getIlluminance()->setTexName(0); // Init libatmosphere model - m_config.num_scattering_orders = 4; - m_model = new atmosphere::Model( m_config, m_wavelengths, @@ -303,19 +281,7 @@ bool LLAtmosphere::configureAtmosphericModel(AtmosphericModelSettings& settings) getScattering()->setTexName(m_textures.scattering_texture); getMieScattering()->setTexName(m_textures.single_mie_scattering_texture); getIlluminance()->setTexName(m_textures.illuminance_texture); - -#if DEBUG_ATMO_TEX_GEN - // for debug only... - U8* transmittance = GetTexture2d(m_config.transmittanceTextureWidth, m_config.transmittanceTextureHeight, 3, m_textures.transmittance_texture); - U8* scattering = GetTexture3d(m_config.scatteringTextureWidth, m_config.scatteringTextureHeight, m_config.scatteringTextureDepth, 3, m_textures.scattering_texture); - U8* single_mie_scattering = GetTexture3d(m_config.scatteringTextureWidth, m_config.scatteringTextureHeight, m_config.scatteringTextureDepth, 3, m_textures.single_mie_scattering_texture); - U8* illuminance = GetTexture2d(m_config.illuminanceTextureWidth, m_config.illuminanceTextureHeight, 3, m_textures.illuminance_texture); - free(transmittance); - free(scattering); - free(single_mie_scattering); - free(illuminance); -#endif - + m_settings = settings; } return m_model != nullptr; diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl index 90217aed02..89873e83ca 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl @@ -36,8 +36,8 @@ VARYING vec2 vary_frag; void main() { - // pass through untransformed fullscreen pos (clipspace) - gl_Position = vec4(position.xyz, 1.0); + // pass through untransformed fullscreen pos at back of frustum for proper sky depth testing + gl_Position = vec4(position.xy, 0.99f, 1.0); vary_frag = texcoord0; } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 3b3d67243a..41bf024942 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -505,22 +505,19 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) if (gPipeline.canUseWindLightShaders()) { + if (gPipeline.useAdvancedAtmospherics()) + { + renderSkyHazeDeferred(origin, camHeightLocal); + renderHeavenlyBodies(); + } + else { // Disable depth-test for sky, but re-enable depth writes for the cloud // rendering below so the cloud shader can write out depth for the stars to test against LLGLDepthTest depth(GL_TRUE, GL_FALSE); - if (gPipeline.useAdvancedAtmospherics()) - { - renderSkyHazeDeferred(origin, camHeightLocal); - } - else - { - renderSkyHaze(origin, camHeightLocal); - - } - renderHeavenlyBodies(); + renderSkyHaze(origin, camHeightLocal); + renderHeavenlyBodies(); } - renderSkyClouds(origin, camHeightLocal); } gGL.setColorMask(true, true); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index e437003520..4b60ed4e68 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -358,6 +358,7 @@ void LLEnvironment::getAtmosphericModelSettings(AtmosphericModelSettings& settin layer.width = layerConfig[LLSettingsSky::SETTING_DENSITY_PROFILE_WIDTH].asReal(); settingsOut.m_mieProfile.push_back(layer); } + settingsOut.m_mieAnisotropy = psky->getMieAnisotropy(); LLSD absorption = psky->getAbsorptionConfigs(); settingsOut.m_absorptionProfile.clear(); @@ -1633,15 +1634,12 @@ void LLEnvironment::DayInstance::setSky(const LLSettingsSky::ptr_t &psky) mSky->update(); mBlenderSky.reset(); -#if 0 if (gAtmosphere) { AtmosphericModelSettings settings; LLEnvironment::getAtmosphericModelSettings(settings, psky); gAtmosphere->configureAtmosphericModel(settings); } -#endif - } void LLEnvironment::DayInstance::setWater(const LLSettingsWater::ptr_t &pwater) diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index a13efbc54b..1b41529795 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -662,15 +662,12 @@ void LLPanelSettingsSkyDensityTab::updateProfile() mSkySettings->update(); setIsDirty(); -/* if (gAtmosphere) { AtmosphericModelSettings atmospheric_settings; LLEnvironment::getAtmosphericModelSettings(atmospheric_settings, mSkySettings); gAtmosphere->configureAtmosphericModel(atmospheric_settings); } -*/ - } void LLPanelSettingsSkyDensityTab::onRayleighExponentialChanged() diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml index 50663e94f6..e071b30c80 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_density.xml @@ -24,10 +24,10 @@ visible="true" height="14"> Date: Fri, 7 Sep 2018 19:03:52 +0100 Subject: Merge --- indra/newview/llfloaterfixedenvironment.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index 1104717dc1..fef3fabb4a 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -269,6 +269,7 @@ void LLFloaterFixedEnvironment::checkAndConfirmSettingsLoss(LLFloaterFixedEnviro LLNotificationsUtil::add("SettingsConfirmLoss", args, LLSD(), [this, cb](const LLSD¬if, const LLSD&resp) { + (void)this; S32 opt = LLNotificationsUtil::getSelectedOption(notif, resp); if (opt == 0) cb(); -- cgit v1.2.3 From e075c65ee22a54b114808057399b5c7546dfb08a Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 10 Sep 2018 16:43:49 +0100 Subject: First pass at preferences and feature table hookup for advanced atmospherics. --- indra/newview/featuretable.txt | 12 ++ indra/newview/featuretable_linux.txt | 13 ++ indra/newview/featuretable_mac.txt | 13 ++ indra/newview/lldrawpoolwlsky.cpp | 136 ++++++++++----------- indra/newview/llfloatereditextdaycycle.cpp | 33 ++++- indra/newview/llfloaterpreference.cpp | 19 ++- indra/newview/llfloaterpreference.h | 1 + indra/newview/pipeline.cpp | 4 +- .../en/floater_preferences_graphics_advanced.xml | 14 +++ 9 files changed, 167 insertions(+), 78 deletions(-) diff --git a/indra/newview/featuretable.txt b/indra/newview/featuretable.txt index e99b94f150..1d6fb82d10 100644 --- a/indra/newview/featuretable.txt +++ b/indra/newview/featuretable.txt @@ -66,6 +66,7 @@ RenderCompressTextures 1 1 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 1 RenderShadowDetail 1 2 RenderUseStreamVBO 1 1 RenderFSAASamples 1 16 @@ -98,6 +99,7 @@ VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -129,6 +131,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -159,6 +162,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -189,6 +193,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -219,6 +224,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -249,6 +255,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -279,6 +286,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -309,6 +317,7 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 1 RenderShadowDetail 1 2 RenderFSAASamples 1 2 @@ -320,6 +329,7 @@ RenderVBOEnable 1 0 RenderShadowDetail 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 // // Class 0 Hardware (just old) @@ -375,6 +385,7 @@ WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 RenderShadowDetail 0 0 +RenderUseAdvancedAtmospherics 0 0 // // No Vertex Shaders available @@ -388,6 +399,7 @@ WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 RenderShadowDetail 0 0 +RenderUseAdvancedAtmospherics 0 0 // // GL_ARB_map_buffer_range exists diff --git a/indra/newview/featuretable_linux.txt b/indra/newview/featuretable_linux.txt index 801a622e93..18feae162f 100644 --- a/indra/newview/featuretable_linux.txt +++ b/indra/newview/featuretable_linux.txt @@ -66,6 +66,7 @@ RenderCompressTextures 1 1 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 1 RenderShadowDetail 1 2 RenderFSAASamples 1 16 RenderMaxTextureIndex 1 16 @@ -97,6 +98,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -128,6 +130,7 @@ VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -158,6 +161,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -188,6 +192,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -217,6 +222,7 @@ RenderVolumeLODFactor 1 1.125 VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderDeferredSSAO 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 @@ -248,6 +254,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -278,6 +285,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 2 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -308,6 +316,7 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 1 RenderShadowDetail 1 2 RenderFSAASamples 1 2 @@ -319,6 +328,7 @@ RenderVBOEnable 1 0 RenderShadowDetail 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 // // Class 0 Hardware (just old) @@ -373,6 +383,7 @@ VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // @@ -386,6 +397,7 @@ VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // @@ -413,6 +425,7 @@ RenderReflectionDetail 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // diff --git a/indra/newview/featuretable_mac.txt b/indra/newview/featuretable_mac.txt index 1f891ee4d7..3f5edede98 100644 --- a/indra/newview/featuretable_mac.txt +++ b/indra/newview/featuretable_mac.txt @@ -66,6 +66,7 @@ RenderCompressTextures 1 1 RenderShaderLightingMaxLevel 1 3 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 1 RenderShadowDetail 1 2 RenderUseStreamVBO 1 1 RenderFSAASamples 1 16 @@ -98,6 +99,7 @@ VertexShaderEnable 1 0 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -129,6 +131,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -159,6 +162,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 0 @@ -189,6 +193,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -219,6 +224,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -249,6 +255,7 @@ VertexShaderEnable 1 1 WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 0 RenderShadowDetail 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -280,6 +287,7 @@ WindLightUseAtmosShaders 1 1 RenderDeferred 1 1 RenderDeferredSSAO 1 1 RenderShadowDetail 1 2 +RenderUseAdvancedAtmospherics 1 0 WLSkyDetail 1 48 RenderFSAASamples 1 2 @@ -309,6 +317,7 @@ WindLightUseAtmosShaders 1 1 WLSkyDetail 1 128 RenderDeferred 1 1 RenderDeferredSSAO 1 1 +RenderUseAdvancedAtmospherics 1 1 RenderShadowDetail 1 2 RenderFSAASamples 1 2 @@ -320,6 +329,7 @@ RenderVBOEnable 1 0 RenderShadowDetail 1 0 RenderDeferred 1 0 RenderDeferredSSAO 1 0 +RenderUseAdvancedAtmospherics 1 0 // // Class 0 Hardware (just old) @@ -368,6 +378,7 @@ VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // @@ -381,6 +392,7 @@ VertexShaderEnable 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // @@ -407,6 +419,7 @@ RenderReflectionDetail 0 0 WindLightUseAtmosShaders 0 0 RenderDeferred 0 0 RenderDeferredSSAO 0 0 +RenderUseAdvancedAtmospherics 0 0 RenderShadowDetail 0 0 // diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 41bf024942..0d49c5a339 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -230,10 +230,9 @@ void LLDrawPoolWLSky::renderStars(void) const // clamping and allow the star_alpha param to brighten the stars. LLColor4 star_alpha(LLColor4::black); - // *LAPRAS - star_alpha.mV[3] = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / (2.f + ((rand() >> 16)/65535.0f)); // twinkle twinkle - - // If start_brightness is not set, exit + star_alpha.mV[3] = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / 512.f; + + // If star brightness is not set, exit if( star_alpha.mV[3] < 0.001 ) { LL_DEBUGS("SKY") << "star_brightness below threshold." << LL_ENDL; @@ -293,9 +292,8 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const LLGLSPipelineSkyBox gls_sky; LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - - // *LAPRAS - F32 star_alpha = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / (2.f + ((rand() >> 16)/65535.0f)); // twinkle twinkle + + F32 star_alpha = LLEnvironment::instance().getCurrentSky()->getStarBrightness() / 512.0f; // If start_brightness is not set, exit if(star_alpha < 0.001f) @@ -332,6 +330,11 @@ void LLDrawPoolWLSky::renderStarsDeferred(void) const gDeferredStarProgram.uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); gDeferredStarProgram.uniform1f(sCustomAlpha, star_alpha); + + sStarTime = (F32)LLFrameTimer::getElapsedSeconds() * 0.5f; + + gDeferredStarProgram.uniform1f(LLShaderMgr::WATER_TIME, sStarTime); + gSky.mVOWLSkyp->drawStars(); gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); @@ -375,6 +378,8 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor(); bool can_use_vertex_shaders = gPipeline.canUseVertexShaders(); + bool can_use_windlight_shaders = gPipeline.canUseWindLightShaders(); + if (gSky.mVOSkyp->getSun().getDraw() && face && face->getGeomCount()) { @@ -388,45 +393,39 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() if (tex_a || tex_b) { // if and only if we have a texture defined, render the sun disc - if (can_use_vertex_shaders) - { - sun_shader->bind(); - } - - if (tex_a && (!tex_b || (tex_a == tex_b))) + if (can_use_vertex_shaders && can_use_windlight_shaders) { - // Bind current and next sun textures - sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); - blend_factor = 0; - } - else if (tex_b && !tex_a) - { - sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); - blend_factor = 0; - } - else if (tex_b != tex_a) - { - sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); - sun_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); - } - - LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor()); + sun_shader->bind(); + + if (tex_a && (!tex_b || (tex_a == tex_b))) + { + // Bind current and next sun textures + sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b && !tex_a) + { + sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b != tex_a) + { + sun_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + sun_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + } + + LLColor4 color(gSky.mVOSkyp->getSun().getInterpColor()); - if (can_use_vertex_shaders) - { sun_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); sun_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); - } - LLFacePool::LLOverrideFaceColor color_override(this, color); - face->renderIndexed(); + LLFacePool::LLOverrideFaceColor color_override(this, color); + face->renderIndexed(); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); - if (can_use_vertex_shaders) - { - sun_shader->unbind(); + sun_shader->unbind(); } } } @@ -440,46 +439,39 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor()); - if (can_use_vertex_shaders) - { - moon_shader->bind(); - } - - if (tex_a && (!tex_b || (tex_a == tex_b))) + if (can_use_vertex_shaders && can_use_windlight_shaders) { - // Bind current and next sun textures - moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); - blend_factor = 0; - } - else if (tex_b && !tex_a) - { - moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); - blend_factor = 0; - } - else if (tex_b != tex_a) - { - moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); - moon_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); - } + moon_shader->bind(); + + if (tex_a && (!tex_b || (tex_a == tex_b))) + { + // Bind current and next sun textures + moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b && !tex_a) + { + moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + blend_factor = 0; + } + else if (tex_b != tex_a) + { + moon_shader->bindTexture(LLShaderMgr::DIFFUSE_MAP, tex_a, LLTexUnit::TT_TEXTURE); + moon_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); + } - if (can_use_vertex_shaders) - { moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); - } - LLFacePool::LLOverrideFaceColor color_override(this, color); - - face->renderIndexed(); + LLFacePool::LLOverrideFaceColor color_override(this, color); + face->renderIndexed(); - gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); - gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(0)->unbind(LLTexUnit::TT_TEXTURE); + gGL.getTexUnit(1)->unbind(LLTexUnit::TT_TEXTURE); - if (can_use_vertex_shaders) - { - moon_shader->unbind(); - } - } + moon_shader->unbind(); + } + } gGL.popMatrix(); } diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 7b5a848188..d4f0c934e7 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -195,13 +195,30 @@ BOOL LLFloaterEditExtDayCycle::postBuild() LLTabContainer* tab_container = mSkyTabLayoutContainer->getChild("sky_tabs"); S32 tab_count = tab_container->getTabCount(); + LLSettingsEditPanel *panel = nullptr; for (S32 idx = 0; idx < tab_count; ++idx) { - LLSettingsEditPanel *panel = static_cast(tab_container->getPanelByIndex(idx)); + panel = static_cast(tab_container->getPanelByIndex(idx)); if (panel) panel->setOnDirtyFlagChanged([this](LLPanel *, bool val) { onPanelDirtyFlagChanged(val); }); } + panel = dynamic_cast(tab_container->getChildView("advanced_atmo_panel")); + if (panel) + { + if (gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics")) + { + panel->setEnabled(true); + panel->setAllChildrenEnabled(true); + } + else + { + panel->setEnabled(false); + panel->setAllChildrenEnabled(false); + panel->setVisible(false); + } + } + tab_container = mWaterTabLayoutContainer->getChild("water_tabs"); tab_count = tab_container->getTabCount(); @@ -833,6 +850,7 @@ void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) } else { + panel->setEnabled(false); panel->setVisible(false); } } @@ -875,8 +893,17 @@ void LLFloaterEditExtDayCycle::setSkyTabsEnabled(BOOL enable) panel = dynamic_cast(tab_container->getChildView("advanced_atmo_panel")); if (panel) { - panel->setEnabled(enable); - panel->setAllChildrenEnabled(enable); + if (gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics")) + { + panel->setEnabled(enable); + panel->setAllChildrenEnabled(enable); + } + else + { + panel->setEnabled(false); + panel->setAllChildrenEnabled(false); + panel->setVisible(false); + } } } diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 4ce35643b1..8a01eea912 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -811,6 +811,17 @@ void LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable() refreshEnabledGraphics(); } +void LLFloaterPreferenceGraphicsAdvanced::onAdvancedAtmosphericsEnable() +{ + LLFloaterPreference* instance = LLFloaterReg::findTypedInstance("preferences"); + if (instance) + { + instance->refresh(); + } + + refreshEnabledGraphics(); +} + void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledGraphics() { refreshEnabledState(); @@ -1351,6 +1362,11 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() ctrl_ssao->setEnabled(enabled); ctrl_dof->setEnabled(enabled); + LLCheckBoxCtrl* ctrl_advanced_atmo = getChild("UseAdvancedAtmo"); + + bool advanced_atmo_enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderUseAdvancedAtmospherics"); + ctrl_advanced_atmo->setEnabled(advanced_atmo_enabled); + enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"); ctrl_shadow->setEnabled(enabled); @@ -2714,7 +2730,8 @@ void LLPanelPreferenceGraphics::setHardwareDefaults() LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const LLSD& key) : LLFloater(key) { - mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this)); + mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this)); + mCommitCallbackRegistrar.add("Pref.AdvancedAtmosphericsEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onAdvancedAtmosphericsEnable, this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this)); } diff --git a/indra/newview/llfloaterpreference.h b/indra/newview/llfloaterpreference.h index 8339a18296..973ca25c37 100644 --- a/indra/newview/llfloaterpreference.h +++ b/indra/newview/llfloaterpreference.h @@ -295,6 +295,7 @@ class LLFloaterPreferenceGraphicsAdvanced : public LLFloater void refresh(); // callback for when client turns on shaders void onVertexShaderEnable(); + void onAdvancedAtmosphericsEnable(); LOG_CLASS(LLFloaterPreferenceGraphicsAdvanced); }; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index bfb7eb3f6a..d265ba9fb8 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -424,8 +424,7 @@ void LLPipeline::init() gOctreeMinSize = gSavedSettings.getF32("OctreeMinimumNodeSize"); sDynamicLOD = gSavedSettings.getBOOL("RenderDynamicLOD"); sRenderBump = gSavedSettings.getBOOL("RenderObjectBump"); - sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips"); - sUseAdvancedAtmospherics = gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics"); + sUseTriStrips = gSavedSettings.getBOOL("RenderUseTriStrips"); LLVertexBuffer::sUseStreamDraw = gSavedSettings.getBOOL("RenderUseStreamVBO"); LLVertexBuffer::sUseVAO = gSavedSettings.getBOOL("RenderUseVAO"); LLVertexBuffer::sPreferStreamDraw = gSavedSettings.getBOOL("RenderPreferStreamDraw"); @@ -1049,6 +1048,7 @@ void LLPipeline::refreshCachedSettings() RenderAvatarVP = gSavedSettings.getBOOL("RenderAvatarVP"); WindLightUseAtmosShaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders"); RenderDeferred = gSavedSettings.getBOOL("RenderDeferred"); + sUseAdvancedAtmospherics = gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics"); RenderDeferredSunWash = gSavedSettings.getF32("RenderDeferredSunWash"); RenderFSAASamples = gSavedSettings.getU32("RenderFSAASamples"); RenderResolutionDivisor = gSavedSettings.getU32("RenderResolutionDivisor"); diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index c2500951a6..d9bbf32583 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -819,6 +819,20 @@ function="Pref.VertexShaderEnable" /> + + + + Date: Mon, 10 Sep 2018 20:39:48 +0100 Subject: Fixes for switching between atmospherics implementations on the fly. --- .../app_settings/shaders/class3/deferred/skyF.glsl | 2 +- indra/newview/lldrawpoolwlsky.cpp | 28 +++++++----- indra/newview/llfloatereditextdaycycle.cpp | 53 +++++++++++++++++++++- indra/newview/llfloaterfixedenvironment.cpp | 2 + indra/newview/llviewercontrol.cpp | 12 +++++ indra/newview/llviewershadermgr.cpp | 10 ++-- indra/newview/pipeline.cpp | 2 +- .../default/xui/en/floater_edit_ext_day_cycle.xml | 2 + 8 files changed, 90 insertions(+), 21 deletions(-) diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl index ef94190d45..cd0efe8cbb 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl @@ -24,7 +24,7 @@ */ #ifdef DEFINE_GL_FRAGCOLOR -out vec4 frag_data[4]; +out vec4 frag_data[3]; #else #define frag_data gl_FragData #endif diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 0d49c5a339..205b6441e7 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -163,7 +163,7 @@ void LLDrawPoolWLSky::renderDome(const LLVector3& camPosLocal, F32 camHeightLoca void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const { - if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders() && gAtmosphere) + if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders()) { sky_shader->bind(); @@ -192,7 +192,7 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->uniform3f(sCamPosLocal, camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]); renderFsSky(camPosLocal, camHeightLocal, sky_shader); - + sky_shader->unbind(); } } @@ -497,18 +497,22 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) if (gPipeline.canUseWindLightShaders()) { - if (gPipeline.useAdvancedAtmospherics()) { - renderSkyHazeDeferred(origin, camHeightLocal); - renderHeavenlyBodies(); - } - else - { - // Disable depth-test for sky, but re-enable depth writes for the cloud - // rendering below so the cloud shader can write out depth for the stars to test against LLGLDepthTest depth(GL_TRUE, GL_FALSE); - renderSkyHaze(origin, camHeightLocal); - renderHeavenlyBodies(); + + if (gPipeline.useAdvancedAtmospherics()) + { + //LLGLSquashToFarClip far_clip(get_current_projection()); + renderSkyHazeDeferred(origin, camHeightLocal); + } + else + { + // Disable depth-test for sky, but re-enable depth writes for the cloud + // rendering below so the cloud shader can write out depth for the stars to test against + renderSkyHaze(origin, camHeightLocal); + + } + renderHeavenlyBodies(); } renderSkyClouds(origin, camHeightLocal); } diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 18a7c1d242..8e29e4cf32 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -62,6 +62,8 @@ #include "llenvironment.h" #include "lltrans.h" +#pragma optimize("", off) + extern LLControlGroup gSavedSettings; //========================================================================= @@ -198,9 +200,33 @@ BOOL LLFloaterEditExtDayCycle::postBuild() LLTabContainer* tab_container = mSkyTabLayoutContainer->getChild("sky_tabs"); S32 tab_count = tab_container->getTabCount(); + LLSettingsEditPanel *panel = nullptr; + + // Add or remove density tab as necessary + // Must be before operation on all tabs below + if (gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics")) + { + panel = dynamic_cast(tab_container->getChildView("panel_settings_sky_density")); + if (!panel) + { + panel = new LLPanelSettingsSkyDensityTab; + panel->buildFromFile("panel_settings_sky_density.xml"); + tab_container->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); + } + } + else + { + panel = dynamic_cast(tab_container->getChildView("panel_settings_sky_density")); + if (panel) + { + tab_container->removeTabPanel(panel); + } + delete panel; + } + for (S32 idx = 0; idx < tab_count; ++idx) { - LLSettingsEditPanel *panel = static_cast(tab_container->getPanelByIndex(idx)); + panel = static_cast(tab_container->getPanelByIndex(idx)); if (panel) panel->setOnDirtyFlagChanged([this](LLPanel *, bool val) { onPanelDirtyFlagChanged(val); }); } @@ -813,7 +839,7 @@ void LLFloaterEditExtDayCycle::updateWaterTabs(const LLSettingsWaterPtr_t &p_wat void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) { - LLView* tab_container = mSkyTabLayoutContainer->getChild(TABS_SKYS); //can't extract panels directly, since they are in 'tuple' + LLTabContainer* tab_container = mSkyTabLayoutContainer->getChild(TABS_SKYS); //can't extract panels directly, since they are in 'tuple' LLPanelSettingsSky* panel; panel = dynamic_cast(tab_container->getChildView("atmosphere_panel")); @@ -831,6 +857,29 @@ void LLFloaterEditExtDayCycle::updateSkyTabs(const LLSettingsSkyPtr_t &p_sky) { panel->setSky(p_sky); } + + if (gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics")) + { + panel = dynamic_cast(tab_container->getChildView("panel_settings_sky_density")); + if (!panel) + { + panel = new LLPanelSettingsSkyDensityTab; + panel->buildFromFile("panel_settings_sky_density.xml"); + panel->setOnDirtyFlagChanged([this](LLPanel *, bool value) { onPanelDirtyFlagChanged(value); }); + tab_container->addTabPanel(LLTabContainer::TabPanelParams().panel(panel).select_tab(false)); + } + panel->setSky(std::static_pointer_cast(p_sky)); + } + else + { + panel = dynamic_cast(tab_container->getChildView("panel_settings_sky_density")); + if (panel) + { + tab_container->removeTabPanel(panel); + } + delete panel; + } + } void LLFloaterEditExtDayCycle::updateButtons() diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index 09a05eb7e2..e5d6412218 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -55,6 +55,8 @@ #include "llsettingsvo.h" #include "llinventorymodel.h" +#pragma optimize("", off) + extern LLControlGroup gSavedSettings; namespace diff --git a/indra/newview/llviewercontrol.cpp b/indra/newview/llviewercontrol.cpp index 88984d518a..ebc55fa0dd 100644 --- a/indra/newview/llviewercontrol.cpp +++ b/indra/newview/llviewercontrol.cpp @@ -410,6 +410,17 @@ static bool handleRenderDeferredChanged(const LLSD& newvalue) return true; } +static bool handleRenderUseAdvancedAtmosphericsChanged(const LLSD& newvalue) +{ + if (gPipeline.isInit()) + { + LLPipeline::refreshCachedSettings(); + // Need to reload shaders when changing atmospherics implementations... + LLViewerShaderMgr::instance()->setShaders(); + } + return true; +} + // This looks a great deal like handleRenderDeferredChanged because // Advanced Lighting (Materials) implies bumps and shiny so disabling // bumps should further disable that feature. @@ -644,6 +655,7 @@ void settings_setup_listeners() gSavedSettings.getControl("RenderDebugPipeline")->getSignal()->connect(boost::bind(&handleRenderDebugPipelineChanged, _2)); gSavedSettings.getControl("RenderResolutionDivisor")->getSignal()->connect(boost::bind(&handleRenderResolutionDivisorChanged, _2)); gSavedSettings.getControl("RenderDeferred")->getSignal()->connect(boost::bind(&handleRenderDeferredChanged, _2)); + gSavedSettings.getControl("RenderUseAdvancedAtmospherics")->getSignal()->connect(boost::bind(&handleRenderUseAdvancedAtmosphericsChanged, _2)); gSavedSettings.getControl("RenderShadowDetail")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); gSavedSettings.getControl("RenderDeferredSSAO")->getSignal()->connect(boost::bind(&handleSetShaderChanged, _2)); gSavedSettings.getControl("RenderPerformanceTest")->getSignal()->connect(boost::bind(&handleRenderPerfTestChanged, _2)); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index cd378c0a56..5e7e87c163 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -2139,7 +2139,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; gDeferredWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; - if (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3) + if (mVertexShaderLevel[SHADER_WINDLIGHT] > 1) { gDeferredWLSkyProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink(); } @@ -3537,13 +3537,13 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() return TRUE; } - if (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3) + if (mVertexShaderLevel[SHADER_WINDLIGHT] > 1) { // Prepare precomputed atmospherics textures using libatmosphere LLAtmosphere::initClass(); } - if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] < 3)) + if (success) { gWLSkyProgram.mName = "Windlight Sky Shader"; //gWLSkyProgram.mFeatures.hasGamma = true; @@ -3567,7 +3567,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() success = gWLCloudProgram.createShader(NULL, NULL); } - if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] < 3)) + if (success) { gWLSunProgram.mName = "Windlight Sun Program"; gWLSunProgram.mShaderFiles.clear(); @@ -3585,7 +3585,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() success = gWLSunProgram.createShader(NULL, NULL); } - if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] < 3)) + if (success) { gWLMoonProgram.mName = "Windlight Moon Program"; gWLMoonProgram.mShaderFiles.clear(); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d265ba9fb8..1522403990 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -1048,7 +1048,7 @@ void LLPipeline::refreshCachedSettings() RenderAvatarVP = gSavedSettings.getBOOL("RenderAvatarVP"); WindLightUseAtmosShaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders"); RenderDeferred = gSavedSettings.getBOOL("RenderDeferred"); - sUseAdvancedAtmospherics = gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics"); + sUseAdvancedAtmospherics = WindLightUseAtmosShaders && gSavedSettings.getBOOL("RenderUseAdvancedAtmospherics"); RenderDeferredSunWash = gSavedSettings.getF32("RenderDeferredSunWash"); RenderFSAASamples = gSavedSettings.getU32("RenderFSAASamples"); RenderResolutionDivisor = gSavedSettings.getU32("RenderResolutionDivisor"); diff --git a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml index 7a5c9cb63f..aec71fda07 100644 --- a/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml +++ b/indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml @@ -520,6 +520,7 @@ Select a key frame from the timeline above to edit settings. left_delta="0" top_pad="5" name="moon_panel" /> + -- cgit v1.2.3 From 8a162bc59cefc246da80d66f223a5cd545ff1dd3 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 10 Sep 2018 20:41:10 +0100 Subject: Pull fname out of class loop so we can see which actual shader file we were trying to load while debugging. --- indra/llrender/llshadermgr.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 78aed5eef6..20d32612f8 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -588,10 +588,11 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade S32 try_gpu_class = shader_level; S32 gpu_class; + std::stringstream fname; + //find the most relevant file for (gpu_class = try_gpu_class; gpu_class > 0; gpu_class--) - { //search from the current gpu class down to class 1 to find the most relevant shader - std::stringstream fname; + { //search from the current gpu class down to class 1 to find the most relevant shader fname << getShaderDirPrefix(); fname << gpu_class << "/" << filename; -- cgit v1.2.3 From ef2c61275eafa7d1fd3afa3f0eb76397632f12c9 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 10 Sep 2018 21:18:37 +0100 Subject: Move fname back inside class loop. grumble stringstream grumble. Fix sky depth-testing with advanced atmospherics. --- indra/llrender/llshadermgr.cpp | 5 ++--- indra/newview/app_settings/shaders/class3/deferred/skyV.glsl | 2 +- indra/newview/llvowlsky.cpp | 2 -- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 20d32612f8..78aed5eef6 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -588,11 +588,10 @@ GLhandleARB LLShaderMgr::loadShaderFile(const std::string& filename, S32 & shade S32 try_gpu_class = shader_level; S32 gpu_class; - std::stringstream fname; - //find the most relevant file for (gpu_class = try_gpu_class; gpu_class > 0; gpu_class--) - { //search from the current gpu class down to class 1 to find the most relevant shader + { //search from the current gpu class down to class 1 to find the most relevant shader + std::stringstream fname; fname << getShaderDirPrefix(); fname << gpu_class << "/" << filename; diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl index 89873e83ca..a5cc49ca30 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl @@ -37,7 +37,7 @@ VARYING vec2 vary_frag; void main() { // pass through untransformed fullscreen pos at back of frustum for proper sky depth testing - gl_Position = vec4(position.xy, 0.99f, 1.0); + gl_Position = vec4(position.xy, 1.0f, 1.0); vary_frag = texcoord0; } diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index 741d0e3992..b5f019a7f8 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -324,8 +324,6 @@ void LLVOWLSky::drawFsSky(void) updateGeometry(mDrawable); } - //LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE, GL_LEQUAL); - LLGLDepthTest gls_depth(GL_FALSE, GL_FALSE, GL_ALWAYS); LLGLDisable disable_blend(GL_BLEND); mFsSkyVerts->setBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK); -- cgit v1.2.3 From 555dfdc6ef0dab37bc4eaf6ae0b00a857f0609da Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 10 Sep 2018 23:21:34 +0100 Subject: Add copies of existing lighting shaders for advanced atmo path. Enable advanced atmo by default. Disable nSight in settings.xml Remove MSVC debug pragmas. --- indra/newview/app_settings/settings.xml | 4 +- .../shaders/class3/deferred/multiSpotLightF.glsl | 314 +++++++++++++++++++++ .../app_settings/shaders/class3/deferred/skyF.glsl | 13 +- .../shaders/class3/deferred/softenLightF.glsl | 189 +++++++++++++ .../shaders/class3/deferred/softenLightV.glsl | 42 +++ .../shaders/class3/deferred/spotLightF.glsl | 313 ++++++++++++++++++++ .../shaders/class3/deferred/sunLightF.glsl | 247 ++++++++++++++++ .../shaders/class3/deferred/sunLightSSAOF.glsl | 308 ++++++++++++++++++++ .../shaders/class3/deferred/sunLightV.glsl | 41 +++ indra/newview/llfloatereditextdaycycle.cpp | 2 - indra/newview/llfloaterfixedenvironment.cpp | 2 - 11 files changed, 1465 insertions(+), 10 deletions(-) create mode 100644 indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl create mode 100644 indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl create mode 100644 indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl create mode 100644 indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl create mode 100644 indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl create mode 100644 indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl create mode 100644 indra/newview/app_settings/shaders/class3/deferred/sunLightV.glsl diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 8f4faf51da..5b790fe9cf 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8664,7 +8664,7 @@ Type Boolean Value - 1 + 0 RenderLocalLights @@ -10165,7 +10165,7 @@ Type Boolean Value - 0 + 1 RenderUseTriStrips diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl new file mode 100644 index 0000000000..864ba4859d --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -0,0 +1,314 @@ +/** + * @file multiSpotLightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +#extension GL_ARB_texture_rectangle : enable +#extension GL_ARB_shader_texture_lod : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2DRect diffuseRect; +uniform sampler2DRect specularRect; +uniform sampler2DRect depthMap; +uniform sampler2DRect normalMap; +uniform samplerCube environmentMap; +uniform sampler2DRect lightMap; +uniform sampler2D noiseMap; +uniform sampler2D projectionMap; +uniform sampler2D lightFunc; + +uniform mat4 proj_mat; //screen space to light space +uniform float proj_near; //near clip for projection +uniform vec3 proj_p; //plane projection is emitting from (in screen space) +uniform vec3 proj_n; +uniform float proj_focus; //distance from plane to begin blurring +uniform float proj_lod; //(number of mips in proj map) +uniform float proj_range; //range between near clip and far clip plane of projection +uniform float proj_ambient_lod; +uniform float proj_ambiance; +uniform float near_clip; +uniform float far_clip; + +uniform vec3 proj_origin; //origin of projection to be used for angular attenuation +uniform float sun_wash; +uniform int proj_shadow_idx; +uniform float shadow_fade; + +uniform vec3 center; +uniform float size; +uniform vec3 color; +uniform float falloff; + +VARYING vec4 vary_fragcoord; +uniform vec2 screen_res; + +uniform mat4 inv_proj; + +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); +vec3 decode_normal (vec2 enc); + +vec4 correctWithGamma(vec4 col) +{ + return vec4(srgb_to_linear(col.rgb), col.a); +} + +vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = srgb_to_linear(ret.rgb); + + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); + + float det = min(lod/(proj_lod*0.5), 1.0); + + float d = min(dist.x, dist.y); + + d *= min(1, d * (proj_lod - lod)); + + float edge = 0.25*det; + + ret *= clamp(d/edge, 0.0, 1.0); + + return ret; +} + +vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); + + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); + + float det = min(lod/(proj_lod*0.5), 1.0); + + float d = min(dist.x, dist.y); + + float edge = 0.25*det; + + ret *= clamp(d/edge, 0.0, 1.0); + + return ret; +} + +vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); + + vec2 dist = tc-vec2(0.5); + + float d = dot(dist,dist); + + ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0), 1.0); + + return ret; +} + + +vec4 getPosition(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen.xy).r; + vec2 sc = pos_screen.xy*2.0; + sc /= screen_res; + sc -= vec2(1.0,1.0); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} + +void main() +{ + vec4 frag = vary_fragcoord; + frag.xyz /= frag.w; + frag.xyz = frag.xyz*0.5+0.5; + frag.xy *= screen_res; + + vec3 pos = getPosition(frag.xy).xyz; + vec3 lv = center.xyz-pos.xyz; + float dist = length(lv); + dist /= size; + if (dist > 1.0) + { + discard; + } + + float shadow = 1.0; + + if (proj_shadow_idx >= 0) + { + vec4 shd = texture2DRect(lightMap, frag.xy); + float sh[2]; + sh[0] = shd.b; + sh[1] = shd.a; + shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); + } + + vec3 norm = texture2DRect(normalMap, frag.xy).xyz; + + float envIntensity = norm.z; + + norm = decode_normal(norm.xy); + + norm = normalize(norm); + float l_dist = -dot(lv, proj_n); + + vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); + if (proj_tc.z < 0.0) + { + discard; + } + + proj_tc.xyz /= proj_tc.w; + + float fa = falloff+1.0; + float dist_atten = min(1.0-(dist-1.0*(1.0-fa))/fa, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0; + if (dist_atten <= 0.0) + { + discard; + } + + lv = proj_origin-pos.xyz; + lv = normalize(lv); + float da = dot(norm, lv); + + vec3 col = vec3(0,0,0); + + vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + + vec4 spec = texture2DRect(specularRect, frag.xy); + + vec3 dlit = vec3(0, 0, 0); + + float noise = texture2D(noiseMap, frag.xy/128.0).b; + if (proj_tc.z > 0.0 && + proj_tc.x < 1.0 && + proj_tc.y < 1.0 && + proj_tc.x > 0.0 && + proj_tc.y > 0.0) + { + float amb_da = proj_ambiance; + float lit = 0.0; + + if (da > 0.0) + { + lit = da * dist_atten * noise; + + float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); + float lod = diff * proj_lod; + + 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; + } + + //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)*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; + } + + + if (spec.a > 0.0) + { + vec3 npos = -normalize(pos); + dlit *= min(da*6.0, 1.0) * dist_atten; + + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, 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); + col += dlit*scol*spec.rgb*shadow; + //col += spec.rgb; + } + } + + + + + + if (envIntensity > 0.0) + { + vec3 ref = reflect(normalize(pos), norm); + + //project from point pos in direction ref to plane proj_p, proj_n + vec3 pdelta = proj_p-pos; + float ds = dot(ref, proj_n); + + if (ds < 0.0) + { + vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; + + vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0)); + + if (stc.z > 0.0) + { + stc /= stc.w; + + if (stc.x < 1.0 && + stc.y < 1.0 && + stc.x > 0.0 && + stc.y > 0.0) + { + col += color.rgb * texture2DLodSpecular(projectionMap, stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * shadow * envIntensity; + } + } + } + } + + //not sure why, but this line prevents MATBUG-194 + col = max(col, vec3(0.0)); + + frag_color.rgb = col; + frag_color.a = 0.0; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl index cd0efe8cbb..7bfc114383 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl @@ -55,7 +55,7 @@ void main() vec3 view_ray = (inv_modelview * vec4(view_pos.xyz, 0.0f)).xyz; vec3 view_direction = normalize(view_ray); - vec3 sun_direction = normalize(sun_dir); + vec3 sun_direction = normalize(sun_dir); vec3 camPos = (camPosLocal / 1000.0f) + vec3(0, 0, 6360.0f); vec3 transmittance; @@ -63,15 +63,20 @@ void main() vec3 solar_luminance = transmittance * GetSolarLuminance(); // If the view ray intersects the Sun, add the Sun radiance. - if (dot(view_direction, sun_direction) >= sun_size) + float s = dot(view_direction, sun_direction); + + // cheesy solar disc... + if (s >= (sun_size * 0.999)) { - radiance_sun += solar_luminance; + radiance_sun += pow(smoothstep(0.0, 1.3, (s - (sun_size * 0.9))), 2.0) * solar_luminance; } + s = smoothstep(0.9, 1.0, s) * 16.0f; vec3 color = vec3(1.0) - exp(-radiance_sun * 0.0001); + color = pow(color, vec3(1.0 / 2.2)); - frag_data[0] = vec4(color, 1.0); + frag_data[0] = vec4(color, 1.0 + s); frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0, 1.0, 0.0, 1.0); } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl new file mode 100644 index 0000000000..bda33c3213 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -0,0 +1,189 @@ +/** + * @file softenLightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2DRect diffuseRect; +uniform sampler2DRect specularRect; +uniform sampler2DRect normalMap; +uniform sampler2DRect lightMap; +uniform sampler2DRect depthMap; +uniform samplerCube environmentMap; +uniform sampler2D lightFunc; + +uniform float blur_size; +uniform float blur_fidelity; + +// Inputs +uniform vec4 morphFactor; +uniform vec3 camPosLocal; +//uniform vec4 camPosWorld; +uniform vec4 gamma; +uniform vec4 sunlight_color; +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 global_gamma; +uniform float scene_light_strength; +uniform mat3 env_mat; +uniform vec4 shadow_clip; +uniform mat3 ssao_effect_mat; + +uniform vec3 sun_dir; +VARYING vec2 vary_fragcoord; + +uniform mat4 inv_proj; +uniform mat4 inv_modelview; + +uniform vec2 screen_res; + +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); +vec3 decode_normal (vec2 enc); + +vec4 getPosition_d(vec2 pos_screen, float depth) +{ + vec2 sc = pos_screen.xy*2.0; + sc /= screen_res; + sc -= vec2(1.0,1.0); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} + +vec4 getPosition(vec2 pos_screen) +{ //get position in screen space (world units) given window coordinate and depth map + float depth = texture2DRect(depthMap, pos_screen.xy).r; + return getPosition_d(pos_screen, depth); +} + + +#ifdef WATER_FOG +vec4 applyWaterFogView(vec3 pos, vec4 color); +#endif + +void main() +{ + vec2 tc = vary_fragcoord.xy; + float depth = texture2DRect(depthMap, tc.xy).r; + vec3 pos = getPosition_d(tc, depth).xyz; + vec4 norm = texture2DRect(normalMap, tc); + float envIntensity = norm.z; + norm.xyz = decode_normal(norm.xy); // unpack norm + + float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); + + float light_gamma = 1.0/1.3; + da = pow(da, light_gamma); + + + vec4 diffuse = texture2DRect(diffuseRect, tc); + + //convert to gamma space + diffuse.rgb = linear_to_srgb(diffuse.rgb); + + vec3 col; + float bloom = 0.0; + { + vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); + + vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; + scol_ambocc = pow(scol_ambocc, vec2(light_gamma)); + + float scol = max(scol_ambocc.r, diffuse.a); + + float ambocc = scol_ambocc.g; + + vec3 sunlit; + vec3 amblit; + vec3 additive; + vec3 atten; + + //calcFragAtmospherics(pos.xyz, ambocc, sunlit, amblit, additive, atten); + //col += atmosFragAffectDirectionalLight(max(min(da, scol), 0.0), sunlit); + + col *= diffuse.rgb; + + vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); + + if (spec.a > 0.0) // specular reflection + { + // the old infinite-sky shiny reflection + // + + float sa = dot(refnormpersp, sun_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; + } + + + col = mix(col, diffuse.rgb, diffuse.a); + + if (envIntensity > 0.0) + { //add environmentmap + vec3 env_vec = env_mat * refnormpersp; + vec3 refcol = textureCube(environmentMap, env_vec).rgb; + col = mix(col.rgb, refcol, envintensity); + } + + if (norm.w < 0.5) + { + //col = mix(atmosFragLighting(col, additive, atten), fullbrightFragAtmosTransport(col, atten, additive), diffuse.a); + //col = mix(scaleFragSoftClip(col), fullbrightScaleSoftClipFrag(col, atten), diffuse.a); + } + + #ifdef WATER_FOG + vec4 fogged = applyWaterFogView(pos,vec4(col, bloom)); + col = fogged.rgb; + bloom = fogged.a; + #endif + + col = srgb_to_linear(col); + } + + frag_color.rgb = col; + frag_color.a = bloom; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl new file mode 100644 index 0000000000..c840d72784 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightV.glsl @@ -0,0 +1,42 @@ +/** + * @file softenLightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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 mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; + +uniform vec2 screen_res; + +VARYING vec2 vary_fragcoord; + +void main() +{ + //transform vertex + vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0); + gl_Position = pos; + + + vary_fragcoord = (pos.xy*0.5+0.5)*screen_res; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl new file mode 100644 index 0000000000..a7da140b31 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -0,0 +1,313 @@ +/** + * @file spotLightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +#extension GL_ARB_texture_rectangle : enable +#extension GL_ARB_shader_texture_lod : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +uniform sampler2DRect diffuseRect; +uniform sampler2DRect specularRect; +uniform sampler2DRect depthMap; +uniform sampler2DRect normalMap; +uniform samplerCube environmentMap; +uniform sampler2DRect lightMap; +uniform sampler2D noiseMap; +uniform sampler2D projectionMap; +uniform sampler2D lightFunc; + +uniform mat4 proj_mat; //screen space to light space +uniform float proj_near; //near clip for projection +uniform vec3 proj_p; //plane projection is emitting from (in screen space) +uniform vec3 proj_n; +uniform float proj_focus; //distance from plane to begin blurring +uniform float proj_lod; //(number of mips in proj map) +uniform float proj_range; //range between near clip and far clip plane of projection +uniform float proj_ambient_lod; +uniform float proj_ambiance; +uniform float near_clip; +uniform float far_clip; + +uniform vec3 proj_origin; //origin of projection to be used for angular attenuation +uniform float sun_wash; +uniform int proj_shadow_idx; +uniform float shadow_fade; + +uniform float size; +uniform vec3 color; +uniform float falloff; + +VARYING vec3 trans_center; +VARYING vec4 vary_fragcoord; +uniform vec2 screen_res; + +uniform mat4 inv_proj; + +vec3 decode_normal (vec2 enc); +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); + +vec4 correctWithGamma(vec4 col) +{ + return vec4(srgb_to_linear(col.rgb), col.a); +} + +vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret.rgb = srgb_to_linear(ret.rgb); + + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); + + float det = min(lod/(proj_lod*0.5), 1.0); + + float d = min(dist.x, dist.y); + + d *= min(1, d * (proj_lod - lod)); + + float edge = 0.25*det; + + ret *= clamp(d/edge, 0.0, 1.0); + + return ret; +} + +vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); + + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); + + float det = min(lod/(proj_lod*0.5), 1.0); + + float d = min(dist.x, dist.y); + + float edge = 0.25*det; + + ret *= clamp(d/edge, 0.0, 1.0); + + return ret; +} + +vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) +{ + vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); + + vec2 dist = tc-vec2(0.5); + + float d = dot(dist,dist); + + ret *= min(clamp((0.25-d)/0.25, 0.0, 1.0), 1.0); + + return ret; +} + + +vec4 getPosition(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen.xy).r; + vec2 sc = pos_screen.xy*2.0; + sc /= screen_res; + sc -= vec2(1.0,1.0); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} + +void main() +{ + vec4 frag = vary_fragcoord; + frag.xyz /= frag.w; + frag.xyz = frag.xyz*0.5+0.5; + frag.xy *= screen_res; + + vec3 pos = getPosition(frag.xy).xyz; + vec3 lv = trans_center.xyz-pos.xyz; + float dist = length(lv); + dist /= size; + if (dist > 1.0) + { + discard; + } + + float shadow = 1.0; + + if (proj_shadow_idx >= 0) + { + vec4 shd = texture2DRect(lightMap, frag.xy); + float sh[2]; + sh[0] = shd.b; + sh[1] = shd.a; + shadow = min(sh[proj_shadow_idx]+shadow_fade, 1.0); + } + + vec3 norm = texture2DRect(normalMap, frag.xy).xyz; + float envIntensity = norm.z; + norm = decode_normal(norm.xy); + + norm = normalize(norm); + float l_dist = -dot(lv, proj_n); + + vec4 proj_tc = (proj_mat * vec4(pos.xyz, 1.0)); + if (proj_tc.z < 0.0) + { + discard; + } + + proj_tc.xyz /= proj_tc.w; + + float fa = falloff + 1.0; + float dist_atten = min(1.0 - (dist - 1.0 * (1.0 - fa)) / fa, 1.0); + dist_atten *= dist_atten; + dist_atten *= 2.0; + + if (dist_atten <= 0.0) + { + discard; + } + + lv = proj_origin-pos.xyz; + lv = normalize(lv); + float da = dot(norm, lv); + + vec3 col = vec3(0,0,0); + + vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + + vec4 spec = texture2DRect(specularRect, frag.xy); + + vec3 dlit = vec3(0, 0, 0); + + float noise = texture2D(noiseMap, frag.xy/128.0).b; + if (proj_tc.z > 0.0 && + proj_tc.x < 1.0 && + proj_tc.y < 1.0 && + proj_tc.x > 0.0 && + proj_tc.y > 0.0) + { + float amb_da = proj_ambiance; + float lit = 0.0; + + if (da > 0.0) + { + lit = da * dist_atten * noise; + + float diff = clamp((l_dist-proj_focus)/proj_range, 0.0, 1.0); + float lod = diff * proj_lod; + + 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; + } + + //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)*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; + } + + + if (spec.a > 0.0) + { + dlit *= min(da*6.0, 1.0) * dist_atten; + vec3 npos = -normalize(pos); + + //vec3 ref = dot(pos+lv, norm); + vec3 h = normalize(lv+npos); + float nh = dot(norm, h); + float nv = dot(norm, 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); + col += dlit*scol*spec.rgb*shadow; + //col += spec.rgb; + } + } + + + + + + if (envIntensity > 0.0) + { + vec3 ref = reflect(normalize(pos), norm); + + //project from point pos in direction ref to plane proj_p, proj_n + vec3 pdelta = proj_p-pos; + float ds = dot(ref, proj_n); + + if (ds < 0.0) + { + vec3 pfinal = pos + ref * dot(pdelta, proj_n)/ds; + + vec4 stc = (proj_mat * vec4(pfinal.xyz, 1.0)); + + if (stc.z > 0.0) + { + stc /= stc.w; + + if (stc.x < 1.0 && + stc.y < 1.0 && + stc.x > 0.0 && + stc.y > 0.0) + { + col += color.rgb * texture2DLodSpecular(projectionMap, stc.xy, (1 - spec.a) * (proj_lod * 0.6)).rgb * shadow * envIntensity; + } + } + } + } + + //not sure why, but this line prevents MATBUG-194 + col = max(col, vec3(0.0)); + + frag_color.rgb = col; + frag_color.a = 0.0; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl new file mode 100644 index 0000000000..aa5e99a2f7 --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/sunLightF.glsl @@ -0,0 +1,247 @@ +/** + * @file sunLightF.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +//class 2, shadows, no SSAO + +uniform sampler2DRect depthMap; +uniform sampler2DRect normalMap; +uniform sampler2DShadow shadowMap0; +uniform sampler2DShadow shadowMap1; +uniform sampler2DShadow shadowMap2; +uniform sampler2DShadow shadowMap3; +uniform sampler2DShadow shadowMap4; +uniform sampler2DShadow shadowMap5; + + +// Inputs +uniform mat4 shadow_matrix[6]; +uniform vec4 shadow_clip; +uniform float ssao_radius; +uniform float ssao_max_radius; +uniform float ssao_factor; +uniform float ssao_factor_inv; + +VARYING vec2 vary_fragcoord; + +uniform mat4 inv_proj; +uniform vec2 screen_res; +uniform vec2 proj_shadow_res; +uniform vec3 sun_dir; + +uniform vec2 shadow_res; +uniform float shadow_bias; +uniform float shadow_offset; + +uniform float spot_shadow_bias; +uniform float spot_shadow_offset; + +vec3 decode_normal (vec2 enc); + +vec4 getPosition(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen.xy).r; + vec2 sc = pos_screen.xy*2.0; + sc /= screen_res; + sc -= vec2(1.0,1.0); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} + +float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen) +{ + stc.xyz /= stc.w; + stc.z += shadow_bias; + + stc.x = floor(stc.x*shadow_res.x + fract(pos_screen.y*0.666666666))/shadow_res.x; // add some 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; + + 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(-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; + + + return shadow*0.2; +} + +float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen) +{ + stc.xyz /= stc.w; + stc.z += spot_shadow_bias*scl; + stc.x = floor(proj_shadow_res.x * stc.x + fract(pos_screen.y*0.666666666)) / proj_shadow_res.x; // snap + + float cs = shadow2D(shadowMap, stc.xyz).x; + float shadow = cs; + + vec2 off = 1.0/proj_shadow_res; + off.y *= 1.5; + + shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x*2.0, off.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x*2.0, -off.y, 0.0)).x; + + return shadow*0.2; +} + +void main() +{ + vec2 pos_screen = vary_fragcoord.xy; + + //try doing an unproject here + + vec4 pos = getPosition(pos_screen); + + vec3 norm = texture2DRect(normalMap, pos_screen).xyz; + norm = decode_normal(norm.xy); // unpack norm + + /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL + { + frag_color = vec4(0.0); // doesn't matter + return; + }*/ + + float shadow = 0.0; + float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); + + vec3 shadow_pos = pos.xyz; + vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); + + vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0); + + if (spos.z > -shadow_clip.w) + { + if (dp_directional_light == 0.0) + { + // if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup + shadow = 0.0; + } + else + { + vec4 lpos; + + vec4 near_split = shadow_clip*-0.75; + vec4 far_split = shadow_clip*-1.25; + vec4 transition_domain = near_split-far_split; + float weight = 0.0; + + if (spos.z < near_split.z) + { + lpos = shadow_matrix[3]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; + shadow += pcfShadow(shadowMap3, lpos, 0.25, pos_screen)*w; + weight += w; + shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); + } + + if (spos.z < near_split.y && spos.z > far_split.z) + { + lpos = shadow_matrix[2]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; + w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; + shadow += pcfShadow(shadowMap2, lpos, 0.5, pos_screen)*w; + weight += w; + } + + if (spos.z < near_split.x && spos.z > far_split.y) + { + lpos = shadow_matrix[1]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; + w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; + shadow += pcfShadow(shadowMap1, lpos, 0.75, pos_screen)*w; + weight += w; + } + + if (spos.z > far_split.x) + { + lpos = shadow_matrix[0]*spos; + + float w = 1.0; + w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; + + shadow += pcfShadow(shadowMap0, lpos, 1.0, pos_screen)*w; + weight += w; + } + + + shadow /= weight; + + // take the most-shadowed value out of these two: + // * the blurred sun shadow in the light (shadow) map + // * an unblurred dot product between the sun and this norm + // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting + shadow = min(shadow, dp_directional_light); + + //lpos.xy /= lpos.w*32.0; + //if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1) + //{ + // shadow = 0.0; + //} + + } + } + else + { + // more distant than the shadow map covers + shadow = 1.0; + } + + frag_color[0] = shadow; + frag_color[1] = 1.0; + + spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0); + + //spotlight shadow 1 + vec4 lpos = shadow_matrix[4]*spos; + frag_color[2] = pcfSpotShadow(shadowMap4, lpos, 0.8, pos_screen); + + //spotlight shadow 2 + lpos = shadow_matrix[5]*spos; + frag_color[3] = pcfSpotShadow(shadowMap5, lpos, 0.8, pos_screen); + + //frag_color.rgb = pos.xyz; + //frag_color.b = shadow; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl new file mode 100644 index 0000000000..58f3f2f91e --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/sunLightSSAOF.glsl @@ -0,0 +1,308 @@ +/** + * @file sunLightSSAOF.glsl + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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$ + */ + +#extension GL_ARB_texture_rectangle : enable + +/*[EXTRA_CODE_HERE]*/ + +#ifdef DEFINE_GL_FRAGCOLOR +out vec4 frag_color; +#else +#define frag_color gl_FragColor +#endif + +//class 2 -- shadows and SSAO + +uniform sampler2DRect depthMap; +uniform sampler2DRect normalMap; +uniform sampler2DShadow shadowMap0; +uniform sampler2DShadow shadowMap1; +uniform sampler2DShadow shadowMap2; +uniform sampler2DShadow shadowMap3; +uniform sampler2DShadow shadowMap4; +uniform sampler2DShadow shadowMap5; +uniform sampler2D noiseMap; + + +// Inputs +uniform mat4 shadow_matrix[6]; +uniform vec4 shadow_clip; +uniform float ssao_radius; +uniform float ssao_max_radius; +uniform float ssao_factor; +uniform float ssao_factor_inv; + +VARYING vec2 vary_fragcoord; + +uniform mat4 inv_proj; +uniform vec2 screen_res; +uniform vec2 proj_shadow_res; +uniform vec3 sun_dir; + +uniform vec2 shadow_res; + +uniform float shadow_bias; +uniform float shadow_offset; + +uniform float spot_shadow_bias; +uniform float spot_shadow_offset; + +vec3 decode_normal (vec2 enc); + +vec4 getPosition(vec2 pos_screen) +{ + float depth = texture2DRect(depthMap, pos_screen.xy).r; + vec2 sc = pos_screen.xy*2.0; + sc /= screen_res; + sc -= vec2(1.0,1.0); + vec4 ndc = vec4(sc.x, sc.y, 2.0*depth-1.0, 1.0); + vec4 pos = inv_proj * ndc; + pos /= pos.w; + pos.w = 1.0; + return pos; +} + +vec2 getKern(int i) +{ + vec2 kern[8]; + // exponentially (^2) distant occlusion samples spread around origin + kern[0] = vec2(-1.0, 0.0) * 0.125*0.125; + kern[1] = vec2(1.0, 0.0) * 0.250*0.250; + kern[2] = vec2(0.0, 1.0) * 0.375*0.375; + kern[3] = vec2(0.0, -1.0) * 0.500*0.500; + kern[4] = vec2(0.7071, 0.7071) * 0.625*0.625; + kern[5] = vec2(-0.7071, -0.7071) * 0.750*0.750; + kern[6] = vec2(-0.7071, 0.7071) * 0.875*0.875; + kern[7] = vec2(0.7071, -0.7071) * 1.000*1.000; + + return kern[i]; +} + +//calculate decreases in ambient lighting when crowded out (SSAO) +float calcAmbientOcclusion(vec4 pos, vec3 norm) +{ + float ret = 1.0; + + vec2 pos_screen = vary_fragcoord.xy; + vec3 pos_world = pos.xyz; + vec2 noise_reflect = texture2D(noiseMap, vary_fragcoord.xy/128.0).xy; + + float angle_hidden = 0.0; + float points = 0; + + float scale = min(ssao_radius / -pos_world.z, ssao_max_radius); + + // it was found that keeping # of samples a constant was the fastest, probably due to compiler optimizations (unrolling?) + for (int i = 0; i < 8; i++) + { + vec2 samppos_screen = pos_screen + scale * reflect(getKern(i), noise_reflect); + vec3 samppos_world = getPosition(samppos_screen).xyz; + + vec3 diff = pos_world - samppos_world; + float dist2 = dot(diff, diff); + + // assume each sample corresponds to an occluding sphere with constant radius, constant x-sectional area + // --> solid angle shrinking by the square of distance + //radius is somewhat arbitrary, can approx with just some constant k * 1 / dist^2 + //(k should vary inversely with # of samples, but this is taken care of later) + + float funky_val = (dot((samppos_world - 0.05*norm - pos_world), norm) > 0.0) ? 1.0 : 0.0; + angle_hidden = angle_hidden + funky_val * min(1.0/dist2, ssao_factor_inv); + + // 'blocked' samples (significantly closer to camera relative to pos_world) are "no data", not "no occlusion" + float diffz_val = (diff.z > -1.0) ? 1.0 : 0.0; + points = points + diffz_val; + } + + angle_hidden = min(ssao_factor*angle_hidden/points, 1.0); + + float points_val = (points > 0.0) ? 1.0 : 0.0; + ret = (1.0 - (points_val * angle_hidden)); + + ret = max(ret, 0.0); + return min(ret, 1.0); +} + +float pcfShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen) +{ + stc.xyz /= stc.w; + stc.z += shadow_bias; + + stc.x = floor(stc.x*shadow_res.x + fract(pos_screen.y*0.666666666))/shadow_res.x; + float cs = shadow2D(shadowMap, stc.xyz).x; + + 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.2; +} + +float pcfSpotShadow(sampler2DShadow shadowMap, vec4 stc, float scl, vec2 pos_screen) +{ + stc.xyz /= stc.w; + stc.z += spot_shadow_bias*scl; + stc.x = floor(proj_shadow_res.x * stc.x + fract(pos_screen.y*0.666666666)) / proj_shadow_res.x; // snap + + float cs = shadow2D(shadowMap, stc.xyz).x; + float shadow = cs; + + vec2 off = 1.0/proj_shadow_res; + off.y *= 1.5; + + shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x*2.0, off.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(off.x, -off.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x, off.y, 0.0)).x; + shadow += shadow2D(shadowMap, stc.xyz+vec3(-off.x*2.0, -off.y, 0.0)).x; + + return shadow*0.2; +} + +void main() +{ + vec2 pos_screen = vary_fragcoord.xy; + + //try doing an unproject here + + vec4 pos = getPosition(pos_screen); + + vec3 norm = texture2DRect(normalMap, pos_screen).xyz; + norm = decode_normal(norm.xy); // unpack norm + + /*if (pos.z == 0.0) // do nothing for sky *FIX: REMOVE THIS IF/WHEN THE POSITION MAP IS BEING USED AS A STENCIL + { + frag_color = vec4(0.0); // doesn't matter + return; + }*/ + + float shadow = 0.0; + float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); + + vec3 shadow_pos = pos.xyz; + vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); + + vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0); + + if (spos.z > -shadow_clip.w) + { + if (dp_directional_light == 0.0) + { + // if we know this point is facing away from the sun then we know it's in shadow without having to do a squirrelly shadow-map lookup + shadow = 0.0; + } + else + { + vec4 lpos; + + vec4 near_split = shadow_clip*-0.75; + vec4 far_split = shadow_clip*-1.25; + vec4 transition_domain = near_split-far_split; + float weight = 0.0; + + if (spos.z < near_split.z) + { + lpos = shadow_matrix[3]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.z, 0.0)/transition_domain.z; + shadow += pcfShadow(shadowMap3, lpos, 0.25, pos_screen)*w; + weight += w; + shadow += max((pos.z+shadow_clip.z)/(shadow_clip.z-shadow_clip.w)*2.0-1.0, 0.0); + } + + if (spos.z < near_split.y && spos.z > far_split.z) + { + lpos = shadow_matrix[2]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; + w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; + shadow += pcfShadow(shadowMap2, lpos, 0.5, pos_screen)*w; + weight += w; + } + + if (spos.z < near_split.x && spos.z > far_split.y) + { + lpos = shadow_matrix[1]*spos; + + float w = 1.0; + w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; + w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; + shadow += pcfShadow(shadowMap1, lpos, 0.75, pos_screen)*w; + weight += w; + } + + if (spos.z > far_split.x) + { + lpos = shadow_matrix[0]*spos; + + float w = 1.0; + w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; + + shadow += pcfShadow(shadowMap0, lpos, 1.0, pos_screen)*w; + weight += w; + } + + + shadow /= weight; + + // take the most-shadowed value out of these two: + // * the blurred sun shadow in the light (shadow) map + // * an unblurred dot product between the sun and this norm + // the goal is to err on the side of most-shadow to fill-in shadow holes and reduce artifacting + shadow = min(shadow, dp_directional_light); + + //lpos.xy /= lpos.w*32.0; + //if (fract(lpos.x) < 0.1 || fract(lpos.y) < 0.1) + //{ + // shadow = 0.0; + //} + + } + } + else + { + // more distant than the shadow map covers + shadow = 1.0; + } + + frag_color[0] = shadow; + frag_color[1] = calcAmbientOcclusion(pos, norm); + + spos = vec4(shadow_pos+norm*spot_shadow_offset, 1.0); + + //spotlight shadow 1 + vec4 lpos = shadow_matrix[4]*spos; + frag_color[2] = pcfSpotShadow(shadowMap4, lpos, 0.8, pos_screen); + + //spotlight shadow 2 + lpos = shadow_matrix[5]*spos; + frag_color[3] = pcfSpotShadow(shadowMap5, lpos, 0.8, pos_screen); + + //frag_color.rgb = pos.xyz; + //frag_color.b = shadow; +} diff --git a/indra/newview/app_settings/shaders/class3/deferred/sunLightV.glsl b/indra/newview/app_settings/shaders/class3/deferred/sunLightV.glsl new file mode 100644 index 0000000000..bc5eb5181d --- /dev/null +++ b/indra/newview/app_settings/shaders/class3/deferred/sunLightV.glsl @@ -0,0 +1,41 @@ +/** + * @file sunLightV.glsl + * + * $LicenseInfo:firstyear=2007&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2007, 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 mat4 modelview_projection_matrix; + +ATTRIBUTE vec3 position; + +VARYING vec2 vary_fragcoord; + +uniform vec2 screen_res; + +void main() +{ + //transform vertex + vec4 pos = modelview_projection_matrix * vec4(position.xyz, 1.0); + gl_Position = pos; + + vary_fragcoord = (pos.xy * 0.5 + 0.5)*screen_res; +} diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 8e29e4cf32..0b59239f8c 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -62,8 +62,6 @@ #include "llenvironment.h" #include "lltrans.h" -#pragma optimize("", off) - extern LLControlGroup gSavedSettings; //========================================================================= diff --git a/indra/newview/llfloaterfixedenvironment.cpp b/indra/newview/llfloaterfixedenvironment.cpp index e5d6412218..09a05eb7e2 100644 --- a/indra/newview/llfloaterfixedenvironment.cpp +++ b/indra/newview/llfloaterfixedenvironment.cpp @@ -55,8 +55,6 @@ #include "llsettingsvo.h" #include "llinventorymodel.h" -#pragma optimize("", off) - extern LLControlGroup gSavedSettings; namespace -- cgit v1.2.3 From 87cecc7679c259805c357cf9f7f264aa84cab3d0 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 10 Sep 2018 23:26:23 +0100 Subject: Put back extern decl of gSavedSettings dropped in merge. --- indra/newview/llfloatereditextdaycycle.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index ce4797c380..b50b0ce34f 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -62,6 +62,8 @@ #include "llenvironment.h" #include "lltrans.h" +extern LLControlGroup gSavedSettings; + //========================================================================= namespace { const std::string track_tabs[] = { -- cgit v1.2.3 From 3262446f07616f42ad0e4c77930b6ba2f03e452c Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Mon, 10 Sep 2018 23:49:40 +0100 Subject: Put back new func dropped in merge. --- indra/newview/llfloatereditextdaycycle.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index b50b0ce34f..4cab1160c0 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -1253,6 +1253,18 @@ void LLFloaterEditExtDayCycle::doApplyCommit() } } +bool LLFloaterEditExtDayCycle::isRemovingFrameAllowed() +{ + if (mCurrentTrack <= LLSettingsDay::TRACK_GROUND_LEVEL) + { + return (mSliderKeyMap.size() > 1); + } + else + { + return (mSliderKeyMap.size() > 0); + } +} + void LLFloaterEditExtDayCycle::onInventoryCreated(LLUUID asset_id, LLUUID inventory_id, LLSD results) { LL_INFOS("ENVDAYEDIT") << "Inventory item " << inventory_id << " has been created with asset " << asset_id << " results are:" << results << LL_ENDL; -- cgit v1.2.3 From 24e0e64f2f226fb87df5d6b42d868e2a0e3daff7 Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 11 Sep 2018 00:23:10 +0100 Subject: Fix cloud shader tex binding to be more robust. Make vert generation not skip dome verts used for clouds when doing advanced atmospherics. --- indra/newview/lldrawpoolwlsky.cpp | 7 ++-- indra/newview/llvowlsky.cpp | 76 +++++++++++++++++++-------------------- 2 files changed, 40 insertions(+), 43 deletions(-) diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 205b6441e7..e7929e0bbf 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -350,10 +350,11 @@ void LLDrawPoolWLSky::renderSkyClouds(const LLVector3& camPosLocal, F32 camHeigh LLGLEnable blend(GL_BLEND); gGL.setSceneBlendType(LLRender::BT_ALPHA); - gGL.getTexUnit(0)->bind(gSky.mVOSkyp->getCloudNoiseTex()); - gGL.getTexUnit(1)->bind(gSky.mVOSkyp->getCloudNoiseTexNext()); - cloud_shader->bind(); + + cloud_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, gSky.mVOSkyp->getCloudNoiseTex()); + cloud_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP_NEXT, gSky.mVOSkyp->getCloudNoiseTexNext()); + F32 blend_factor = LLEnvironment::instance().getCurrentSky()->getBlendFactor(); cloud_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); diff --git a/indra/newview/llvowlsky.cpp b/indra/newview/llvowlsky.cpp index b5f019a7f8..933bf9bf12 100644 --- a/indra/newview/llvowlsky.cpp +++ b/indra/newview/llvowlsky.cpp @@ -160,49 +160,45 @@ BOOL LLVOWLSky::updateGeometry(LLDrawable * drawable) LLStrider texCoords; LLStrider indices; - if (gPipeline.useAdvancedAtmospherics()) + if (mFsSkyVerts.isNull()) { - if (mFsSkyVerts.isNull()) - { - mFsSkyVerts = new LLVertexBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); - - if (!mFsSkyVerts->allocateBuffer(4, 6, TRUE)) - { - LL_WARNS() << "Failed to allocate Vertex Buffer on full screen sky update" << LL_ENDL; - } - - BOOL success = mFsSkyVerts->getVertexStrider(vertices) - && mFsSkyVerts->getTexCoord0Strider(texCoords) - && mFsSkyVerts->getIndexStrider(indices); - - if(!success) - { - LL_ERRS() << "Failed updating WindLight fullscreen sky geometry." << LL_ENDL; - } - - *vertices++ = LLVector3(-1.0f, -1.0f, 0.0f); - *vertices++ = LLVector3( 1.0f, -1.0f, 0.0f); - *vertices++ = LLVector3(-1.0f, 1.0f, 0.0f); - *vertices++ = LLVector3( 1.0f, 1.0f, 0.0f); - - *texCoords++ = LLVector2(0.0f, 0.0f); - *texCoords++ = LLVector2(1.0f, 0.0f); - *texCoords++ = LLVector2(0.0f, 1.0f); - *texCoords++ = LLVector2(1.0f, 1.0f); - - *indices++ = 0; - *indices++ = 1; - *indices++ = 2; - *indices++ = 1; - *indices++ = 3; - *indices++ = 2; - - mFsSkyVerts->flush(); - } - - return TRUE; + mFsSkyVerts = new LLVertexBuffer(LLDrawPoolWLSky::ADV_ATMO_SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); + + if (!mFsSkyVerts->allocateBuffer(4, 6, TRUE)) + { + LL_WARNS() << "Failed to allocate Vertex Buffer on full screen sky update" << LL_ENDL; + } + + BOOL success = mFsSkyVerts->getVertexStrider(vertices) + && mFsSkyVerts->getTexCoord0Strider(texCoords) + && mFsSkyVerts->getIndexStrider(indices); + + if(!success) + { + LL_ERRS() << "Failed updating WindLight fullscreen sky geometry." << LL_ENDL; + } + + *vertices++ = LLVector3(-1.0f, -1.0f, 0.0f); + *vertices++ = LLVector3( 1.0f, -1.0f, 0.0f); + *vertices++ = LLVector3(-1.0f, 1.0f, 0.0f); + *vertices++ = LLVector3( 1.0f, 1.0f, 0.0f); + + *texCoords++ = LLVector2(0.0f, 0.0f); + *texCoords++ = LLVector2(1.0f, 0.0f); + *texCoords++ = LLVector2(0.0f, 1.0f); + *texCoords++ = LLVector2(1.0f, 1.0f); + + *indices++ = 0; + *indices++ = 1; + *indices++ = 2; + *indices++ = 1; + *indices++ = 3; + *indices++ = 2; + + mFsSkyVerts->flush(); } + if(mFanVerts.isNull()) { mFanVerts = new LLVertexBuffer(LLDrawPoolWLSky::SKY_VERTEX_DATA_MASK, GL_STATIC_DRAW_ARB); if (!mFanVerts->allocateBuffer(getFanNumVerts(), getFanNumIndices(), TRUE)) -- cgit v1.2.3 From cd2dc42a28873f9d3d18c4d52d1b1a64a2170a6f Mon Sep 17 00:00:00 2001 From: Graham Linden Date: Tue, 11 Sep 2018 17:49:26 +0100 Subject: Hide UI related to advanced atmospherics and make it off by default again. --- indra/newview/app_settings/settings.xml | 2 +- indra/newview/llfloaterpreference.cpp | 4 ++++ .../skins/default/xui/en/floater_preferences_graphics_advanced.xml | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 5b790fe9cf..214b1a1965 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10165,7 +10165,7 @@ Type Boolean Value - 1 + 0 RenderUseTriStrips diff --git a/indra/newview/llfloaterpreference.cpp b/indra/newview/llfloaterpreference.cpp index 8a01eea912..2a22dd461a 100644 --- a/indra/newview/llfloaterpreference.cpp +++ b/indra/newview/llfloaterpreference.cpp @@ -1362,10 +1362,12 @@ void LLFloaterPreferenceGraphicsAdvanced::refreshEnabledState() ctrl_ssao->setEnabled(enabled); ctrl_dof->setEnabled(enabled); +#if USE_ADVANCED_ATMOSPHERICS LLCheckBoxCtrl* ctrl_advanced_atmo = getChild("UseAdvancedAtmo"); bool advanced_atmo_enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderUseAdvancedAtmospherics"); ctrl_advanced_atmo->setEnabled(advanced_atmo_enabled); +#endif enabled = enabled && LLFeatureManager::getInstance()->isFeatureAvailable("RenderShadowDetail"); @@ -2731,7 +2733,9 @@ LLFloaterPreferenceGraphicsAdvanced::LLFloaterPreferenceGraphicsAdvanced(const L : LLFloater(key) { mCommitCallbackRegistrar.add("Pref.VertexShaderEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onVertexShaderEnable, this)); +#if USE_ADVANCED_ATMOSPHERICS mCommitCallbackRegistrar.add("Pref.AdvancedAtmosphericsEnable", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::onAdvancedAtmosphericsEnable, this)); +#endif mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxNonImpostors", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxNonImpostors,this)); mCommitCallbackRegistrar.add("Pref.UpdateIndirectMaxComplexity", boost::bind(&LLFloaterPreferenceGraphicsAdvanced::updateMaxComplexity,this)); } diff --git a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml index d9bbf32583..4b202ec21e 100644 --- a/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml +++ b/indra/newview/skins/default/xui/en/floater_preferences_graphics_advanced.xml @@ -819,6 +819,7 @@ function="Pref.VertexShaderEnable" /> + Date: Tue, 11 Sep 2018 17:50:32 +0100 Subject: Merge advanced atmo WIP --- indra/newview/app_settings/settings.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index 214b1a1965..8f4faf51da 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -8664,7 +8664,7 @@ Type Boolean Value - 0 + 1 RenderLocalLights -- cgit v1.2.3