diff options
author | Graham Linden <graham@lindenlab.com> | 2018-10-08 22:08:35 +0100 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2018-10-08 22:08:35 +0100 |
commit | ffc6393309d06446f9d1361f0f0282b2110768ae (patch) | |
tree | f2a802ab7710126521be6826b8d5e3d5993de858 /indra | |
parent | 5eed233618abd7020e130799be2abe0f986543f6 (diff) |
SL-9751
Add optional moon brightness setting
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llinventory/llsettingssky.cpp | 18 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.h | 5 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.cpp | 2 | ||||
-rw-r--r-- | indra/llrender/llshadermgr.h | 4 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/moonF.glsl | 15 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/windlight/moonF.glsl | 18 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwlsky.cpp | 22 | ||||
-rw-r--r-- | indra/newview/llpaneleditsky.cpp | 12 | ||||
-rw-r--r-- | indra/newview/llpaneleditsky.h | 1 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/floater_edit_ext_day_cycle.xml | 6 | ||||
-rw-r--r-- | indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml | 29 |
11 files changed, 119 insertions, 13 deletions
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 21fde72941..dd3a76be31 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -102,6 +102,8 @@ const std::string LLSettingsSky::SETTING_MAX_Y("max_y"); const std::string LLSettingsSky::SETTING_MOON_ROTATION("moon_rotation"); const std::string LLSettingsSky::SETTING_MOON_SCALE("moon_scale"); const std::string LLSettingsSky::SETTING_MOON_TEXTUREID("moon_id"); +const std::string LLSettingsSky::SETTING_MOON_BRIGHTNESS("moon_brightness"); + const std::string LLSettingsSky::SETTING_STAR_BRIGHTNESS("star_brightness"); const std::string LLSettingsSky::SETTING_SUNLIGHT_COLOR("sunlight_color"); const std::string LLSettingsSky::SETTING_SUN_ROTATION("sun_rotation"); @@ -555,6 +557,9 @@ LLSettingsSky::validation_list_t LLSettingsSky::validationList() validation.push_back(Validator(SETTING_MOON_SCALE, false, LLSD::TypeReal, boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.25f)(20.0f))), LLSD::Real(1.0))); validation.push_back(Validator(SETTING_MOON_TEXTUREID, false, LLSD::TypeUUID)); + validation.push_back(Validator(SETTING_MOON_BRIGHTNESS, false, LLSD::TypeReal, + boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(1.0f))))); + validation.push_back(Validator(SETTING_STAR_BRIGHTNESS, true, LLSD::TypeReal, boost::bind(&Validator::verifyFloatRange, _1, LLSD(LLSDArray(0.0f)(500.0f))))); validation.push_back(Validator(SETTING_SUNLIGHT_COLOR, true, LLSD::TypeArray, @@ -686,6 +691,9 @@ LLSD LLSettingsSky::defaults(const LLSettingsBase::TrackPosition& position) dfltsetting[SETTING_MAX_Y] = LLSD::Real(1605); dfltsetting[SETTING_MOON_ROTATION] = moonquat.getValue(); + dfltsetting[SETTING_MOON_BRIGHTNESS] = LLSD::Real(0.5f); + dfltsetting[SETTING_MOON_TEXTUREID] = GetDefaultMoonTextureId(); + dfltsetting[SETTING_STAR_BRIGHTNESS] = LLSD::Real(256.0000); dfltsetting[SETTING_SUNLIGHT_COLOR] = LLColor4(0.7342, 0.7815, 0.8999, 0.0).getValue(); dfltsetting[SETTING_SUN_ROTATION] = sunquat.getValue(); @@ -1496,6 +1504,16 @@ void LLSettingsSky::setMoonTextureId(LLUUID id) setValue(SETTING_MOON_TEXTUREID, id); } +F32 LLSettingsSky::getMoonBrightness() const +{ + return mSettings[SETTING_MOON_BRIGHTNESS].asReal(); +} + +void LLSettingsSky::setMoonBrightness(F32 brightness_factor) +{ + setValue(SETTING_MOON_BRIGHTNESS, brightness_factor); +} + F32 LLSettingsSky::getStarBrightness() const { return mSettings[SETTING_STAR_BRIGHTNESS].asReal(); diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index fbae6739b8..89dd6d20fd 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -66,6 +66,8 @@ public: static const std::string SETTING_MOON_ROTATION; static const std::string SETTING_MOON_SCALE; static const std::string SETTING_MOON_TEXTUREID; + static const std::string SETTING_MOON_BRIGHTNESS; + static const std::string SETTING_STAR_BRIGHTNESS; static const std::string SETTING_SUNLIGHT_COLOR; static const std::string SETTING_SUN_ROTATION; @@ -205,6 +207,9 @@ public: LLUUID getMoonTextureId() const; void setMoonTextureId(LLUUID id); + F32 getMoonBrightness() const; + void setMoonBrightness(F32 brightness_factor); + F32 getStarBrightness() const; void setStarBrightness(F32 val); diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 153cef0317..3927632dbe 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1325,6 +1325,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("ice_level"); mReservedUniforms.push_back("rainbow_map"); mReservedUniforms.push_back("halo_map"); + mReservedUniforms.push_back("moon_brightness"); + mReservedUniforms.push_back("moon_phase"); llassert(mReservedUniforms.size() == END_RESERVED_UNIFORMS); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index ffdd2da529..489caa49ae 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -239,6 +239,10 @@ public: ICE_LEVEL, RAINBOW_MAP, HALO_MAP, + + MOON_BRIGHTNESS, + MOON_PHASE, + END_RESERVED_UNIFORMS } eGLSLReservedUniforms; diff --git a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index e86bca3ddd..f65a6eb32b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -39,6 +39,7 @@ vec3 fullbrightScaleSoftClip(vec3 light); uniform vec4 color; uniform vec4 sunlight_color; uniform vec3 lumWeights; +uniform float moon_brightness; uniform float minLuminance; uniform sampler2D diffuseMap; uniform sampler2D altDiffuseMap; @@ -51,15 +52,23 @@ void main() vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy); vec4 c = mix(moonA, moonB, blend_factor); + if (c.a < 0.1f) + { + discard; + } + c.rgb = pow(c.rgb, vec3(0.7f)); c.rgb = fullbrightAtmosTransport(c.rgb); c.rgb = fullbrightScaleSoftClip(c.rgb); // mix factor which blends when sunlight is brighter // and shows true moon color at night - vec3 luma_weights = vec3(0.1, 0.3, 0.0); - float mix = 1.0f - dot(sunlight_color.rgb, luma_weights); - frag_data[0] = vec4(c.rgb, mix * c.a); + vec3 luma_weights = vec3(0.2, 0.3, 0.2); + float mix = 1.0f - dot(normalize(sunlight_color.rgb), luma_weights); + + c.rgb = pow(c.rgb, 1.2 - vec3(mix * moon_brightness)); + + frag_data[0] = vec4(c.rgb, mix * (moon_brightness + (c.a * 0.25))); frag_data[1] = vec4(0.0); frag_data[2] = vec4(0.0f); } diff --git a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl index 933625986c..8cc7fc3bb5 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/moonF.glsl @@ -39,6 +39,7 @@ vec3 fullbrightScaleSoftClip(vec3 light); uniform vec4 color; uniform vec4 sunlight_color; uniform vec3 lumWeights; +uniform float moon_brightness; uniform float minLuminance; uniform sampler2D diffuseMap; uniform sampler2D altDiffuseMap; @@ -51,13 +52,22 @@ void main() vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy); vec4 c = mix(moonA, moonB, blend_factor); - c.rgb = pow(c.rgb, vec3(0.45f)); + if (c.a < 0.1f) + { + discard; + } + + c.rgb = pow(c.rgb, vec3(0.7f)); c.rgb = fullbrightAtmosTransport(c.rgb); c.rgb = fullbrightScaleSoftClip(c.rgb); + // mix factor which blends when sunlight is brighter // and shows true moon color at night - vec3 luma_weights = vec3(0.1, 0.3, 0.0); - float mix = 1.0f - dot(sunlight_color.rgb, luma_weights); - frag_color = vec4(c.rgb, mix * c.a); + vec3 luma_weights = vec3(0.2, 0.3, 0.2); + float mix = 1.0f - dot(normalize(sunlight_color.rgb), luma_weights); + + c.rgb = pow(c.rgb, 1.2 - vec3(mix * moon_brightness)); + + frag_color = vec4(c.rgb, mix * (moon_brightness + (c.a * 0.25))); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index d82cff516e..b89588a463 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -224,6 +224,22 @@ void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightL LLGLDisable blend(GL_BLEND); sky_shader->bind(); + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + LLViewerTexture* rainbow_tex = gSky.mVOSkyp->getRainbowTex(); + LLViewerTexture* halo_tex = gSky.mVOSkyp->getHaloTex(); + + sky_shader->bindTexture(LLShaderMgr::RAINBOW_MAP, rainbow_tex); + sky_shader->bindTexture(LLShaderMgr::HALO_MAP, halo_tex); + + F32 moisture_level = (float)psky->getSkyMoistureLevel(); + F32 droplet_radius = (float)psky->getSkyDropletRadius(); + F32 ice_level = (float)psky->getSkyIceLevel(); + + sky_shader->uniform1f(LLShaderMgr::MOISTURE_LEVEL, moisture_level); + sky_shader->uniform1f(LLShaderMgr::DROPLET_RADIUS, droplet_radius); + sky_shader->uniform1f(LLShaderMgr::ICE_LEVEL, ice_level); + /// Render the skydome renderDome(origin, camHeightLocal, sky_shader); @@ -484,6 +500,12 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() moon_shader->bindTexture(LLShaderMgr::ALTERNATE_DIFFUSE_MAP, tex_b, LLTexUnit::TT_TEXTURE); } + LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + + F32 moon_brightness = (float)psky->getMoonBrightness(); + + moon_shader->uniform1f(LLShaderMgr::MOON_BRIGHTNESS, moon_brightness); + moon_shader->uniform4fv(LLShaderMgr::DIFFUSE_COLOR, 1, color.mV); moon_shader->uniform1f(LLShaderMgr::BLEND_FACTOR, blend_factor); diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index faba2b7ed1..0d8c9a988a 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -72,6 +72,7 @@ namespace const std::string FIELD_SKY_MOON_ROTATION("moon_rotation"); const std::string FIELD_SKY_MOON_IMAGE("moon_image"); const std::string FIELD_SKY_MOON_SCALE("moon_scale"); + const std::string FIELD_SKY_MOON_BRIGHTNESS("moon_brightness"); const std::string FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL("rayleigh_exponential"); const std::string FIELD_SKY_DENSITY_RAYLEIGH_EXPONENTIAL_SCALE("rayleigh_exponential_scale"); @@ -398,6 +399,7 @@ BOOL LLPanelSettingsSkySunMoonTab::postBuild() getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setAllowNoTexture(TRUE); getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setAllowLocalTexture(FALSE); getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonScaleChanged(); }); + getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setCommitCallback([this](LLUICtrl *, const LLSD &) { onMoonBrightnessChanged(); }); refresh(); @@ -411,6 +413,9 @@ void LLPanelSettingsSkySunMoonTab::setEnabled(BOOL enabled) getChild<LLUICtrl>(FIELD_SKY_GLOW_FOCUS)->setEnabled(enabled); getChild<LLUICtrl>(FIELD_SKY_GLOW_SIZE)->setEnabled(enabled); getChild<LLUICtrl>(FIELD_SKY_STAR_BRIGHTNESS)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_SUN_SCALE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setEnabled(enabled); + getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setEnabled(enabled); } void LLPanelSettingsSkySunMoonTab::refresh() @@ -438,6 +443,7 @@ void LLPanelSettingsSkySunMoonTab::refresh() getChild<LLVirtualTrackball>(FIELD_SKY_MOON_ROTATION)->setRotation(mSkySettings->getMoonRotation()); getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->setValue(mSkySettings->getMoonTextureId()); getChild<LLUICtrl>(FIELD_SKY_MOON_SCALE)->setValue(mSkySettings->getMoonScale()); + getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->setValue(mSkySettings->getMoonBrightness()); } //------------------------------------------------------------------------- @@ -513,6 +519,12 @@ void LLPanelSettingsSkySunMoonTab::onMoonScaleChanged() setIsDirty(); } +void LLPanelSettingsSkySunMoonTab::onMoonBrightnessChanged() +{ + mSkySettings->setMoonBrightness((getChild<LLUICtrl>(FIELD_SKY_MOON_BRIGHTNESS)->getValue().asReal())); + mSkySettings->update(); + setIsDirty(); +} LLPanelSettingsSkyDensityTab::LLPanelSettingsSkyDensityTab() { diff --git a/indra/newview/llpaneleditsky.h b/indra/newview/llpaneleditsky.h index e9d956de74..829a65dae5 100644 --- a/indra/newview/llpaneleditsky.h +++ b/indra/newview/llpaneleditsky.h @@ -123,6 +123,7 @@ private: void onSunImageChanged(); void onMoonRotationChanged(); void onMoonScaleChanged(); + void onMoonBrightnessChanged(); void onMoonImageChanged(); }; 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 e1c08a24f2..9aa7c6f499 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 @@ -6,9 +6,9 @@ save_rect="false" title="Edit Day Cycle" width="705" - height="650" + height="700" min_width="705" - min_height="650" + min_height="700" single_instance="true" can_resize="false"> @@ -25,7 +25,7 @@ <!-- Layout --> <layout_stack name="outer_stack" width="705" - height="650" + height="700" follows="all" animate="false" top="0" diff --git a/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml b/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml index 6d12f6bb94..1332ecd965 100644 --- a/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml +++ b/indra/newview/skins/default/xui/en/panel_settings_sky_sunmoon.xml @@ -14,14 +14,14 @@ top="5" right="-5" bottom="-5" - orientation="hoizontal"> + orientation="horizontal"> <layout_panel border="true" bevel_style="in" auto_resize="true" user_resize="false" visible="true" - height="350"> + height="400"> <text follows="left|top" height="10" @@ -176,6 +176,29 @@ top_delta="15" width="250" can_edit_text="true"/> + <text + follows="left|top" + height="10" + layout="topleft" + left_delta="-5" + top_delta="22" + width="200"> + Moon Brightness: + </text> + <slider + decimal_digits="2" + follows="left|top" + height="16" + increment="0.01" + initial_value="0" + layout="topleft" + left_delta="5" + min_val="0.0" + max_val="1.0" + name="moon_brightness" + top_delta="15" + width="250" + can_edit_text="true"/> </layout_panel> <layout_panel border="false" @@ -183,7 +206,7 @@ auto_resize="true" user_resize="false" visible="true" - height="350"> + height="400"> <layout_stack left="5" top="5" |