diff options
-rw-r--r-- | indra/llinventory/llsettingssky.cpp | 14 | ||||
-rw-r--r-- | indra/llinventory/llsettingssky.h | 6 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwater.cpp | 6 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwlsky.cpp | 13 | ||||
-rw-r--r-- | indra/newview/llenvironment.cpp | 3 | ||||
-rw-r--r-- | indra/newview/llenvironment.h | 1 | ||||
-rw-r--r-- | indra/newview/llsky.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llsky.h | 3 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 8 | ||||
-rw-r--r-- | indra/newview/llvosky.cpp | 25 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 8 |
11 files changed, 47 insertions, 48 deletions
diff --git a/indra/llinventory/llsettingssky.cpp b/indra/llinventory/llsettingssky.cpp index be26439cee..c5dfd765f2 100644 --- a/indra/llinventory/llsettingssky.cpp +++ b/indra/llinventory/llsettingssky.cpp @@ -51,9 +51,6 @@ namespace const F32 LLSettingsSky::DOME_OFFSET(0.96f); const F32 LLSettingsSky::DOME_RADIUS(15000.f); -const F32 LLSettingsSky::NIGHTTIME_ELEVATION(-8.0f); // degrees -const F32 LLSettingsSky::NIGHTTIME_ELEVATION_COS((F32)sin(NIGHTTIME_ELEVATION*DEG_TO_RAD)); - //========================================================================= const std::string LLSettingsSky::SETTING_AMBIENT("ambient"); const std::string LLSettingsSky::SETTING_BLUE_DENSITY("blue_density"); @@ -816,6 +813,7 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() { mSunDirection = DUE_EAST * getSunRotation(); mSunDirection.normalize(); + mMoonDirection = DUE_EAST * getMoonRotation(); mMoonDirection.normalize(); @@ -824,7 +822,7 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() { mLightDirection = mSunDirection; } - else if (mSunDirection.mV[1] < 0.0 && mSunDirection.mV[1] > NIGHTTIME_ELEVATION_COS) + else if (mSunDirection.mV[1] < 0.0 && mSunDirection.mV[1] > NIGHTTIME_ELEVATION_SIN) { // clamp v1 to 0 so sun never points up and causes weirdness on some machines LLVector3 vec(mSunDirection); @@ -834,7 +832,11 @@ void LLSettingsSky::calculateHeavnlyBodyPositions() } else { - mLightDirection = mMoonDirection; + // clamp v1 to 0 so moon never points up and causes weirdness on some machines + LLVector3 vec(mMoonDirection); + vec.mV[1] = 0.0; + vec.normalize(); + mLightDirection = vec; } // calculate the clamp lightnorm for sky (to prevent ugly banding in sky @@ -993,7 +995,7 @@ void LLSettingsSky::calculateLightSettings() // and vary_sunlight will work properly with moon light F32 lighty = lightnorm[1]; - if (lighty < NIGHTTIME_ELEVATION_COS) + if (lighty < NIGHTTIME_ELEVATION_SIN) { lighty = -lighty; } diff --git a/indra/llinventory/llsettingssky.h b/indra/llinventory/llsettingssky.h index 63a20e0d48..8e96735abf 100644 --- a/indra/llinventory/llsettingssky.h +++ b/indra/llinventory/llsettingssky.h @@ -37,6 +37,9 @@ const F32 SUN_DIST = 149598.260e6f; const F32 MOON_RADIUS = 1.737e6f; const F32 MOON_DIST = 384.400e6f; +const F32 NIGHTTIME_ELEVATION = -8.0f; // degrees +const F32 NIGHTTIME_ELEVATION_SIN = (F32)sinf(NIGHTTIME_ELEVATION * DEG_TO_RAD); + class LLSettingsSky: public LLSettingsBase { public: @@ -504,9 +507,6 @@ private: static LLSD absorptionConfigDefault(); static LLSD mieConfigDefault(); - static const F32 NIGHTTIME_ELEVATION; - static const F32 NIGHTTIME_ELEVATION_COS; - void calculateHeavnlyBodyPositions(); void calculateLightSettings(); diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index bdf04bd436..2804ad1f46 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -491,6 +491,8 @@ void LLDrawPoolWater::shade() LLSettingsWater::ptr_t pwater = LLEnvironment::instance().getCurrentWater(); light_dir = voskyp->getLightDirection(); + light_dir.normalize(); + if (LLEnvironment::instance().getIsDayTime()) { light_color = voskyp->getSunAmbientColor(); @@ -501,14 +503,14 @@ void LLDrawPoolWater::shade() } else { - light_color = voskyp->getMoonAmbientColor(); + light_color = voskyp->getMoonDiffuseColor(); 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); } -// if (gSky.getSunDirection().mV[2] > LLSky::NIGHTTIME_ELEVATION_COS) +// if (gSky.getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS) // { // light_dir = gSky.getSunDirection(); // light_dir.normVec(); diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 91bfc3858c..277f1f3d6c 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -329,15 +329,12 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() gGL.getTexUnit(0)->bind(face->getTexture()); LLColor4 color(gSky.mVOSkyp->getMoon().getInterpColor()); -#if 0 - F32 a = gSky.mVOSkyp->getMoon().getDirection().mV[2]; + /*F32 a = gSky.mVOSkyp->getMoon().getDirection().mV[2]; if (a > 0.f) { a = a*a*4.f; - } - - color.mV[3] = llclamp(a, 0.f, 1.f); -#endif + } + color.mV[3] = llclamp(a, 0.f, 1.f);*/ if (gPipeline.canUseVertexShaders()) { @@ -431,7 +428,9 @@ void LLDrawPoolWLSky::render(S32 pass) renderSkyHaze(origin, camHeightLocal); - if (!gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders()) + bool use_advanced = gPipeline.useAdvancedAtmospherics(); + + if (!use_advanced) { gGL.pushMatrix(); diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index d878bd9abe..d37cbfc76d 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -190,7 +190,6 @@ const F32Seconds LLEnvironment::TRANSITION_DEFAULT(5.0f); const F32Seconds LLEnvironment::TRANSITION_SLOW(10.0f); const F32 LLEnvironment::SUN_DELTA_YAW(F_PI); // 180deg -const F32 LLEnvironment::NIGHTTIME_ELEVATION_COS(LLSky::NIGHTTIME_ELEVATION_COS); //------------------------------------------------------------------------- LLEnvironment::LLEnvironment(): @@ -380,7 +379,7 @@ F32 LLEnvironment::getWaterHeight() const bool LLEnvironment::getIsDayTime() const { - return mCurrentEnvironment->getSky()->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_COS; + return mCurrentEnvironment->getSky()->getSunDirection().mV[2] > NIGHTTIME_ELEVATION_SIN; } //------------------------------------------------------------------------- diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 30286d54fd..e4f891deca 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -293,7 +293,6 @@ private: }; static const F32 SUN_DELTA_YAW; - static const F32 NIGHTTIME_ELEVATION_COS; typedef std::map<LLUUID, LLSettingsBase::ptr_t> AssetSettingMap_t; diff --git a/indra/newview/llsky.cpp b/indra/newview/llsky.cpp index 15aebda5ad..a81e74b6ed 100644 --- a/indra/newview/llsky.cpp +++ b/indra/newview/llsky.cpp @@ -51,18 +51,16 @@ #include "llvosky.h" #include "llcubemap.h" #include "llviewercontrol.h" +#include "llenvironment.h" #include "llvowlsky.h" F32 azimuth_from_vector(const LLVector3 &v); F32 elevation_from_vector(const LLVector3 &v); -LLSky gSky; -// ---------------- LLSky ---------------- - -const F32 LLSky::NIGHTTIME_ELEVATION = -8.0f; // degrees -const F32 LLSky::NIGHTTIME_ELEVATION_COS = (F32)sin(NIGHTTIME_ELEVATION*DEG_TO_RAD); +LLSky gSky; +// ---------------- LLSky ---------------- ////////////////////////////////////////////////////////////////////// // Construction/Destruction ////////////////////////////////////////////////////////////////////// diff --git a/indra/newview/llsky.h b/indra/newview/llsky.h index 010cc30d55..27029b254b 100644 --- a/indra/newview/llsky.h +++ b/indra/newview/llsky.h @@ -97,9 +97,6 @@ public: // Legacy stuff LLVector3 mSunDefaultPosition; - static const F32 NIGHTTIME_ELEVATION; // degrees - static const F32 NIGHTTIME_ELEVATION_COS; - protected: F32 mSunPhase; LLColor4 mFogColor; // Color to use for fog and haze diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 95e4f27a39..40cf4c82e6 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -46,6 +46,8 @@ #include "llenvironment.h" #include "llatmosphere.h" +#pragma optimize("", off) + #ifdef LL_RELEASE_FOR_DOWNLOAD #define UNIFORM_ERRS LL_WARNS_ONCE("Shader") #else @@ -509,8 +511,9 @@ void LLViewerShaderMgr::setShaders() wl_class = llmin(wl_class, 2); } - if (!(LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders") - && gSavedSettings.getBOOL("WindLightUseAtmosShaders"))) + bool hasWindLightShaders = LLFeatureManager::getInstance()->isFeatureAvailable("WindLightUseAtmosShaders"); + bool useWindLightShaders = gSavedSettings.getBOOL("WindLightUseAtmosShaders"); + if (!hasWindLightShaders || !useWindLightShaders) { // user has disabled WindLight in their settings, downgrade // windlight shaders to stub versions. @@ -544,7 +547,6 @@ void LLViewerShaderMgr::setShaders() // Load all shaders to set max levels loaded = loadShadersEnvironment(); - llassert(loaded); if (loaded) { diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index 5f55f6c310..1e99c77da9 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -700,6 +700,12 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable) bool draw_sun = updateHeavenlyBodyGeometry(drawable, FACE_SUN, mSun, up, right); bool draw_moon = updateHeavenlyBodyGeometry(drawable, FACE_MOON, mMoon, up, right); + bool daytime = LLEnvironment::getInstance()->getIsDayTime(); + + // makeshift check until we properly handle moon in daytime + draw_sun &= daytime; + draw_moon &= !daytime; + mSun.setDraw(draw_sun); mMoon.setDraw(draw_moon); @@ -763,16 +769,7 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, LLHe S32 index_offset; LLFace *facep; - LLVector3 to_dir = hb.getDirection(); - - /*F32 rad = hb.getDiskRadius(); - F32 d = to_dir * LLVector3::z_axis; - if (d < -(rad * 0.5f)) - { - hb.setVisible(FALSE); - return FALSE; - }*/ - + LLVector3 to_dir = hb.getDirection(); LLVector3 draw_pos = to_dir * HEAVENLY_BODY_DIST; LLVector3 hb_right = to_dir % LLVector3::z_axis; @@ -780,8 +777,12 @@ BOOL LLVOSky::updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 f, LLHe hb_right.normalize(); hb_up.normalize(); - const LLVector3 scaled_right = HEAVENLY_BODY_DIST * hb.getDiskRadius() * hb_right; - const LLVector3 scaled_up = HEAVENLY_BODY_DIST * hb.getDiskRadius() * hb_up; + const F32 enlargm_factor = ( 1 - to_dir.mV[2] ); + F32 horiz_enlargement = 1 + enlargm_factor * 0.3f; + F32 vert_enlargement = 1 + enlargm_factor * 0.2f; + + const LLVector3 scaled_right = horiz_enlargement * HEAVENLY_BODY_DIST * HEAVENLY_BODY_FACTOR * hb.getDiskRadius() * hb_right; + const LLVector3 scaled_up = vert_enlargement * HEAVENLY_BODY_DIST * HEAVENLY_BODY_FACTOR * hb.getDiskRadius() * hb_up; LLVector3 v_clipped[4]; diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 6ad47386c7..b2ec9a6a66 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -927,7 +927,7 @@ bool LLPipeline::allocateScreenBuffer(U32 resX, U32 resY, U32 samples) for (U32 i = 0; i < 4; i++) { if (!mShadow[i].allocate(sun_shadow_map_width,U32(resY*scale), 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) return false; - if (!mShadowOcclusion[i].allocate(mShadow[i].getWidth()/occlusion_divisor, mShadow[i].getHeight()/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) return false; + if (!mShadowOcclusion[i].allocate(mShadow[i].getWidth()/occlusion_divisor, mShadow[i].getHeight()/occlusion_divisor, 0, TRUE, FALSE, LLTexUnit::TT_TEXTURE)) return false; } } else @@ -6034,7 +6034,7 @@ void LLPipeline::setupAvatarLights(bool for_edit) } } F32 backlight_mag; - if (gSky.getSunDirection().mV[2] >= LLSky::NIGHTTIME_ELEVATION_COS) + if (gSky.getSunDirection().mV[2] >= NIGHTTIME_ELEVATION_SIN) { backlight_mag = BACKLIGHT_DAY_MAGNITUDE_OBJECT; } @@ -6253,7 +6253,7 @@ void LLPipeline::setupHWLights(LLDrawPool* pool) // Light 0 = Sun or Moon (All objects) { - if (gSky.getSunDirection().mV[2] >= LLSky::NIGHTTIME_ELEVATION_COS) + if (gSky.getSunDirection().mV[2] >= NIGHTTIME_ELEVATION_SIN) { mSunDir.setVec(gSky.getSunDirection()); mSunDiffuse.setVec(gSky.getSunDiffuseColor()); @@ -9124,7 +9124,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) } } -// pretty sure this doesn't work as expected since the shaders using 'shadow_ofset' all declare it as a single uniform float, no array or vec +// pretty sure this doesn't work as expected since the shaders using 'shadow_offset' all declare it as a single uniform float, no array or vec gDeferredSunProgram.uniform3fv(LLShaderMgr::DEFERRED_SHADOW_OFFSET, slice, offset); gDeferredSunProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, mDeferredLight.getWidth(), mDeferredLight.getHeight()); |