diff options
24 files changed, 541 insertions, 323 deletions
diff --git a/indra/llinventory/llsettingsbase.cpp b/indra/llinventory/llsettingsbase.cpp index 1b3b5d2576..a261c98bb1 100644 --- a/indra/llinventory/llsettingsbase.cpp +++ b/indra/llinventory/llsettingsbase.cpp @@ -206,7 +206,9 @@ LLSD LLSettingsBase::interpolateSDMap(const LLSD &settings, const LLSD &other, F if (slerps.find(key_name) != slerps.end()) { - LLQuaternion q = slerp(mix, LLQuaternion(value), LLQuaternion(other_value)); + LLQuaternion a(value); + LLQuaternion b(other_value); + LLQuaternion q = slerp(mix, a, b); newvalue = q.getValue(); } else diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index f02500d61b..bb310806bd 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -386,6 +386,9 @@ void LLSettingsSky::blend(const LLSettingsBase::ptr_t &end, F64 blendf) LLSD blenddata = interpolateSDMap(mSettings, other->mSettings, blendf); replaceSettings(blenddata); + mPositionsDirty = true; + mLightingDirty = true; + setBlendFactor(blendf); mNextSunTextureId = other->getSunTextureId(); mNextMoonTextureId = other->getMoonTextureId(); @@ -771,11 +774,14 @@ LLSD LLSettingsSky::translateLegacySettings(const LLSD& legacy) void LLSettingsSky::updateSettings() { - mPositionsDirty = isDirty(); - mLightingDirty = isDirty(); - // base class clears dirty flag so as to not trigger recursive update LLSettingsBase::updateSettings(); + + // NOTE: these functions are designed to do nothing unless a dirty bit has been set + // so if you add new settings that are referenced by these update functions, + // you'll need to insure that your setter updates the dirty bits as well + calculateHeavenlyBodyPositions(); + calculateLightSettings(); } bool LLSettingsSky::getIsSunUp() const @@ -792,10 +798,11 @@ bool LLSettingsSky::getIsMoonUp() const void LLSettingsSky::calculateHeavenlyBodyPositions() const { + /* can't do this as it gets defeated during animation of env panel settings if (!mPositionsDirty) { return; - } + }*/ mPositionsDirty = false; @@ -811,7 +818,7 @@ void LLSettingsSky::calculateHeavenlyBodyPositions() const LLVector3 LLSettingsSky::getLightDirection() const { - calculateHeavenlyBodyPositions(); + update(); // is the normal from the sun or the moon if (getIsSunUp()) @@ -955,60 +962,61 @@ LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const LLVector3 LLSettingsSky::getSunDirection() const { - calculateHeavenlyBodyPositions(); + update(); return mSunDirection; } LLVector3 LLSettingsSky::getMoonDirection() const { - calculateHeavenlyBodyPositions(); + update(); return mMoonDirection; } LLColor4U LLSettingsSky::getFadeColor() const { - calculateLightSettings(); + update(); return mFadeColor; } LLColor4 LLSettingsSky::getMoonAmbient() const { - calculateLightSettings(); + update(); return mMoonAmbient; } LLColor3 LLSettingsSky::getMoonDiffuse() const { - calculateLightSettings(); + update(); return mMoonDiffuse; } LLColor4 LLSettingsSky::getSunAmbient() const { - calculateLightSettings(); + update(); return mSunAmbient; } LLColor3 LLSettingsSky::getSunDiffuse() const { - calculateLightSettings(); + update(); return mSunDiffuse; } LLColor4 LLSettingsSky::getTotalAmbient() const { - calculateLightSettings(); + update(); return mTotalAmbient; } void LLSettingsSky::calculateLightSettings() const { + /* can't do this as it gets defeated during animation of env panel settings if (!mLightingDirty) { return; } - calculateHeavenlyBodyPositions(); + calculateHeavenlyBodyPositions();*/ mLightingDirty = false; @@ -1068,3 +1076,266 @@ LLUUID LLSettingsSky::GetDefaultCloudNoiseTextureId() { return DEFAULT_CLOUD_ID; } + +F32 LLSettingsSky::getPlanetRadius() const +{ + return mSettings[SETTING_PLANET_RADIUS].asReal(); +} + +F32 LLSettingsSky::getSkyBottomRadius() const +{ + return mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal(); +} + +F32 LLSettingsSky::getSkyTopRadius() const +{ + return mSettings[SETTING_SKY_TOP_RADIUS].asReal(); +} + +F32 LLSettingsSky::getSunArcRadians() const +{ + return mSettings[SETTING_SUN_ARC_RADIANS].asReal(); +} + +F32 LLSettingsSky::getMieAnisotropy() const +{ + return mSettings[SETTING_MIE_ANISOTROPY_FACTOR].asReal(); +} + +LLSD LLSettingsSky::getRayleighConfigs() const +{ + return mSettings[SETTING_RAYLEIGH_CONFIG]; +} + +LLSD LLSettingsSky::getMieConfigs() const +{ + return mSettings[SETTING_MIE_CONFIG]; +} + +LLSD LLSettingsSky::getAbsorptionConfigs() const +{ + return mSettings[SETTING_ABSORPTION_CONFIG]; +} + +LLUUID LLSettingsSky::getBloomTextureId() const +{ + return mSettings[SETTING_BLOOM_TEXTUREID].asUUID(); +} + +//--------------------------------------------------------------------- +LLColor3 LLSettingsSky::getAmbientColor() const +{ + return LLColor3(mSettings[SETTING_AMBIENT]); +} + +void LLSettingsSky::setAmbientColor(const LLColor3 &val) +{ + setValue(SETTING_AMBIENT, val); + mLightingDirty = true; +} + +LLColor3 LLSettingsSky::getCloudColor() const +{ + return LLColor3(mSettings[SETTING_CLOUD_COLOR]); +} + +void LLSettingsSky::setCloudColor(const LLColor3 &val) +{ + setValue(SETTING_CLOUD_COLOR, val); +} + +LLUUID LLSettingsSky::getCloudNoiseTextureId() const +{ + return mSettings[SETTING_CLOUD_TEXTUREID].asUUID(); +} + +void LLSettingsSky::setCloudNoiseTextureId(const LLUUID &id) +{ + setValue(SETTING_CLOUD_TEXTUREID, id); +} + +LLColor3 LLSettingsSky::getCloudPosDensity1() const +{ + return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY1]); +} + +void LLSettingsSky::setCloudPosDensity1(const LLColor3 &val) +{ + setValue(SETTING_CLOUD_POS_DENSITY1, val); +} + +LLColor3 LLSettingsSky::getCloudPosDensity2() const +{ + return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY2]); +} + +void LLSettingsSky::setCloudPosDensity2(const LLColor3 &val) +{ + setValue(SETTING_CLOUD_POS_DENSITY2, val); +} + +F32 LLSettingsSky::getCloudScale() const +{ + return mSettings[SETTING_CLOUD_SCALE].asReal(); +} + +void LLSettingsSky::setCloudScale(F32 val) +{ + setValue(SETTING_CLOUD_SCALE, val); +} + +LLVector2 LLSettingsSky::getCloudScrollRate() const +{ + return LLVector2(mSettings[SETTING_CLOUD_SCROLL_RATE]); +} + +void LLSettingsSky::setCloudScrollRate(const LLVector2 &val) +{ + setValue(SETTING_CLOUD_SCROLL_RATE, val); +} + +void LLSettingsSky::setCloudScrollRateX(F32 val) +{ + mSettings[SETTING_CLOUD_SCROLL_RATE][0] = val; + setDirtyFlag(true); +} + +void LLSettingsSky::setCloudScrollRateY(F32 val) +{ + mSettings[SETTING_CLOUD_SCROLL_RATE][1] = val; + setDirtyFlag(true); +} + +F32 LLSettingsSky::getCloudShadow() const +{ + return mSettings[SETTING_CLOUD_SHADOW].asReal(); +} + +void LLSettingsSky::setCloudShadow(F32 val) +{ + setValue(SETTING_CLOUD_SHADOW, val); + mLightingDirty = true; +} + +F32 LLSettingsSky::getDomeOffset() const +{ + //return mSettings[SETTING_DOME_OFFSET].asReal(); + return DOME_OFFSET; +} + +F32 LLSettingsSky::getDomeRadius() const +{ + //return mSettings[SETTING_DOME_RADIUS].asReal(); + return DOME_RADIUS; +} + +F32 LLSettingsSky::getGamma() const +{ + return mSettings[SETTING_GAMMA].asReal(); +} + +void LLSettingsSky::setGamma(F32 val) +{ + mSettings[SETTING_GAMMA] = LLSD::Real(val); + setDirtyFlag(true); + mLightingDirty = true; +} + +LLColor3 LLSettingsSky::getGlow() const +{ + return LLColor3(mSettings[SETTING_GLOW]); +} + +void LLSettingsSky::setGlow(const LLColor3 &val) +{ + setValue(SETTING_GLOW, val); + mLightingDirty = true; +} + +F32 LLSettingsSky::getMaxY() const +{ + return mSettings[SETTING_MAX_Y].asReal(); +} + +void LLSettingsSky::setMaxY(F32 val) +{ + setValue(SETTING_MAX_Y, val); +} + +LLQuaternion LLSettingsSky::getMoonRotation() const +{ + return LLQuaternion(mSettings[SETTING_MOON_ROTATION]); +} + +void LLSettingsSky::setMoonRotation(const LLQuaternion &val) +{ + setValue(SETTING_MOON_ROTATION, val); + mPositionsDirty = true; +} + +LLUUID LLSettingsSky::getMoonTextureId() const +{ + return mSettings[SETTING_MOON_TEXTUREID].asUUID(); +} + +void LLSettingsSky::setMoonTextureId(LLUUID id) +{ + setValue(SETTING_MOON_TEXTUREID, id); +} + +F32 LLSettingsSky::getStarBrightness() const +{ + return mSettings[SETTING_STAR_BRIGHTNESS].asReal(); +} + +void LLSettingsSky::setStarBrightness(F32 val) +{ + setValue(SETTING_STAR_BRIGHTNESS, val); +} + +LLColor3 LLSettingsSky::getSunlightColor() const +{ + return LLColor3(mSettings[SETTING_SUNLIGHT_COLOR]); +} + +void LLSettingsSky::setSunlightColor(const LLColor3 &val) +{ + setValue(SETTING_SUNLIGHT_COLOR, val); + mLightingDirty = true; +} + +LLQuaternion LLSettingsSky::getSunRotation() const +{ + return LLQuaternion(mSettings[SETTING_SUN_ROTATION]); +} + +void LLSettingsSky::setSunRotation(const LLQuaternion &val) +{ + setValue(SETTING_SUN_ROTATION, val); + mPositionsDirty = true; +} + +LLUUID LLSettingsSky::getSunTextureId() const +{ + return mSettings[SETTING_SUN_TEXTUREID].asUUID(); +} + +void LLSettingsSky::setSunTextureId(LLUUID id) +{ + setValue(SETTING_SUN_TEXTUREID, id); +} + +LLUUID LLSettingsSky::getNextSunTextureId() const +{ + return mNextSunTextureId; +} + +LLUUID LLSettingsSky::getNextMoonTextureId() const +{ + return mNextMoonTextureId; +} + +LLUUID LLSettingsSky::getNextCloudNoiseTextureId() const +{ + return mNextCloudTextureId; +} diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 299e679b6a..a557080744 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -105,267 +105,85 @@ public: static LLSD defaults(); - F32 getPlanetRadius() const - { - return mSettings[SETTING_PLANET_RADIUS].asReal(); - } - - F32 getSkyBottomRadius() const - { - return mSettings[SETTING_SKY_BOTTOM_RADIUS].asReal(); - } - - F32 getSkyTopRadius() const - { - return mSettings[SETTING_SKY_TOP_RADIUS].asReal(); - } - - F32 getSunArcRadians() const - { - return mSettings[SETTING_SUN_ARC_RADIANS].asReal(); - } - - F32 getMieAnisotropy() const - { - return mSettings[SETTING_MIE_ANISOTROPY_FACTOR].asReal(); - } - - LLSD getRayleighConfigs() const - { - return mSettings[SETTING_RAYLEIGH_CONFIG]; - } - - LLSD getMieConfigs() const - { - return mSettings[SETTING_MIE_CONFIG]; - } - - LLSD getAbsorptionConfigs() const - { - return mSettings[SETTING_ABSORPTION_CONFIG]; - } - - LLUUID getBloomTextureId() const - { - return mSettings[SETTING_BLOOM_TEXTUREID].asUUID(); - } + F32 getPlanetRadius() const; + F32 getSkyBottomRadius() const; + F32 getSkyTopRadius() const; + F32 getSunArcRadians() const; + F32 getMieAnisotropy() const; + LLSD getRayleighConfigs() const; + LLSD getMieConfigs() const; + + LLSD getAbsorptionConfigs() const; + LLUUID getBloomTextureId() const; //--------------------------------------------------------------------- - LLColor3 getAmbientColor() const - { - return LLColor3(mSettings[SETTING_AMBIENT]); - } - - void setAmbientColor(const LLColor3 &val) - { - setValue(SETTING_AMBIENT, val); - } - - LLColor3 getCloudColor() const - { - return LLColor3(mSettings[SETTING_CLOUD_COLOR]); - } - - void setCloudColor(const LLColor3 &val) - { - setValue(SETTING_CLOUD_COLOR, val); - } - - LLUUID getCloudNoiseTextureId() const - { - return mSettings[SETTING_CLOUD_TEXTUREID].asUUID(); - } - - void setCloudNoiseTextureId(const LLUUID &id) - { - setValue(SETTING_CLOUD_TEXTUREID, id); - } - - LLColor3 getCloudPosDensity1() const - { - return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY1]); - } - - void setCloudPosDensity1(const LLColor3 &val) - { - setValue(SETTING_CLOUD_POS_DENSITY1, val); - } - - LLColor3 getCloudPosDensity2() const - { - return LLColor3(mSettings[SETTING_CLOUD_POS_DENSITY2]); - } - - void setCloudPosDensity2(const LLColor3 &val) - { - setValue(SETTING_CLOUD_POS_DENSITY2, val); - } - - F32 getCloudScale() const - { - return mSettings[SETTING_CLOUD_SCALE].asReal(); - } - - void setCloudScale(F32 val) - { - setValue(SETTING_CLOUD_SCALE, val); - } - - LLVector2 getCloudScrollRate() const - { - return LLVector2(mSettings[SETTING_CLOUD_SCROLL_RATE]); - } - - void setCloudScrollRate(const LLVector2 &val) - { - setValue(SETTING_CLOUD_SCROLL_RATE, val); - } - - void setCloudScrollRateX(F32 val) - { - mSettings[SETTING_CLOUD_SCROLL_RATE][0] = val; - setDirtyFlag(true); - } - - void setCloudScrollRateY(F32 val) - { - mSettings[SETTING_CLOUD_SCROLL_RATE][1] = val; - setDirtyFlag(true); - } - - F32 getCloudShadow() const - { - return mSettings[SETTING_CLOUD_SHADOW].asReal(); - } - - void setCloudShadow(F32 val) - { - setValue(SETTING_CLOUD_SHADOW, val); - } + LLColor3 getAmbientColor() const; + void setAmbientColor(const LLColor3 &val); + + LLColor3 getCloudColor() const; + void setCloudColor(const LLColor3 &val); + + LLUUID getCloudNoiseTextureId() const; + void setCloudNoiseTextureId(const LLUUID &id); + + LLColor3 getCloudPosDensity1() const; + void setCloudPosDensity1(const LLColor3 &val); + + LLColor3 getCloudPosDensity2() const; + void setCloudPosDensity2(const LLColor3 &val); + F32 getCloudScale() const; + void setCloudScale(F32 val); + + LLVector2 getCloudScrollRate() const; + void setCloudScrollRate(const LLVector2 &val); + + void setCloudScrollRateX(F32 val); + void setCloudScrollRateY(F32 val); + + F32 getCloudShadow() const; + void setCloudShadow(F32 val); - F32 getDomeOffset() const - { - return DOME_OFFSET; - //return mSettings[SETTING_DOME_OFFSET].asReal(); - } - - F32 getDomeRadius() const - { - return DOME_RADIUS; - //return mSettings[SETTING_DOME_RADIUS].asReal(); - } - - F32 getGamma() const - { - return mSettings[SETTING_GAMMA].asReal(); - } - - void setGamma(F32 val) - { - mSettings[SETTING_GAMMA] = LLSD::Real(val); - setDirtyFlag(true); - } - - LLColor3 getGlow() const - { - return LLColor3(mSettings[SETTING_GLOW]); - } - - void setGlow(const LLColor3 &val) - { - setValue(SETTING_GLOW, val); - } - - F32 getMaxY() const - { - return mSettings[SETTING_MAX_Y].asReal(); - } - - void setMaxY(F32 val) - { - setValue(SETTING_MAX_Y, val); - } - - LLQuaternion getMoonRotation() const - { - return LLQuaternion(mSettings[SETTING_MOON_ROTATION]); - } - - void setMoonRotation(const LLQuaternion &val) - { - setValue(SETTING_MOON_ROTATION, val); - } - - LLUUID getMoonTextureId() const - { - return mSettings[SETTING_MOON_TEXTUREID].asUUID(); - } - - void setMoonTextureId(LLUUID id) - { - setValue(SETTING_MOON_TEXTUREID, id); - } - - F32 getStarBrightness() const - { - return mSettings[SETTING_STAR_BRIGHTNESS].asReal(); - } - - void setStarBrightness(F32 val) - { - setValue(SETTING_STAR_BRIGHTNESS, val); - } - - LLColor3 getSunlightColor() const - { - return LLColor3(mSettings[SETTING_SUNLIGHT_COLOR]); - } - - void setSunlightColor(const LLColor3 &val) - { - setValue(SETTING_SUNLIGHT_COLOR, val); - } - - LLQuaternion getSunRotation() const - { - return LLQuaternion(mSettings[SETTING_SUN_ROTATION]); - } - - void setSunRotation(const LLQuaternion &val) - { - setValue(SETTING_SUN_ROTATION, val); - } - - LLUUID getSunTextureId() const - { - return mSettings[SETTING_SUN_TEXTUREID].asUUID(); - } - - void setSunTextureId(LLUUID id) - { - setValue(SETTING_SUN_TEXTUREID, id); - } + F32 getDomeOffset() const; + F32 getDomeRadius() const; - //===================================================================== - // transient properties used in animations. - LLUUID getNextSunTextureId() const - { - return mNextSunTextureId; - } + F32 getGamma() const; + + void setGamma(F32 val); - LLUUID getNextMoonTextureId() const - { - return mNextMoonTextureId; - } + LLColor3 getGlow() const; + void setGlow(const LLColor3 &val); - LLUUID getNextCloudNoiseTextureId() const - { - return mNextCloudTextureId; - } + F32 getMaxY() const; + + void setMaxY(F32 val); + + LLQuaternion getMoonRotation() const; + void setMoonRotation(const LLQuaternion &val); + + LLUUID getMoonTextureId() const; + void setMoonTextureId(LLUUID id); + + F32 getStarBrightness() const; + void setStarBrightness(F32 val); + + LLColor3 getSunlightColor() const; + void setSunlightColor(const LLColor3 &val); + + LLQuaternion getSunRotation() const; + void setSunRotation(const LLQuaternion &val) ; + + LLUUID getSunTextureId() const; + void setSunTextureId(LLUUID id); //===================================================================== - virtual void loadTextures() { }; + // transient properties used in animations. + LLUUID getNextSunTextureId() const; + LLUUID getNextMoonTextureId() const; + LLUUID getNextCloudNoiseTextureId() const; + + //===================================================================== + virtual void loadTextures() { }; //===================================================================== virtual validation_list_t getValidationList() const SETTINGS_OVERRIDE; @@ -380,7 +198,6 @@ public: LLColor3 getLightTransmittance() const; LLColor3 gammaCorrect(const LLColor3& in) const; - LLColor3 getBlueDensity() const; LLColor3 getBlueHorizon() const; F32 getHazeDensity() const; diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index 716ec8750a..037786ec49 100644 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1212,6 +1212,7 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("spot_shadow_bias"); mReservedUniforms.push_back("spot_shadow_offset"); mReservedUniforms.push_back("sun_dir"); + mReservedUniforms.push_back("moon_dir"); mReservedUniforms.push_back("shadow_res"); mReservedUniforms.push_back("proj_shadow_res"); mReservedUniforms.push_back("depth_cutoff"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index 9bb6660e54..53d59dbbf8 100644 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -134,6 +134,7 @@ public: DEFERRED_SPOT_SHADOW_BIAS, DEFERRED_SPOT_SHADOW_OFFSET, DEFERRED_SUN_DIR, + DEFERRED_MOON_DIR, DEFERRED_SHADOW_RES, DEFERRED_PROJ_SHADOW_RES, DEFERRED_DEPTH_CUTOFF, diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index 2234ceeb53..8dda96984e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -43,6 +43,7 @@ uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; +uniform vec3 moon_dir; #if HAS_SHADOW uniform sampler2DShadow shadowMap0; @@ -287,7 +288,10 @@ void main() vec2 abnormal = encode_normal(norm.xyz); norm.xyz = decode_normal(abnormal.xy); - float da = dot(norm.xyz, sun_dir.xyz); + float da_sun = dot(norm.xyz, sun_dir.xyz); + float da_moon = dot(norm.xyz, moon_dir.xyz); + + float da = max(da_sun, da_moon); float final_da = da; final_da = min(final_da, shadow); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index a90e433622..4dc15dbc89 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -98,6 +98,7 @@ uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; +uniform vec3 moon_dir; VARYING vec2 vary_fragcoord; VARYING vec3 vary_position; @@ -388,7 +389,9 @@ void main() vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); - float da =dot(norm.xyz, sun_dir.xyz); + float da_sun =dot(norm.xyz, sun_dir.xyz); + float da_moon =dot(norm.xyz, moon_dir.xyz); + float da = max(da_sun, da_moon); float final_da = da; final_da = min(final_da, shadow); @@ -418,7 +421,10 @@ void main() // the old infinite-sky shiny reflection // - float sa = dot(refnormpersp, sun_dir.xyz); + float sa_sun = dot(refnormpersp, sun_dir.xyz); + float sa_moon = dot(refnormpersp, moon_dir.xyz); + float sa = max(sa_sun, sa_moon); + vec3 dumbshiny = sunlit*shadow*(texture2D(lightFunc, vec2(sa, spec.a)).r); // add the two types of shiny together diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index fbfd43a4da..a4543c325e 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -56,6 +56,7 @@ uniform mat3 env_mat; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; +uniform vec3 moon_dir; VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; @@ -106,7 +107,9 @@ void main() float envIntensity = norm.z; norm.xyz = decode_normal(norm.xy); // unpack norm - float da = dot(norm.xyz, sun_dir.xyz); + float da_sun = dot(norm.xyz, sun_dir.xyz); + float da_moon = dot(norm.xyz, moon_dir.xyz); + float da = max(da_sun, da_moon); float final_da = max(0.0,da); final_da = min(final_da, 1.0f); @@ -148,7 +151,10 @@ void main() // the old infinite-sky shiny reflection // - float sa = dot(refnormpersp, sun_dir.xyz); + float sa_sun = dot(refnormpersp, sun_dir.xyz); + float sa_moon = dot(refnormpersp, moon_dir.xyz); + float sa = max(sa_sun, sa_moon); + vec3 dumbshiny = sunlit*(texture2D(lightFunc, vec2(sa, spec.a)).r); // add the two types of shiny together diff --git a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl index a7c28a1ac3..68ce2843d0 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterFogF.glsl @@ -25,7 +25,6 @@ -uniform vec4 lightnorm; uniform vec4 waterPlane; uniform vec4 waterFogColor; uniform float waterFogDensity; diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 9f56bff4c2..5046ede00d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -49,7 +49,6 @@ uniform vec4 morphFactor; uniform vec3 camPosLocal; //uniform vec4 camPosWorld; uniform vec4 gamma; -uniform vec4 lightnorm; uniform vec4 sunlight_color; uniform vec4 ambient; uniform vec4 blue_horizon; @@ -68,6 +67,7 @@ uniform vec4 shadow_clip; uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; +uniform vec3 moon_dir; VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; @@ -117,7 +117,9 @@ void main() float envIntensity = norm.z; norm.xyz = decode_normal(norm.xy); // unpack norm - float da = max(dot(norm.xyz, sun_dir.xyz), 0.0); + float da_sun = max(dot(norm.xyz, sun_dir.xyz), 0.0); + float da_moon = max(dot(norm.xyz, moon_dir.xyz), 0.0); + float da = max(da_sun, da_moon); float light_gamma = 1.0/1.3; da = pow(da, light_gamma); @@ -168,7 +170,9 @@ void main() // the old infinite-sky shiny reflection // - float sa = dot(refnormpersp, sun_dir.xyz); + float sa_sun = dot(refnormpersp, sun_dir.xyz); + float sa_moon = dot(refnormpersp, moon_dir.xyz); + float sa = max(sa_sun, sa_moon); vec3 dumbshiny = sunlit*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r); // add the two types of shiny together diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl index aa5e99a2f7..11ccdf638c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl @@ -59,6 +59,7 @@ uniform mat4 inv_proj; uniform vec2 screen_res; uniform vec2 proj_shadow_res; uniform vec3 sun_dir; +uniform vec3 moon_dir; uniform vec2 shadow_res; uniform float shadow_bias; @@ -139,10 +140,14 @@ void main() }*/ float shadow = 0.0; - float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); + float da_sun = dot(norm, sun_dir.xyz); + float da_moon = dot(norm, moon_dir.xyz); + float da = max(da_sun, da_moon); + + float dp_directional_light = max(0.0, da); vec3 shadow_pos = pos.xyz; - vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); + vec3 offset = ((da_sun > da_moon) ? sun_dir.xyz : moon_dir.xyz) * (1.0-dp_directional_light); vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl index 58f3f2f91e..4fccb1d33c 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl @@ -59,6 +59,7 @@ uniform mat4 inv_proj; uniform vec2 screen_res; uniform vec2 proj_shadow_res; uniform vec3 sun_dir; +uniform vec3 moon_dir; uniform vec2 shadow_res; @@ -200,10 +201,13 @@ void main() }*/ float shadow = 0.0; - float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz)); + float da_sun = dot(norm, sun_dir.xyz); + float da_moon = dot(norm, moon_dir.xyz); + float da = max(da_sun, da_moon); + float dp_directional_light = max(0.0, da); vec3 shadow_pos = pos.xyz; - vec3 offset = sun_dir.xyz * (1.0-dp_directional_light); + vec3 offset = ((da_sun > da_moon) ? sun_dir.xyz : moon_dir.xyz) * (1.0-dp_directional_light); vec4 spos = vec4(shadow_pos+offset*shadow_offset, 1.0); diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl index a439aa64d7..0fb990611e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl @@ -34,6 +34,7 @@ in vec3 view_dir; uniform vec3 cameraPosLocal; uniform vec3 sun_dir; +uniform vec3 moon_dir; uniform float sun_size; uniform sampler2D transmittance_texture; @@ -42,9 +43,9 @@ uniform sampler3D single_mie_scattering_texture; uniform sampler2D irradiance_texture; vec3 GetSolarLuminance(); -vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 sun_dir, out vec3 transmittance); -vec3 GetSkyLuminanceToPoint(vec3 camPos, vec3 pos, float shadow_length, vec3 sun_dir, out vec3 transmittance); -vec3 GetSunAndSkyIlluminance(vec3 pos, vec3 norm, vec3 sun_dir, out vec3 sky_irradiance); +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() { @@ -55,8 +56,9 @@ void main() vec3 camPos = cameraPosLocal + vec3(0, 0, 6360.0f); vec3 transmittance; vec3 sky_illum; - vec3 radiance = GetSkyLuminance(camPos, view_direction, 0.0f, sun_direction, transmittance); - vec3 radiance2 = GetSunAndSkyIlluminance(camPos, view_direction, sun_direction, 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 *= transmittance; diff --git a/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl b/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl index fed3edf7de..bdb54a1d63 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl @@ -33,6 +33,7 @@ in vec3 view_dir; uniform vec3 cameraPosLocal; uniform vec3 sun_dir; +uniform vec3 moon_dir; uniform float sun_size; uniform sampler2D transmittance_texture; diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 0126f1e2ca..4b77e18c15 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -151,11 +151,13 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->bindTexture(LLShaderMgr::ILLUMINANCE_TEX, gAtmosphere->getIlluminance()); LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLVector4 light_dir = LLEnvironment::instance().getClampedLightNorm(); + LLVector4 sun_dir = LLEnvironment::instance().getClampedSunNorm(); + LLVector4 moon_dir = LLEnvironment::instance().getClampedMoonNorm(); F32 sunSize = (float)cosf(psky->getSunArcRadians()); sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize); - sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, light_dir.mV); + sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, sun_dir.mV); + sky_shader->uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, moon_dir.mV); // clouds are rendered along with sky in adv atmo if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && gSky.mVOSkyp->getCloudNoiseTex()) diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index a5ee7d0737..f0bec2fda1 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -700,6 +700,18 @@ void LLEnvironment::updateEnvironment(LLSettingsBase::Seconds transition, bool f } } +LLVector4 LLEnvironment::toCFR(const LLVector3 vec) const +{ + LLVector4 vec_cfr(vec.mV[1], vec.mV[0], vec.mV[2], 0.0f); + return vec_cfr; +} + +LLVector4 LLEnvironment::toLightNorm(const LLVector3 vec) const +{ + LLVector4 vec_ogl(vec.mV[1], vec.mV[2], vec.mV[0], 0.0f); + return vec_ogl; +} + LLVector3 LLEnvironment::getLightDirection() const { LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); @@ -710,16 +722,24 @@ LLVector3 LLEnvironment::getLightDirection() const return psky->getLightDirection(); } -LLVector4 LLEnvironment::toCFR(const LLVector3 vec) const +LLVector3 LLEnvironment::getSunDirection() const { - LLVector4 vec_cfr(vec.mV[1], vec.mV[0], vec.mV[2], 0.0f); - return vec_cfr; + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + if (!psky) + { + return LLVector3(0, 0, 1); + } + return psky->getSunDirection(); } -LLVector4 LLEnvironment::toLightNorm(const LLVector3 vec) const +LLVector3 LLEnvironment::getMoonDirection() const { - LLVector4 vec_ogl(vec.mV[1], vec.mV[2], vec.mV[0], 0.0f); - return vec_ogl; + LLSettingsSky::ptr_t psky = mCurrentEnvironment->getSky(); + if (!psky) + { + return LLVector3(0, 0, -1); + } + return psky->getMoonDirection(); } LLVector4 LLEnvironment::getLightDirectionCFR() const @@ -729,6 +749,20 @@ LLVector4 LLEnvironment::getLightDirectionCFR() const return light_direction_cfr; } +LLVector4 LLEnvironment::getSunDirectionCFR() const +{ + LLVector3 light_direction = getSunDirection(); + LLVector4 light_direction_cfr = toCFR(light_direction); + return light_direction_cfr; +} + +LLVector4 LLEnvironment::getMoonDirectionCFR() const +{ + LLVector3 light_direction = getMoonDirection(); + LLVector4 light_direction_cfr = toCFR(light_direction); + return light_direction_cfr; +} + LLVector4 LLEnvironment::getClampedLightNorm() const { LLVector3 light_direction = getLightDirection(); @@ -739,6 +773,26 @@ LLVector4 LLEnvironment::getClampedLightNorm() const return toLightNorm(light_direction); } +LLVector4 LLEnvironment::getClampedSunNorm() const +{ + LLVector3 light_direction = getSunDirection(); + if (light_direction.mV[2] < -0.1f) + { + light_direction.mV[2] = -0.1f; + } + return toLightNorm(light_direction); +} + +LLVector4 LLEnvironment::getClampedMoonNorm() const +{ + LLVector3 light_direction = getMoonDirection(); + if (light_direction.mV[2] < -0.1f) + { + light_direction.mV[2] = -0.1f; + } + return toLightNorm(light_direction); +} + LLVector4 LLEnvironment::getRotatedLightNorm() const { LLVector3 light_direction = getLightDirection(); diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 9da6de60ae..0fdedb91f7 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -193,14 +193,20 @@ public: // Returns either sun or moon direction (depending on which is up and stronger) // Light direction in +x right, +z up, +y at internal coord sys - LLVector3 getLightDirection() const; + LLVector3 getLightDirection() const; // returns sun or moon depending on which is up + LLVector3 getSunDirection() const; + LLVector3 getMoonDirection() const; // Returns light direction converted to CFR coord system - LLVector4 getLightDirectionCFR() const; + LLVector4 getLightDirectionCFR() const; // returns sun or moon depending on which is up + LLVector4 getSunDirectionCFR() const; + LLVector4 getMoonDirectionCFR() const; // Returns light direction converted to OGL coord system // and clamped above -0.1f in Y to avoid render artifacts in sky shaders - LLVector4 getClampedLightNorm() const; + LLVector4 getClampedLightNorm() const; // returns sun or moon depending on which is up + LLVector4 getClampedSunNorm() const; + LLVector4 getClampedMoonNorm() const; // Returns light direction converted to OGL coord system // and rotated by last cam yaw needed by water rendering shaders diff --git a/indra/newview/llfloatereditextdaycycle.cpp b/indra/newview/llfloatereditextdaycycle.cpp index 5a6af85334..38e45dd6d5 100644 --- a/indra/newview/llfloatereditextdaycycle.cpp +++ b/indra/newview/llfloatereditextdaycycle.cpp @@ -410,7 +410,9 @@ void LLFloaterEditExtDayCycle::onTrackSelectionCallback(const LLSD& user_data) void LLFloaterEditExtDayCycle::onPlayActionCallback(const LLSD& user_data) { std::string action = user_data.asString(); + F32 frame = mTimeSlider->getCurSliderValue(); + if (action == ACTION_PLAY) { startPlay(); @@ -424,13 +426,13 @@ void LLFloaterEditExtDayCycle::onPlayActionCallback(const LLSD& user_data) F32 new_frame = 0; if (action == ACTION_FORWARD) { - new_frame = mEditDay->getUpperBoundFrame(mCurrentTrack, frame); + new_frame = mEditDay->getUpperBoundFrame(mCurrentTrack, frame + (mTimeSlider->getIncrement() / 2)); } else if (action == ACTION_BACK) { new_frame = mEditDay->getLowerBoundFrame(mCurrentTrack, frame - (mTimeSlider->getIncrement() / 2)); } - selectFrame(new_frame); + selectFrame(new_frame, 0.0f); stopPlay(); } } @@ -538,12 +540,12 @@ void LLFloaterEditExtDayCycle::onFrameSliderMouseUp(S32 x, S32 y, MASK mask) LL_WARNS("LAPRAS") << " UP: X=" << x << " Y=" << y << " MASK=" << mask << " Position=" << sliderpos << LL_ENDL; mTimeSlider->setCurSliderValue(sliderpos); - selectFrame(sliderpos); + selectFrame(sliderpos, FRAME_SLOP_FACTOR); } void LLFloaterEditExtDayCycle::onTimeSliderMoved() { - selectFrame(mTimeSlider->getCurSliderValue()); + selectFrame(mTimeSlider->getCurSliderValue(), FRAME_SLOP_FACTOR); } void LLFloaterEditExtDayCycle::selectTrack(U32 track_index, bool force ) @@ -566,16 +568,16 @@ void LLFloaterEditExtDayCycle::selectTrack(U32 track_index, bool force ) updateSlider(); } -void LLFloaterEditExtDayCycle::selectFrame(F32 frame) +void LLFloaterEditExtDayCycle::selectFrame(F32 frame, F32 slop_factor) { mFramesSlider->resetCurSlider(); - keymap_t::iterator iter = mSliderKeyMap.begin(); keymap_t::iterator end_iter = mSliderKeyMap.end(); while (iter != end_iter) { - if (fabs(iter->second.mFrame - frame) <= FRAME_SLOP_FACTOR) + F32 keyframe = iter->second.mFrame; + if (fabs(keyframe - frame) <= slop_factor) { mFramesSlider->setCurSlider(iter->first); frame = iter->second.mFrame; @@ -587,6 +589,7 @@ void LLFloaterEditExtDayCycle::selectFrame(F32 frame) mTimeSlider->setCurSliderValue(frame); // block or update tabs according to new selection updateTabs(); + LLEnvironment::instance().updateEnvironment(); } void LLFloaterEditExtDayCycle::clearTabs() @@ -685,11 +688,16 @@ void LLFloaterEditExtDayCycle::setSkyTabsEnabled(BOOL enable) void LLFloaterEditExtDayCycle::updateButtons() { - LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); - LLSettingsBase::ptr_t settings = mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack); - bool can_add = static_cast<bool>(settings); - mAddFrameButton->setEnabled(can_add); - mDeleteFrameButton->setEnabled(!can_add); + // This logic appears to work in reverse, the add frame button + // is only enabled when you're on an existing frame and disabled + // in all the interim positions where you'd want to add a frame... + //LLSettingsBase::Seconds frame(mTimeSlider->getCurSliderValue()); + //LLSettingsBase::ptr_t settings = mEditDay->getSettingsAtKeyframe(frame, mCurrentTrack); + //bool can_add = static_cast<bool>(settings); + //mAddFrameButton->setEnabled(can_add); + //mDeleteFrameButton->setEnabled(!can_add); + mAddFrameButton->setEnabled(true); + mDeleteFrameButton->setEnabled(true); } void LLFloaterEditExtDayCycle::updateSlider() @@ -717,7 +725,7 @@ void LLFloaterEditExtDayCycle::updateSlider() mLastFrameSlider.clear(); } - selectFrame(frame_position); + selectFrame(frame_position, FRAME_SLOP_FACTOR); } void LLFloaterEditExtDayCycle::updateTimeAndLabel() @@ -1101,7 +1109,7 @@ void LLFloaterEditExtDayCycle::stopPlay() gIdleCallbacks.deleteFunction(onIdlePlay, this); mPlayTimer.stop(); F32 frame = mTimeSlider->getCurSliderValue(); - selectFrame(frame); + selectFrame(frame, FRAME_SLOP_FACTOR); getChild<LLView>("play_layout", true)->setVisible(TRUE); getChild<LLView>("pause_layout", true)->setVisible(FALSE); diff --git a/indra/newview/llfloatereditextdaycycle.h b/indra/newview/llfloatereditextdaycycle.h index 0ec5e91b4d..94b2d6c21b 100644 --- a/indra/newview/llfloatereditextdaycycle.h +++ b/indra/newview/llfloatereditextdaycycle.h @@ -79,6 +79,8 @@ public: private: + F32 getCurrentFrame() const; + // flyout response/click void onButtonApply(LLUICtrl *ctrl, const LLSD &data); void onBtnCancel(); @@ -98,7 +100,7 @@ private: void onFrameSliderMouseUp(S32 x, S32 y, MASK mask); void selectTrack(U32 track_index, bool force = false); - void selectFrame(F32 frame); + void selectFrame(F32 frame, F32 slop_factor); void clearTabs(); void updateTabs(); void updateWaterTabs(const LLSettingsWaterPtr_t &p_water); diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 59cfab61fd..36460475a8 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -267,7 +267,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) F32 density_multiplier = psky->getDensityMultiplier(); F32 max_y = psky->getMaxY(); - LLVector3 lightnorm = LLVector3(LLEnvironment::instance().getClampedLightNorm()); + LLVector3 sun_norm = LLVector3(LLEnvironment::instance().getClampedSunNorm()); // project the direction ray onto the sky dome. F32 phi = acos(Pn[1]); @@ -316,7 +316,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) LLColor3 haze_weight = componentDiv(smear(haze_density), temp1); // Compute sunlight from P & lightnorm (for long rays like sky) - temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); + temp2.mV[1] = llmax(F_APPROXIMATELY_ZERO, llmax(0.f, Pn[1]) * 1.0f + sun_norm[1] ); temp2.mV[1] = 1.f / temp2.mV[1]; componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); @@ -329,7 +329,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // Compute haze glow - temp2.mV[0] = Pn * lightnorm; + temp2.mV[0] = Pn * sun_norm; temp2.mV[0] = 1.f - temp2.mV[0]; // temp2.x is 0 at the sun and increases away from sun @@ -360,7 +360,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) componentMultBy(vars.hazeColor, LLColor3::white - temp1); sunlight = psky->getSunlightColor(); - temp2.mV[1] = llmax(0.f, lightnorm[1] * 2.f); + temp2.mV[1] = llmax(0.f, sun_norm[1] * 2.f); temp2.mV[1] = 1.f / temp2.mV[1]; componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); diff --git a/indra/newview/llpaneleditsky.cpp b/indra/newview/llpaneleditsky.cpp index e5c6116c4f..dc724ce9c7 100644 --- a/indra/newview/llpaneleditsky.cpp +++ b/indra/newview/llpaneleditsky.cpp @@ -374,19 +374,23 @@ void LLPanelSettingsSkySunMoonTab::onStarBrightnessChanged() void LLPanelSettingsSkySunMoonTab::onSunRotationChanged() { mSkySettings->setSunRotation(getChild<LLJoystickQuaternion>(FIELD_SKY_SUN_ROTATION)->getRotation()); + mSkySettings->update(); } void LLPanelSettingsSkySunMoonTab::onSunImageChanged() { mSkySettings->setSunTextureId(getChild<LLTextureCtrl>(FIELD_SKY_SUN_IMAGE)->getValue().asUUID()); + mSkySettings->update(); } void LLPanelSettingsSkySunMoonTab::onMoonRotationChanged() { mSkySettings->setMoonRotation(getChild<LLJoystickQuaternion>(FIELD_SKY_MOON_ROTATION)->getRotation()); + mSkySettings->update(); } void LLPanelSettingsSkySunMoonTab::onMoonImageChanged() { mSkySettings->setMoonTextureId(getChild<LLTextureCtrl>(FIELD_SKY_MOON_IMAGE)->getValue().asUUID()); + mSkySettings->update(); } diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 95bcf127ae..23c77c8a25 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -529,7 +529,7 @@ void LLSettingsVOSky::applySpecial(void *ptarget) { LLGLSLShader *shader = (LLGLSLShader *)ptarget; - LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); + LLVector4 light_direction = LLEnvironment::instance().getClampedSunNorm(); if (shader->mShaderGroup == LLGLSLShader::SG_DEFAULT) { @@ -538,7 +538,6 @@ void LLSettingsVOSky::applySpecial(void *ptarget) } else if (shader->mShaderGroup == LLGLSLShader::SG_SKY) { - LLVector4 light_direction = LLEnvironment::instance().getClampedLightNorm(); shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, light_direction.mV); LLVector4 vect_c_p_d1(mSettings[SETTING_CLOUD_POS_DENSITY1]); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 27db6778eb..7be05a1bcb 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -6258,8 +6258,11 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) // Light 0 = Sun or Moon (All objects) { - LLVector4 light_dir = environment.getLightDirectionCFR(); - mSunDir.setVec(light_dir); + LLVector4 sun_dir = environment.getSunDirectionCFR(); + LLVector4 moon_dir = environment.getMoonDirectionCFR(); + + mSunDir.setVec(sun_dir); + mMoonDir.setVec(moon_dir); if (environment.getIsSunUp()) { @@ -6282,7 +6285,14 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) mHWLightColors[0] = light_diffuse; LLLightState* light = gGL.getLight(0); - light->setPosition(mSunDir); + if (environment.getIsSunUp()) + { + light->setPosition(mSunDir); + } + else + { + light->setPosition(mMoonDir); + } light->setDiffuse(light_diffuse); light->setAmbient(LLColor4::black); light->setSpecular(LLColor4::black); @@ -8377,6 +8387,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n shader.uniform1f(LLShaderMgr::DEFERRED_SPOT_SHADOW_BIAS, RenderSpotShadowBias); shader.uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, mTransformedSunDir.mV); + shader.uniform3fv(LLShaderMgr::DEFERRED_MOON_DIR, 1, mTransformedMoonDir.mV); shader.uniform2f(LLShaderMgr::DEFERRED_SHADOW_RES, mShadow[0].getWidth(), mShadow[0].getHeight()); shader.uniform2f(LLShaderMgr::DEFERRED_PROJ_SHADOW_RES, mShadow[4].getWidth(), mShadow[4].getHeight()); shader.uniform1f(LLShaderMgr::DEFERRED_DEPTH_CUTOFF, RenderEdgeDepthCutoff); @@ -8465,10 +8476,13 @@ void LLPipeline::renderDeferredLighting() vert[2].set(3,1,0); { - setupHWLights(NULL); //to set mSunDir; + setupHWLights(NULL); //to set mSun/MoonDir; glh::vec4f tc(mSunDir.mV); mat.mult_matrix_vec(tc); mTransformedSunDir.set(tc.v); + + glh::vec4f tc_moon(mMoonDir.mV); + mTransformedMoonDir.set(tc_moon.v); } gGL.pushMatrix(); @@ -9078,10 +9092,13 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) vert[2].set(3,1,0); { - setupHWLights(NULL); //to set mSunDir; + setupHWLights(NULL); //to set mSun/MoonDir; glh::vec4f tc(mSunDir.mV); mat.mult_matrix_vec(tc); mTransformedSunDir.set(tc.v); + + glh::vec4f tc_moon(mMoonDir.mV); + mTransformedMoonDir.set(tc_moon.v); } gGL.pushMatrix(); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 43aa7d891e..d17bab775d 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -657,7 +657,10 @@ public: LLColor4 mSunDiffuse; LLVector4 mSunDir; + LLVector4 mMoonDir; + LLVector4 mTransformedSunDir; + LLVector4 mTransformedMoonDir; bool mInitialized; bool mVertexShadersEnabled; |