diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/lllegacyatmospherics.cpp | 117 | ||||
-rw-r--r-- | indra/newview/lllegacyatmospherics.h | 111 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llvosky.cpp | 233 | ||||
-rw-r--r-- | indra/newview/llvosky.h | 9 |
5 files changed, 207 insertions, 265 deletions
diff --git a/indra/newview/lllegacyatmospherics.cpp b/indra/newview/lllegacyatmospherics.cpp index 720c7e2388..a1093df7e1 100644 --- a/indra/newview/lllegacyatmospherics.cpp +++ b/indra/newview/lllegacyatmospherics.cpp @@ -242,8 +242,10 @@ LLColor4 LLAtmospherics::calcSkyColorInDir(AtmosphericsVars& vars, const LLVecto calcSkyColorWLVert(Pn, vars); + bool low_end = !gPipeline.canUseWindLightShaders(); + LLColor3 sky_color = isShiny ? vars.hazeColor : - !gPipeline.canUseWindLightShaders() ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f); + low_end ? vars.hazeColor * 2.0f : psky->gammaCorrect(vars.hazeColor * 2.0f); if (isShiny) { @@ -443,8 +445,8 @@ void LLAtmospherics::updateFog(const F32 distance, const LLVector3& tosun_in) vars.distance_multiplier = psky->getDistanceMultiplier(); vars.max_y = psky->getMaxY(); vars.sun_norm = LLEnvironment::instance().getSunDirectionCFR(); - vars.sunlight = psky->getSunlightColor(); - vars.ambient = psky->getAmbientColor(); + vars.sunlight = psky->getSunlightColorClamped(); + vars.ambient = psky->getAmbientColorClamped(); vars.glow = psky->getGlow(); vars.cloud_shadow = psky->getCloudShadow(); vars.dome_radius = psky->getDomeRadius(); @@ -605,3 +607,112 @@ F32 azimuth(const LLVector3 &v) } return azimuth; } + +bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b) +{ + if (a.hazeColor != b.hazeColor) + { + return false; + } + + if (a.hazeColorBelowCloud != b.hazeColorBelowCloud) + { + return false; + } + + if (a.cloudColorSun != b.cloudColorSun) + { + return false; + } + + if (a.cloudColorAmbient != b.cloudColorAmbient) + { + return false; + } + + if (a.cloudDensity != b.cloudDensity) + { + return false; + } + + if (a.density_multiplier != b.density_multiplier) + { + return false; + } + + if (a.haze_horizon != b.haze_horizon) + { + return false; + } + + if (a.haze_density != b.haze_density) + { + return false; + } + + if (a.blue_horizon != b.blue_horizon) + { + return false; + } + + if (a.blue_density != b.blue_density) + { + return false; + } + + if (a.dome_offset != b.dome_offset) + { + return false; + } + + if (a.dome_radius != b.dome_radius) + { + return false; + } + + if (a.cloud_shadow != b.cloud_shadow) + { + return false; + } + + if (a.glow != b.glow) + { + return false; + } + + if (a.ambient != b.ambient) + { + return false; + } + + if (a.sunlight != b.sunlight) + { + return false; + } + + if (a.sun_norm != b.sun_norm) + { + return false; + } + + if (a.gamma != b.gamma) + { + return false; + } + + if (a.max_y != b.max_y) + { + return false; + } + + if (a.distance_multiplier != b.distance_multiplier) + { + return false; + } + + // light_atten, light_transmittance, total_density + // are ignored as they always change when the values above do + // they're just shared calc across the sky map generation to save cycles + + return true; +} diff --git a/indra/newview/lllegacyatmospherics.h b/indra/newview/lllegacyatmospherics.h index 95700227f9..cdfcead7a4 100644 --- a/indra/newview/lllegacyatmospherics.h +++ b/indra/newview/lllegacyatmospherics.h @@ -206,7 +206,7 @@ public: { } - LL_FORCE_INLINE friend bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b); + friend bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b); LLColor3 hazeColor; LLColor3 hazeColorBelowCloud; @@ -233,115 +233,6 @@ public: LLColor3 total_density; }; -bool operator==(const AtmosphericsVars& a, const AtmosphericsVars& b) -{ - if (a.hazeColor != b.hazeColor) - { - return false; - } - - if (a.hazeColorBelowCloud != b.hazeColorBelowCloud) - { - return false; - } - - if (a.cloudColorSun != b.cloudColorSun) - { - return false; - } - - if (a.cloudColorAmbient != b.cloudColorAmbient) - { - return false; - } - - if (a.cloudDensity != b.cloudDensity) - { - return false; - } - - if (a.density_multiplier != b.density_multiplier) - { - return false; - } - - if (a.haze_horizon != b.haze_horizon) - { - return false; - } - - if (a.haze_density != b.haze_density) - { - return false; - } - - if (a.blue_horizon != b.blue_horizon) - { - return false; - } - - if (a.blue_density != b.blue_density) - { - return false; - } - - if (a.dome_offset != b.dome_offset) - { - return false; - } - - if (a.dome_radius != b.dome_radius) - { - return false; - } - - if (a.cloud_shadow != b.cloud_shadow) - { - return false; - } - - if (a.glow != b.glow) - { - return false; - } - - if (a.ambient != b.ambient) - { - return false; - } - - if (a.sunlight != b.sunlight) - { - return false; - } - - if (a.sun_norm != b.sun_norm) - { - return false; - } - - if (a.gamma != b.gamma) - { - return false; - } - - if (a.max_y != b.max_y) - { - return false; - } - - if (a.distance_multiplier != b.distance_multiplier) - { - return false; - } - - // light_atten, light_transmittance, total_density - // are ignored as they always change when the values above do - // they're just shared calc across the sky map generation to save cycles - - return true; -} - class LLAtmospherics { public: diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index c874b3cf59..aca236cdfd 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -528,7 +528,7 @@ void LLViewerShaderMgr::setShaders() } // Trigger a full rebuild of the fallback skybox / cubemap if we've toggled windlight shaders - if (mShaderLevel[SHADER_WINDLIGHT] != wl_class && gSky.mVOSkyp.notNull()) + if (!wl_class || (mShaderLevel[SHADER_WINDLIGHT] != wl_class && gSky.mVOSkyp.notNull())) { gSky.mVOSkyp->forceSkyUpdate(); } diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 37b685f731..28ad3d0877 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -85,7 +85,7 @@ namespace LLTrace::BlockTimerStatHandle FTM_VOSKY_CREATETEXTURES("VOSky Update Textures"); LLTrace::BlockTimerStatHandle FTM_VOSKY_UPDATEFORCED("VOSky Update Forced"); - F32Seconds UPDATE_EXPRY(2.0f); + F32Seconds UPDATE_EXPRY(0.25f); } /*************************************** SkyTex @@ -419,7 +419,7 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp) mCloudDensity(0.2f), mWind(0.f), mForceUpdate(FALSE), - mCubeMapUpdateStage(-1), + mNeedUpdate(TRUE), mWorldScale(1.f), mBumpSunDir(0.f, 0.f, 1.f) { @@ -502,9 +502,13 @@ void LLVOSky::init() initSkyTextureDirs(side, tile); createSkyTexture(m_atmosphericsVars, side, tile, mSkyTex); createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex, true); - } - mSkyTex[side].create(1.0f); - mShinyTex[side].create(1.0f); + } + } + + for (S32 i = 0; i < NUM_CUBEMAP_FACES; ++i) + { + mSkyTex[i].create(1.0f); + mShinyTex[i].create(1.0f); } initCubeMap(); @@ -608,8 +612,7 @@ void LLVOSky::restoreGL() initCubeMap(); } - mForceUpdate = TRUE; - mCubeMapUpdateStage = -1; + forceSkyUpdate(); if (mDrawable) { @@ -672,31 +675,29 @@ void LLVOSky::updateDirections(void) { LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - mLastSunLightingDirection = mSun.getDirection(); - mLastMoonLightingDirection = mMoon.getDirection(); - mSun.setDirection(psky->getSunDirection()); mMoon.setDirection(psky->getMoonDirection()); - mSun.setRotation(psky->getSunRotation()); mMoon.setRotation(psky->getMoonRotation()); - mSun.renewDirection(); - mSun.renewColor(); mMoon.renewDirection(); - mMoon.renewColor(); } void LLVOSky::idleUpdate(LLAgent &agent, const F64 &time) { } +void LLVOSky::forceSkyUpdate() +{ + mForceUpdate = TRUE; + + memset(&m_lastAtmosphericsVars, 0x00, sizeof(AtmosphericsVars)); +} + bool LLVOSky::updateSky() { LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); - LLColor4 total_ambient = psky->getTotalAmbient(); - if (mDead || !(gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY))) { return TRUE; @@ -713,13 +714,15 @@ bool LLVOSky::updateSky() return TRUE; } + bool is_alm_wl_sky = gPipeline.canUseWindLightShaders(); + static S32 next_frame = 0; const S32 total_no_tiles = NUM_CUBEMAP_FACES * NUM_TILES; const S32 cycle_frame_no = total_no_tiles + 1; const S32 frame = next_frame; - mForceUpdate = mForceUpdate || (total_no_tiles == frame); + mNeedUpdate = mForceUpdate || (total_no_tiles == frame); ++next_frame; next_frame = next_frame % cycle_frame_no; @@ -728,143 +731,90 @@ bool LLVOSky::updateSky() LLHeavenBody::setInterpVal( mInterpVal ); updateDirections(); - if (mCubeMapUpdateStage < 0) - { - LL_RECORD_BLOCK_TIME(FTM_VOSKY_CALC); - calc(); + // Note: must be before comparison of old/current env settings below to be an effective optimization + calc(); - LLVector3 direction = mSun.getDirection(); - direction.normalize(); - const F32 dot_sun = direction * mLastSunLightingDirection; - LLVector3 moon_direction = mMoon.getDirection(); - moon_direction.normalize(); - const F32 dot_moon = moon_direction * mLastMoonLightingDirection; + bool same_atmospherics = m_lastAtmosphericsVars == m_atmosphericsVars; - LLColor3 delta_color; - delta_color.setVec(mLastTotalAmbient.mV[0] - total_ambient.mV[0], - mLastTotalAmbient.mV[1] - total_ambient.mV[1], - mLastTotalAmbient.mV[2] - total_ambient.mV[2]); - - bool sun_direction_changed = (dot_sun < LIGHT_DIRECTION_THRESHOLD); - bool moon_direction_changed = (dot_moon < LIGHT_DIRECTION_THRESHOLD); - bool color_changed = (delta_color.length() >= COLOR_CHANGE_THRESHOLD); - - mForceUpdate = mForceUpdate || sun_direction_changed; - mForceUpdate = mForceUpdate || moon_direction_changed; - mForceUpdate = mForceUpdate || color_changed; - mForceUpdate = mForceUpdate || !mInitialized; + if (mNeedUpdate && mForceUpdateThrottle.hasExpired() && (mForceUpdate || !same_atmospherics)) + { + LL_RECORD_BLOCK_TIME(FTM_VOSKY_UPDATEFORCED); - bool same_atmospherics = m_lastAtmosphericsVars == m_atmosphericsVars; + mForceUpdateThrottle.setTimerExpirySec(UPDATE_EXPRY); - if (mForceUpdate && mForceUpdateThrottle.hasExpired() && !same_atmospherics) - { - // start updating cube map sides - if (mCubeMap && !direction.isExactlyZero()) - { - updateFog(LLViewerCamera::getInstance()->getFar()); + LLSkyTex::stepCurrent(); + + m_lastAtmosphericsVars = m_atmosphericsVars; - mCubeMapUpdateStage = 0; - } - else - { - mCubeMapUpdateStage = NUM_CUBEMAP_FACES; - } - mForceUpdate = FALSE; - } - } - else if (mCubeMapUpdateStage == NUM_CUBEMAP_FACES) - { - LL_RECORD_BLOCK_TIME(FTM_VOSKY_UPDATEFORCED); - LLSkyTex::stepCurrent(); + mInitialized = TRUE; - LLVector3 direction = mSun.getDirection(); - if (!direction.isExactlyZero()) - { - bool is_alm_wl_sky = gPipeline.canUseWindLightShaders(); - int tex = mSkyTex[0].getWhich(TRUE); + if (mCubeMap) + { + updateFog(LLViewerCamera::getInstance()->getFar()); - for (int side = 0; side < NUM_CUBEMAP_FACES; side++) - { - LLImageRaw* raw1 = nullptr; - LLImageRaw* raw2 = nullptr; + for (int side = 0; side < NUM_CUBEMAP_FACES; side++) + { + for (int tile = 0; tile < NUM_TILES; tile++) + { + createSkyTexture(m_atmosphericsVars, side, tile, mSkyTex); + createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex, true); + } + } + } - if (!is_alm_wl_sky) - { - raw1 = mSkyTex[side].getImageRaw(TRUE); - raw2 = mSkyTex[side].getImageRaw(FALSE); - raw2->copy(raw1); - mSkyTex[side].createGLImage(tex); - } + int tex = mSkyTex[0].getWhich(TRUE); - raw1 = mShinyTex[side].getImageRaw(TRUE); - raw2 = mShinyTex[side].getImageRaw(FALSE); - raw2->copy(raw1); - mShinyTex[side].createGLImage(tex); - } - next_frame = 0; + for (int side = 0; side < NUM_CUBEMAP_FACES; side++) + { + LLImageRaw* raw1 = nullptr; + LLImageRaw* raw2 = nullptr; - // update the sky texture if (!is_alm_wl_sky) { - for (S32 i = 0; i < NUM_CUBEMAP_FACES; ++i) - { - mSkyTex[i].create(1.0f); - } + raw1 = mSkyTex[side].getImageRaw(TRUE); + raw2 = mSkyTex[side].getImageRaw(FALSE); + raw2->copy(raw1); + mSkyTex[side].createGLImage(tex); } - for (S32 i = 0; i < NUM_CUBEMAP_FACES; ++i) - { - mShinyTex[i].create(1.0f); - } + raw1 = mShinyTex[side].getImageRaw(TRUE); + raw2 = mShinyTex[side].getImageRaw(FALSE); + raw2->copy(raw1); + mShinyTex[side].createGLImage(tex); + } + next_frame = 0; - // update the environment map - if (mCubeMap) - { - std::vector<LLPointer<LLImageRaw> > images; - images.reserve(NUM_CUBEMAP_FACES); - for (S32 side = 0; side < NUM_CUBEMAP_FACES; side++) - { - images.push_back(mShinyTex[side].getImageRaw(TRUE)); - } - mCubeMap->init(images); - gGL.getTexUnit(0)->disable(); - } + // update the sky texture + if (!is_alm_wl_sky) + { + for (S32 i = 0; i < NUM_CUBEMAP_FACES; ++i) + { + mSkyTex[i].create(1.0f); + } } - m_lastAtmosphericsVars = m_atmosphericsVars; - mForceUpdateThrottle.setTimerExpirySec(UPDATE_EXPRY); - gPipeline.markRebuild(gSky.mVOGroundp->mDrawable, LLDrawable::REBUILD_ALL, TRUE); - mCubeMapUpdateStage = -1; - } - else if (mCubeMapUpdateStage >= 0 && mCubeMapUpdateStage < NUM_CUBEMAP_FACES) - { - LL_RECORD_BLOCK_TIME(FTM_VOSKY_CREATETEXTURES); + for (S32 i = 0; i < NUM_CUBEMAP_FACES; ++i) + { + mShinyTex[i].create(1.0f); + } - LLVector3 direction = mSun.getDirection(); - if (!direction.isExactlyZero()) - { - mLastTotalAmbient = total_ambient; - mInitialized = TRUE; + // update the environment map + if (mCubeMap) + { + std::vector<LLPointer<LLImageRaw> > images; + images.reserve(6); + for (S32 side = 0; side < NUM_CUBEMAP_FACES; side++) + { + images.push_back(mShinyTex[side].getImageRaw(TRUE)); + } + mCubeMap->init(images); + gGL.getTexUnit(0)->disable(); + } - if (mCubeMap) - { - S32 side = mCubeMapUpdateStage; - for (int tile = 0; tile < NUM_TILES; tile++) - { - createSkyTexture(m_atmosphericsVars, side, tile, mSkyTex); - createSkyTexture(m_atmosphericsVars, side, tile, mShinyTex, true); - } - mCubeMapUpdateStage++; - } - else - { - mCubeMapUpdateStage = NUM_CUBEMAP_FACES; - } - } - else - { - mCubeMapUpdateStage = NUM_CUBEMAP_FACES; - } + gPipeline.markRebuild(gSky.mVOGroundp->mDrawable, LLDrawable::REBUILD_ALL, TRUE); + + mNeedUpdate = FALSE; + mForceUpdate = FALSE; } if (mDrawable.notNull() && mDrawable->getFace(0) && !mDrawable->getFace(0)->getVertexBuffer()) @@ -917,7 +867,7 @@ LLDrawable *LLVOSky::createDrawable(LLPipeline *pipeline) poolp->setSkyTex(mSkyTex); mDrawable->setRenderType(LLPipeline::RENDER_TYPE_SKY); - for (S32 i = 0; i < 6; ++i) + for (S32 i = 0; i < NUM_CUBEMAP_FACES; ++i) { mFace[FACE_SIDE0 + i] = mDrawable->addFace(poolp, NULL); } @@ -1079,7 +1029,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) U16 index_offset; LLFace *face; - for (S32 side = 0; side < 6; ++side) + for (S32 side = 0; side < NUM_CUBEMAP_FACES; ++side) { face = mFace[FACE_SIDE0 + side]; @@ -1635,10 +1585,7 @@ void LLVOSky::setSunAndMoonDirectionsCFR(const LLVector3 &sun_dir_cfr, const LLV mBumpSunDir = adjustedDir * sunDot + sun_dir_cfr * (1.0f - sunDot); mBumpSunDir.normalize(); } - updateDirections(); - - mForceUpdate = true; } void LLVOSky::setSunDirectionCFR(const LLVector3 &sun_dir_cfr) @@ -1660,17 +1607,11 @@ void LLVOSky::setSunDirectionCFR(const LLVector3 &sun_dir_cfr) mBumpSunDir = adjustedDir * sunDot + sun_dir_cfr * (1.0f - sunDot); mBumpSunDir.normalize(); } - updateDirections(); - - mForceUpdate = true; } void LLVOSky::setMoonDirectionCFR(const LLVector3 &moon_dir_cfr) { mMoon.setDirection(moon_dir_cfr); - updateDirections(); - - mForceUpdate = true; } diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index c3a04e12e5..b1a01a9366 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -288,7 +288,7 @@ public: void setSunScale(F32 sun_scale); void setMoonScale(F32 sun_scale); - void forceSkyUpdate(void) { mForceUpdate = TRUE; } + void forceSkyUpdate(void); public: LLFace *mFace[FACE_COUNT]; @@ -337,11 +337,10 @@ protected: F32 mWind; bool mInitialized; - bool mForceUpdate; // flag to force update of cubemap + bool mForceUpdate; + bool mNeedUpdate; // flag to force update of cubemap S32 mCubeMapUpdateStage; // state of cubemap uodate: -1 idle; 0-5 per-face updates; 6 finalizing - LLVector3 mLastSunLightingDirection; - LLVector3 mLastMoonLightingDirection; - LLColor3 mLastTotalAmbient; + F32 mAmbientScale; LLColor3 mNightColorShift; F32 mInterpVal; |