diff options
author | Graham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com> | 2018-03-08 16:09:29 +0000 |
---|---|---|
committer | Graham Linden graham@lindenlab.com <Graham Linden graham@lindenlab.com> | 2018-03-08 16:09:29 +0000 |
commit | 087e21082512bce899e435537d7d60a09ef6eaca (patch) | |
tree | ec3476f0a66911fd52b2307eda9e969ce7b09970 /indra | |
parent | 2eb03ae3ef1d75b0966b80a2cb370f5c4ef8973a (diff) |
Add LLVoSky wrapper for current env sky light direction.
Make LLVo classes use LLVoSky wrappers instead of direct access.
Isolate more legacy haze param usage w/in settings.
Diffstat (limited to 'indra')
-rw-r--r-- | indra/llinventory/llsettingssky.cpp | 58 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.h | 50 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwater.cpp | 11 | ||||
-rw-r--r-- | indra/newview/lllegacyatmospherics.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lllegacyatmospherics.h | 10 | ||||
-rw-r--r-- | indra/newview/llviewerwindow.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llvosky.cpp | 4 | ||||
-rw-r--r-- | indra/newview/llvosky.h | 1 |
8 files changed, 59 insertions, 83 deletions
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index 9b9d10718c..e84939800b 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -32,6 +32,8 @@ #include "llfasttimer.h" #include "v3colorutil.h" +#pragma optimize("", off) + //========================================================================= namespace { @@ -574,10 +576,7 @@ LLSD LLSettingsSky::translateLegacySettings(LLSD legacy) // AdvancedAtmospherics TODO // These need to be translated into density profile info in the new settings format... // LEGACY_ATMOSPHERICS - if (legacy.has(SETTING_AMBIENT)) - { - newsettings[SETTING_AMBIENT] = LLColor3(legacy[SETTING_AMBIENT]).getValue(); - } + if (legacy.has(SETTING_BLUE_DENSITY)) { newsettings[SETTING_BLUE_DENSITY] = LLColor3(legacy[SETTING_BLUE_DENSITY]).getValue(); @@ -603,6 +602,10 @@ LLSD LLSettingsSky::translateLegacySettings(LLSD legacy) newsettings[SETTING_HAZE_HORIZON] = LLSD::Real(legacy[SETTING_HAZE_HORIZON][0].asReal()); } + if (legacy.has(SETTING_AMBIENT)) + { + newsettings[SETTING_AMBIENT] = LLColor3(legacy[SETTING_AMBIENT]).getValue(); + } if (legacy.has(SETTING_CLOUD_COLOR)) { newsettings[SETTING_CLOUD_COLOR] = LLColor3(legacy[SETTING_CLOUD_COLOR]).getValue(); @@ -756,6 +759,7 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() // this is used later for sunlight modulation at various altitudes LLColor3 LLSettingsSky::getLightAttenuation(F32 distance) const { +// LEGACY_ATMOSPHERICS LLColor3 blue_density = getBlueDensity(); F32 haze_density = getHazeDensity(); F32 density_multiplier = getDensityMultiplier(); @@ -766,6 +770,7 @@ LLColor3 LLSettingsSky::getLightAttenuation(F32 distance) const LLColor3 LLSettingsSky::getLightTransmittance() const { +// LEGACY_ATMOSPHERICS LLColor3 blue_density = getBlueDensity(); F32 haze_density = getHazeDensity(); F32 density_multiplier = getDensityMultiplier(); @@ -788,41 +793,40 @@ LLColor3 LLSettingsSky::gammaCorrect(const LLColor3& in) const void LLSettingsSky::calculateLightSettings() { -// LEGACY_ATMOSPHERICS - // Initialize temp variables - LLColor3 sunlight = getSunlightColor(); - LLColor3 ambient = getAmbientColor(); - F32 cloud_shadow = getCloudShadow(); - LLVector3 lightnorm = getLightDirection(); - - // Sunlight attenuation effect (hue and brightness) due to atmosphere - // this is used later for sunlight modulation at various altitudes + // Initialize temp variables + LLColor3 sunlight = getSunlightColor(); + LLColor3 ambient = getAmbientColor(); + F32 cloud_shadow = getCloudShadow(); + LLVector3 lightnorm = getLightDirection(); + + // Sunlight attenuation effect (hue and brightness) due to atmosphere + // this is used later for sunlight modulation at various altitudes F32 max_y = getMaxY(); LLColor3 light_atten = getLightAttenuation(max_y); LLColor3 light_transmittance = getLightTransmittance(); - // Compute sunlight from P & lightnorm (for long rays like sky) - /// USE only lightnorm. - // temp2[1] = llmax(0.f, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); + // Compute sunlight from P & lightnorm (for long rays like sky) + /// USE only lightnorm. + // temp2[1] = llmax(0.f, llmax(0.f, Pn[1]) * 1.0f + lightnorm[1] ); - // and vary_sunlight will work properly with moon light - F32 lighty = lightnorm[1]; - if (lighty < NIGHTTIME_ELEVATION_COS) - { - lighty = -lighty; - } + // and vary_sunlight will work properly with moon light + F32 lighty = lightnorm[1]; + if (lighty < NIGHTTIME_ELEVATION_COS) + { + lighty = -lighty; + } lighty = llmax(0.f, lighty); if(lighty > 0.f) - { + { lighty = 1.f / lighty; - } + } componentMultBy(sunlight, componentExp((light_atten * -1.f) * lighty)); - //increase ambient when there are more clouds - LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f; + //increase ambient when there are more clouds + LLColor3 tmpAmbient = ambient + (smear(1.f) - ambient) * cloud_shadow * 0.5f; - //brightness of surface both sunlight and ambient + //brightness of surface both sunlight and ambient mSunDiffuse = gammaCorrect(componentMult(sunlight, light_transmittance)); mSunAmbient = gammaCorrect(componentMult(tmpAmbient, light_transmittance) * 0.5); diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index ceb941bf7c..5c4cacdba0 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -114,64 +114,35 @@ public: setValue(SETTING_AMBIENT, val); } +// LEGACY_ATMOSPHERICS LLColor3 getBlueDensity() const { return LLColor3(mSettings[SETTING_BLUE_DENSITY]); } - void setBlueDensity(const LLColor3 &val) - { - setValue(SETTING_BLUE_DENSITY, val); - } - LLColor3 getBlueHorizon() const { return LLColor3(mSettings[SETTING_BLUE_HORIZON]); } - void setBlueHorizon(const LLColor3 &val) - { - setValue(SETTING_BLUE_HORIZON, val); - } - - F32 getDensityMultiplier() const - { - return mSettings[SETTING_DENSITY_MULTIPLIER].asReal(); - } - - void setDensityMultiplier(F32 val) - { - setValue(SETTING_DENSITY_MULTIPLIER, val); - } - - F32 getDistanceMultiplier() const - { - return mSettings[SETTING_DISTANCE_MULTIPLIER].asReal(); - } - - void setDistanceMultiplier(F32 val) - { - setValue(SETTING_DISTANCE_MULTIPLIER, val); - } - F32 getHazeDensity() const { return mSettings[SETTING_HAZE_DENSITY].asReal(); } - void setHazeDensity(F32 val) + F32 getHazeHorizon() const { - setValue(SETTING_HAZE_DENSITY, val); + return mSettings[SETTING_HAZE_HORIZON].asReal(); } - F32 getHazeHorizon() const + F32 getDensityMultiplier() const { - return mSettings[SETTING_HAZE_HORIZON].asReal(); + return mSettings[SETTING_DENSITY_MULTIPLIER].asReal(); } - void setHazeHorizon(F32 val) + F32 getDistanceMultiplier() const { - setValue(SETTING_HAZE_HORIZON, val); + return mSettings[SETTING_DISTANCE_MULTIPLIER].asReal(); } LLColor3 getCloudColor() const @@ -434,6 +405,10 @@ public: static LLSD translateLegacySettings(LLSD legacy); + LLColor3 getLightAttenuation(F32 distance) const; + LLColor3 getLightTransmittance() const; + LLColor3 gammaCorrect(const LLColor3& in) const; + protected: static const std::string SETTING_LEGACY_EAST_ANGLE; static const std::string SETTING_LEGACY_ENABLE_CLOUD_SCROLL; @@ -455,9 +430,6 @@ private: void calculateHeavnlyBodyPositions(); void calculateLightSettings(); - LLColor3 getLightAttenuation(F32 distance) const; - LLColor3 getLightTransmittance() const; - LLColor3 gammaCorrect(const LLColor3& in) const; LLVector3 mSunDirection; LLVector3 mMoonDirection; diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 5c92cf9fce..493c619a99 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -488,22 +488,21 @@ void LLDrawPoolWater::shade() LLVector3 light_dir; LLColor3 light_color; - LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); - light_dir = psky->getLightDirection(); + light_dir = voskyp->getLightDirection(); if (LLEnvironment::instance().getIsDayTime()) { - light_color = psky->getSunAmbient(); - light_diffuse = psky->getSunDiffuse(); + light_color = voskyp->getSunAmbientColor(); + light_diffuse = voskyp->getSunDiffuseColor(); light_diffuse.normalize(); light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f); light_diffuse *= (light_exp + 0.25f); } else { - light_color = psky->getMoonAmbient(); - light_diffuse = psky->getMoonDiffuse(); + light_color = voskyp->getMoonAmbientColor(); + light_diffuse = voskyp->getMoonDiffuseColor(); light_diffuse.normalize(); light_diffuse *= 0.5f; light_exp = light_dir * LLVector3(light_dir.mV[0], light_dir.mV[1], 0.f); diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 6bc95c367c..0a788b95c7 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -303,7 +303,7 @@ void LLAtmospherics::calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars) // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes - LLColor3 light_atten = (blue_density * 1.0 + smear(haze_density * 0.25f)) * (density_multiplier * max_y); + LLColor3 light_atten = psky->getLightAttenuation(psky->getMaxY()); // Calculate relative weights LLColor3 temp2(0.f, 0.f, 0.f); diff --git a/indra/newview/lllegacyatmospherics.h b/indra/newview/lllegacyatmospherics.h index 71469a622a..5a5b9c0022 100644 --- a/indra/newview/lllegacyatmospherics.h +++ b/indra/newview/lllegacyatmospherics.h @@ -179,18 +179,12 @@ protected: class LLCubeMap; -// turn on floating point precision -// in vs2003 for this class. Otherwise -// black dots go everywhere from 7:10 - 8:50 -#if LL_MSVC && __MSVC_VER__ < 8 -#pragma optimize("p", on) -#endif - class AtmosphericsVars { public: AtmosphericsVars() : hazeColor(0,0,0) + , hazeColorBelowCloud(0,0,0) , cloudColorSun(0,0,0) , cloudColorAmbient(0,0,0) , cloudDensity(0.0f) @@ -200,6 +194,7 @@ public: } LLColor3 hazeColor; + LLColor3 hazeColorBelowCloud; LLColor3 cloudColorSun; LLColor3 cloudColorAmbient; F32 cloudDensity; @@ -234,6 +229,7 @@ protected: void calcSkyColorWLVert(LLVector3 & Pn, AtmosphericsVars& vars); LLColor3 calcSkyColorWLFrag(LLVector3 & Pn, AtmosphericsVars& vars); + LLColor3 getHazeColor(LLSettingsSky::ptr_t psky, AtmosphericsVars& vars, F32 costheta, F32 cloud_shadow); LLHaze mHaze; F32 mHazeConcentration; diff --git a/indra/newview/llviewerwindow.cpp b/indra/newview/llviewerwindow.cpp index 74deaffe16..3f3d5e54cd 100644 --- a/indra/newview/llviewerwindow.cpp +++ b/indra/newview/llviewerwindow.cpp @@ -597,7 +597,7 @@ public: addText(xpos, ypos, llformat("%d Unique Textures", LLImageGL::sUniqueCount)); ypos += y_inc; - addText(xpos, ypos, llformat("%d Render Calls", last_frame_recording.getSampleCount(LLPipeline::sStatBatchSize))); + addText(xpos, ypos, llformat("%d Render Calls", (U32)last_frame_recording.getSampleCount(LLPipeline::sStatBatchSize))); ypos += y_inc; addText(xpos, ypos, llformat("%d/%d Objects Active", gObjectList.getNumActiveObjects(), gObjectList.getNumObjects())); @@ -612,9 +612,9 @@ public: gPipeline.mTextureMatrixOps = 0; gPipeline.mMatrixOpCount = 0; - if (last_frame_recording.getSampleCount(LLPipeline::sStatBatchSize) > 0) + if ((U32)last_frame_recording.getSampleCount(LLPipeline::sStatBatchSize) > 0) { - addText(xpos, ypos, llformat("Batch min/max/mean: %d/%d/%d", last_frame_recording.getMin(LLPipeline::sStatBatchSize), last_frame_recording.getMax(LLPipeline::sStatBatchSize), last_frame_recording.getMean(LLPipeline::sStatBatchSize))); + addText(xpos, ypos, llformat("Batch min/max/mean: %d/%d/%d", (U32)last_frame_recording.getMin(LLPipeline::sStatBatchSize), (U32)last_frame_recording.getMax(LLPipeline::sStatBatchSize), (U32)last_frame_recording.getMean(LLPipeline::sStatBatchSize))); } ypos += y_inc; diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 55307fe1dc..7a5c258949 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -1430,6 +1430,10 @@ void LLVOSky::setSunDirection(const LLVector3 &sun_dir, const LLVector3 &moon_di } } +LLVector3 LLVOSky::getLightDirection() const +{ + return LLEnvironment::instance().getCurrentSky()->getLightDirection(); +} LLColor4U LLVOSky::getFadeColor() const { diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index e93ff51a66..7b5ea38999 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -274,6 +274,7 @@ public: const LLVector3& getToMoonLast() const { return mMoon.getDirectionCached(); } BOOL isSunUp() const { return mSun.getDirectionCached().mV[2] > -0.05f; } + LLVector3 getLightDirection() const; LLColor3 getSunDiffuseColor() const; LLColor3 getMoonDiffuseColor() const; LLColor4 getSunAmbientColor() const; |