diff options
| -rw-r--r-- | indra/newview/llenvironment.cpp | 28 | ||||
| -rw-r--r-- | indra/newview/llenvironment.h | 7 | ||||
| -rw-r--r-- | indra/newview/llsettingssky.cpp | 34 | ||||
| -rw-r--r-- | indra/newview/llsettingssky.h | 55 | ||||
| -rw-r--r-- | indra/newview/llvosky.cpp | 416 | ||||
| -rw-r--r-- | indra/newview/llvosky.h | 34 | ||||
| -rw-r--r-- | indra/newview/llwaterparammanager.cpp | 2 | 
7 files changed, 314 insertions, 262 deletions
diff --git a/indra/newview/llenvironment.cpp b/indra/newview/llenvironment.cpp index ceba7fda88..4192da450e 100644 --- a/indra/newview/llenvironment.cpp +++ b/indra/newview/llenvironment.cpp @@ -85,7 +85,7 @@ void LLEnvironment::update(const LLViewerCamera * cam)  //         mAnimator.update(mCurParams);  //     } -    LLVector3 lightdir = mCurrentSky->getLightDirection(); +    //LLVector3 lightdir = mCurrentSky->getLightDirection();      // update the shaders and the menu      F32 camYaw = cam->getYaw(); @@ -95,7 +95,7 @@ void LLEnvironment::update(const LLViewerCamera * cam)      // *TODO: potential optimization - this block may only need to be      // executed some of the time.  For example for water shaders only.      { -        LLVector3 lightNorm3(mCurrentSky->getLightDirection()); +        LLVector3 lightNorm3( getLightDirection() );          lightNorm3 *= LLQuaternion(-(camYaw + SUN_DELTA_YAW), LLVector3(0.f, 1.f, 0.f));          mRotatedLight = LLVector4(lightNorm3, 0.f); @@ -125,16 +125,6 @@ void LLEnvironment::updateCloudScroll()      LLVector2 cloud_delta = static_cast<F32>(delta_t)* (mCurrentSky->getCloudScrollRate() - LLVector2(10.0, 10.0)) / 100.0;      mCloudScrollDelta += cloud_delta; -//     { -//         LLVector2 v2(mCurrentSky->getCloudScrollRate()); -//         static F32 xoffset(0.f); -//         static F32 yoffset(0.f); -//  -//         xoffset += F32(delta_t * (v2[0] - 10.f) / 100.f); -//         yoffset += F32(delta_t * (v2[1] - 10.f) / 100.f); -//  -//         LL_WARNS("RIDER") << "offset " << mCloudScrollDelta << " vs (" << xoffset << ", " << yoffset << ")" << LL_ENDL; -//     }  } @@ -223,24 +213,12 @@ void LLEnvironment::updateShaderUniforms(LLGLSLShader *shader)      else if (shader->mShaderGroup == LLGLSLShader::SG_SKY)      {          stop_glerror(); -        shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mCurrentSky->getLightDirectionClamped().mV); +        shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, getClampedLightDirection().mV);          stop_glerror();      }      shader->uniform1f(LLShaderMgr::SCENE_LIGHT_STRENGTH, getSceneLightStrength()); -//     { -//         LLVector4 cloud_scroll(mCloudScroll[0], mCloudScroll[1], 0.0, 0.0); -// //         val.mV[0] = F32(i->second[0].asReal()) + mCloudScrollXOffset; -// //         val.mV[1] = F32(i->second[1].asReal()) + mCloudScrollYOffset; -// //         val.mV[2] = (F32)i->second[2].asReal(); -// //         val.mV[3] = (F32)i->second[3].asReal(); -//  -//         stop_glerror(); -//         shader->uniform4fv(LLSettingsSky::SETTING_CLOUD_POS_DENSITY1, 1, cloud_scroll.mV); -//         stop_glerror(); -//     } -  }  //-------------------------------------------------------------------------- diff --git a/indra/newview/llenvironment.h b/indra/newview/llenvironment.h index 0e8f39b4bf..a1bdf2c38c 100644 --- a/indra/newview/llenvironment.h +++ b/indra/newview/llenvironment.h @@ -48,8 +48,6 @@ public:      void                    update(const LLViewerCamera * cam); -    LLVector4               getRotatedLightDir() const { return mRotatedLight; } -      void                    updateGLVariablesForSettings(LLGLSLShader *shader, const LLSettingsBase::ptr_t &psetting);      void                    updateShaderUniforms(LLGLSLShader *shader); @@ -63,6 +61,9 @@ public:      inline F32              getSceneLightStrength() const { return mSceneLightStrength; }      inline void             setSceneLightStrength(F32 light_strength) { mSceneLightStrength = light_strength; } +    inline LLVector4        getLightDirection() const { return LLVector4(mCurrentSky->getLightDirection(), 0.0f); } +    inline LLVector4        getClampedLightDirection() const { return LLVector4(mCurrentSky->getClampedLightDirection(), 0.0f); } +    inline LLVector4        getRotatedLight() const { return mRotatedLight; }  private:      static const F32        SUN_DELTA_YAW; @@ -70,7 +71,6 @@ private:      typedef std::map<std::string, LLSettingsSky::ptr_t> NamedSkyMap_t;      typedef std::map<LLUUID, LLSettingsSky::ptr_t> AssetSkyMap_t; -    LLVector4               mRotatedLight;      LLVector2               mCloudScrollDelta;  // cumulative cloud delta      LLSettingsSky::ptr_t    mCurrentSky; @@ -79,6 +79,7 @@ private:      AssetSkyMap_t           mSkysById;      F32                     mSceneLightStrength; +    LLVector4               mRotatedLight;      void addSky(const LLUUID &id, const LLSettingsSky::ptr_t &sky);      void removeSky(const std::string &name); diff --git a/indra/newview/llsettingssky.cpp b/indra/newview/llsettingssky.cpp index 191ca2d2ec..d4d9172a75 100644 --- a/indra/newview/llsettingssky.cpp +++ b/indra/newview/llsettingssky.cpp @@ -43,7 +43,7 @@  //=========================================================================  namespace  { -    const LLVector3 DUE_EAST(-1.0f, 0.0f, 0.0); +    const LLVector3 DUE_EAST(0.0f, 0.0f, 1.0);      LLTrace::BlockTimerStatHandle FTM_BLEND_ENVIRONMENT("Blending Environment Params");      LLTrace::BlockTimerStatHandle FTM_UPDATE_ENVIRONMENT("Update Environment Params"); @@ -52,6 +52,8 @@ namespace  } +const F32 LLSettingsSky::DOME_OFFSET(0.96f); +const F32 LLSettingsSky::DOME_RADIUS(15000.f);  //=========================================================================  const std::string LLSettingsSky::SETTING_AMBIENT("ambient"); @@ -226,7 +228,7 @@ LLSettingsSky::ptr_t LLSettingsSky::buildFromLegacyPreset(const std::string &nam          F32 altitude = oldsettings[SETTING_LEGACY_SUN_ANGLE].asReal();          LLQuaternion sunquat = ::body_position_from_angles(azimuth, altitude); -        LLQuaternion moonquat = ~sunquat; +        LLQuaternion moonquat = ::body_position_from_angles(azimuth + F_PI, -altitude);          newsettings[SETTING_SUN_ROTATION] = sunquat.getValue();          newsettings[SETTING_MOON_ROTATION] = moonquat.getValue(); @@ -302,8 +304,8 @@ LLSD LLSettingsSky::defaults()      dfltsetting[SETTING_BLOOM_TEXTUREID]    = LLUUID::null;      dfltsetting[SETTING_CLOUD_TEXTUREID]    = LLUUID::null; -    dfltsetting[SETTING_MOON_TEXTUREID]     = IMG_SUN; // gMoonTextureID;   // These two are returned by the login... wow! -    dfltsetting[SETTING_SUN_TEXUTUREID]     = IMG_MOON; // gSunTextureID; +    dfltsetting[SETTING_MOON_TEXTUREID]     = IMG_MOON; // gMoonTextureID;   // These two are returned by the login... wow! +    dfltsetting[SETTING_SUN_TEXUTUREID]     = IMG_SUN;  // gSunTextureID;      return dfltsetting;  } @@ -327,6 +329,12 @@ void LLSettingsSky::calculateHeavnlyBodyPositions()      mMoonDirection = DUE_EAST * getMoonRotation();      mMoonDirection.normalize(); +    {   // set direction (in CRF) and don't allow overriding +        LLVector3 crf_sunDirection(mSunDirection.mV[2], mSunDirection.mV[0], mSunDirection.mV[1]); + +        gSky.setSunDirection(crf_sunDirection, LLVector3(0, 0, 0)); +        gSky.setOverrideSun(TRUE); +    }      // is the normal from the sun or the moon      if (mSunDirection.mV[1] >= 0.0) @@ -338,7 +346,7 @@ void LLSettingsSky::calculateHeavnlyBodyPositions()          // clamp v1 to 0 so sun never points up and causes weirdness on some machines          LLVector3 vec(mSunDirection);          vec.mV[1] = 0.0; -        vec.normVec(); +        vec.normalize();          mLightDirection = vec;      }      else @@ -348,16 +356,18 @@ void LLSettingsSky::calculateHeavnlyBodyPositions()      // calculate the clamp lightnorm for sky (to prevent ugly banding in sky      // when haze goes below the horizon -    mLightDirectionClamped = mSunDirection; +    mClampedLightDirection = mLightDirection; -    if (mLightDirectionClamped.mV[1] < -0.1f) +    if (mClampedLightDirection.mV[1] < -0.1f)      { -        mLightDirectionClamped.mV[1] = -0.1f; +        mClampedLightDirection.mV[1] = -0.1f; +        mClampedLightDirection.normalize();      }  }  void LLSettingsSky::calculateLightSettings()  { +#if 0      LLColor3 vary_HazeColor;      LLColor3 vary_SunlightColor;      LLColor3 vary_AmbientColor; @@ -461,7 +471,7 @@ void LLSettingsSky::calculateLightSettings()      mFadeColor = mTotalAmbient + (mSunDiffuse + mMoonDiffuse) * 0.5f;      mFadeColor.setAlpha(1); - +#endif  }  LLSettingsSky::parammapping_t LLSettingsSky::getParameterMap() const @@ -495,7 +505,7 @@ void LLSettingsSky::applySpecial(void *ptarget)  {      LLGLSLShader *shader = (LLGLSLShader *)ptarget; -    shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mLightDirectionClamped.mV); +    shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, mClampedLightDirection.mV);      shader->uniform4f(LLShaderMgr::GAMMA, getGama(), 0.0, 0.0, 1.0); @@ -529,8 +539,8 @@ namespace  {      LLQuaternion body_position_from_angles(F32 azimuth, F32 altitude)      { -        static const LLVector3 VECT_ZENITH(0.f, 0.f, 1.f); -        static const LLVector3 VECT_NORTHSOUTH(0.f, 1.f, 0.f); +        static const LLVector3 VECT_ZENITH(0.f, 1.f, 0.f); +        static const LLVector3 VECT_NORTHSOUTH(1.f, 0.f, 0.f);          // Azimuth is traditionally calculated from North, we are going from East.          LLQuaternion rot_azi; diff --git a/indra/newview/llsettingssky.h b/indra/newview/llsettingssky.h index f6d1087442..0274661643 100644 --- a/indra/newview/llsettingssky.h +++ b/indra/newview/llsettingssky.h @@ -151,12 +151,14 @@ public:      F32 getDomeOffset() const      { -        return mSettings[SETTING_DOME_OFFSET].asReal(); +        return DOME_OFFSET; +        //return mSettings[SETTING_DOME_OFFSET].asReal();      }      F32 getDomeRadius() const      { -        return mSettings[SETTING_DOME_RADIUS].asReal(); +        return DOME_RADIUS; +        //return mSettings[SETTING_DOME_RADIUS].asReal();      }      F32 getGama() const @@ -219,7 +221,6 @@ public:          return mSettings[SETTING_SUN_TEXUTUREID].asUUID();      } -      // Internal/calculated settings      LLVector3 getLightDirection() const      { @@ -227,6 +228,32 @@ public:          return mLightDirection;      }; +    LLVector3 getClampedLightDirection() const +    { +        update(); +        return mClampedLightDirection; +    }; + +    LLVector3   getSunDirection() const +    { +        update(); +        return mSunDirection; +    } + +    LLVector3   getMoonDirection() const +    { +        update(); +        return mMoonDirection; +    } + + +#if 0 +    LLVector3 getLightDirection() const +    { +        update(); +        return mLightDirection; +    }; +      LLVector3 getLightDirectionClamped() const      {          update(); @@ -280,6 +307,7 @@ public:          update();          return mFadeColor;      } +#endif  protected:      LLSettingsSky(); @@ -299,15 +327,18 @@ private:      LLVector3   mSunDirection;      LLVector3   mMoonDirection;      LLVector3   mLightDirection; -    LLVector3   mLightDirectionClamped; - -    LLColor3    mSunDiffuse; -    LLColor3    mSunAmbient; -    LLColor3    mMoonDiffuse; -    LLColor3    mMoonAmbient;         -     -    LLColor4    mTotalAmbient; -    LLColor4    mFadeColor; +    LLVector3   mClampedLightDirection; + +    static const F32 DOME_RADIUS; +    static const F32 DOME_OFFSET; + +//     LLColor3    mSunDiffuse; +//     LLColor3    mSunAmbient; +//     LLColor3    mMoonDiffuse; +//     LLColor3    mMoonAmbient;         +//      +//     LLColor4    mTotalAmbient; +//     LLColor4    mFadeColor;      typedef std::map<std::string, S32> mapNameToUniformId_t; diff --git a/indra/newview/llvosky.cpp b/indra/newview/llvosky.cpp index dc6e6e9e45..71abad79b6 100644 --- a/indra/newview/llvosky.cpp +++ b/indra/newview/llvosky.cpp @@ -331,24 +331,24 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)  	mBumpSunDir(0.f, 0.f, 1.f)  {  	/// WL PARAMS -	dome_radius = 1.f; -	dome_offset_ratio = 0.f; -	sunlight_color = LLColor3(); -	ambient = LLColor3(); -	gamma = 1.f; -	lightnorm = LLVector4(); -	blue_density = LLColor3(); -	blue_horizon = LLColor3(); -	haze_density = 0.f; -	haze_horizon = 1.f; -	density_multiplier = 0.f; -	max_y = 0.f; -	glow = LLColor3(); -	cloud_shadow = 0.f; -	cloud_color = LLColor3(); -	cloud_scale = 0.f; -	cloud_pos_density1 = LLColor3(); -	cloud_pos_density2 = LLColor3(); +//	dome_radius = 1.f; +//	dome_offset_ratio = 0.f; +//	sunlight_color = LLColor3(); +//	ambient = LLColor3(); +//	gamma = 1.f; +//	lightnorm = LLVector4(); +//	blue_density = LLColor3(); +//	blue_horizon = LLColor3(); +//	haze_density = 0.f; +//	haze_horizon = 1.f; +//	density_multiplier = 0.f; +//	max_y = 0.f; +//	glow = LLColor3(); +//	cloud_shadow = 0.f; +//	cloud_color = LLColor3(); +//	cloud_scale = 0.f; +//	cloud_pos_density1 = LLColor3(); +//	cloud_pos_density2 = LLColor3();  	mInitialized = FALSE;  	mbCanSelect = FALSE; @@ -369,11 +369,12 @@ LLVOSky::LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp)  	mEarthCenter = LLVector3(mCameraPosAgent.mV[0], mCameraPosAgent.mV[1], -EARTH_RADIUS);      // *LAPRAS -    mSunDefaultPosition = LLEnvironment::instance().getCurrentSky()->getLightNormal(); +    mSunDefaultPosition = LLEnvironment::instance().getCurrentSky()->getSunDirection();  	if (gSavedSettings.getBOOL("SkyOverrideSimSunPosition"))  	{ -		initSunDirection(mSunDefaultPosition, LLVector3(0, 0, 0)); + +        initSunDirection(LLVector3(mSunDefaultPosition.mV[2], mSunDefaultPosition.mV[0], mSunDefaultPosition.mV[1]), LLVector3(0, 0, 0));  	}  	mAmbientScale = gSavedSettings.getF32("SkyAmbientScale");  	mNightColorShift = gSavedSettings.getColor3("SkyNightColorShift"); @@ -569,33 +570,35 @@ void LLVOSky::initAtmospherics(void)      // *LAPRAS      // uniform parameters for convenience -    LLSettingsSky::ptr_t sky = LLEnvironment::instance().getCurrentSky(); - -    dome_radius = sky->getDomeRadius(); -    dome_offset_ratio = sky->getDomeOffset(); -    sunlight_color = sky->getSunlightColor(); -    ambient = sky->getAmbientColor(); -    gamma = sky->getGama(); -    blue_density = sky->getBlueDensity(); -    blue_horizon = sky->getBlueHorizon(); -    haze_density = sky->getHazeDensity(); -    haze_horizon = sky->getHazeHorizon(); -    density_multiplier = sky->getDensityMultiplier(); -    max_y = sky->getMaxY(); -    glow = sky->getGlow(); -    cloud_shadow = sky->getCloudShadow(); -    cloud_color = sky->getCloudColor(); -    cloud_scale = sky->getCloudScale(); -    cloud_pos_density1 = sky->getCloudPosDensity1(); -    cloud_pos_density2 = sky->getCloudPosDensity2(); +    LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + +//    dome_radius = psky->getDomeRadius(); +//    dome_offset_ratio = psky->getDomeOffset(); +//    sunlight_color = psky->getSunlightColor(); +//    ambient = psky->getAmbientColor(); +//    gamma = psky->getGama(); +//    blue_density = psky->getBlueDensity(); +//    blue_horizon = psky->getBlueHorizon(); +//    haze_density = psky->getHazeDensity(); +//    haze_horizon = psky->getHazeHorizon(); +//    density_multiplier = psky->getDensityMultiplier(); +//    max_y = psky->getMaxY(); +//    glow = psky->getGlow(); +//    cloud_shadow = psky->getCloudShadow(); +//    cloud_color = psky->getCloudColor(); +//    cloud_scale = psky->getCloudScale(); +//    cloud_pos_density1 = psky->getCloudPosDensity1(); +//    cloud_pos_density2 = psky->getCloudPosDensity2();  	// light norm is different.  We need the sun's direction, not the light direction  	// which could be from the moon.  And we need to clamp it  	// just like for the gpu -	LLVector3 sunDir = gSky.getSunDirection(); +//	LLVector3 sunDir = gSky.getSunDirection(); +    LLVector3 sunDir = psky->getSunDirection();  	// CFR_TO_OGL -	lightnorm = LLVector4(sunDir.mV[1], sunDir.mV[2], sunDir.mV[0], 0); +//	lightnorm = LLVector4(sunDir.mV[1], sunDir.mV[2], sunDir.mV[0], 0); +    lightnorm = LLVector4(sunDir, 0);  	unclamped_lightnorm = lightnorm;  	if(lightnorm.mV[1] < -0.1f)  	{ @@ -676,6 +679,11 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo  							LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity,   							LLVector2 vary_HorizontalProjection[2])  { +    LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); + +    LLColor3 blue_density = psky->getBlueDensity(); +    F32      max_y = psky->getMaxY(); +  	// project the direction ray onto the sky dome.  	F32 phi = acos(Pn[1]);  	F32 sinA = sin(F_PI - phi); @@ -684,7 +692,8 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo  		sinA = 0.01f;  	} -	F32 Plen = dome_radius * sin(F_PI + phi + asin(dome_offset_ratio * sinA)) / sinA; +//	F32 Plen = dome_radius * sin(F_PI + phi + asin(dome_offset_ratio * sinA)) / sinA; +	F32 Plen = psky->getDomeRadius() * sin(F_PI + phi + asin(psky->getDomeOffset() * sinA)) / sinA;  	Pn *= Plen; @@ -705,7 +714,14 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo  	Pn /= Plen;  	// Initialize temp variables -	LLColor3 sunlight = sunlight_color; +	LLColor3 sunlight = psky->getSunlightColor(); +    LLColor3 ambient = psky->getAmbientColor(); +    LLColor3 blue_horizon = psky->getBlueHorizon(); +    F32 haze_density = psky->getHazeDensity(); +    F32 haze_horizon = psky->getHazeHorizon(); +    F32 density_multiplier = psky->getDensityMultiplier(); +    LLColor3 glow = psky->getGlow(); +    F32 cloud_shadow = psky->getCloudShadow();  	// Sunlight attenuation effect (hue and brightness) due to atmosphere  	// this is used later for sunlight modulation at various altitudes @@ -766,7 +782,7 @@ void LLVOSky::calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLCo  	// Final atmosphere additive  	componentMultBy(vary_HazeColor, LLColor3::white - temp1); -	sunlight = sunlight_color; +	sunlight = psky->getSunlightColor();  	temp2.mV[1] = llmax(0.f, lightnorm[1] * 2.f);  	temp2.mV[1] = 1.f / temp2.mV[1];  	componentMultBy(sunlight, componentExp((light_atten * -1.f) * temp2.mV[1])); @@ -807,8 +823,10 @@ LLColor3 LLVOSky::calcSkyColorWLFrag(LLVector3 & Pn, LLColor3 & vary_HazeColor,  							LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity,   							LLVector2 vary_HorizontalProjection[2])  { -	LLColor3 res; +    LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky(); +    F32 gamma = psky->getGama(); +	LLColor3 res;  	LLColor3 color0 = vary_HazeColor;  	if (!gPipeline.canUseWindLightShaders()) @@ -874,6 +892,7 @@ LLColor3 LLVOSky::createAmbientFromWL(LLColor3 ambient, LLColor3 sundiffuse, LLC  void LLVOSky::calcAtmospherics(void)  { +    LLSettingsSky::ptr_t psky = LLEnvironment::instance().getCurrentSky();  	initAtmospherics();  	LLColor3 vary_HazeColor; @@ -881,7 +900,16 @@ void LLVOSky::calcAtmospherics(void)  	LLColor3 vary_AmbientColor;  	{  		// Initialize temp variables -		LLColor3 sunlight = sunlight_color; +		LLColor3 sunlight = psky->getSunlightColor(); +        LLColor3 ambient = psky->getAmbientColor(); +        F32      gamma = psky->getGama(); +        LLColor3 blue_density = psky->getBlueDensity(); +        LLColor3 blue_horizon = psky->getBlueHorizon(); +        F32      haze_density = psky->getHazeDensity(); +        F32      haze_horizon = psky->getHazeHorizon(); +        F32      density_multiplier = psky->getDensityMultiplier(); +        F32      max_y = psky->getMaxY(); +        F32      cloud_shadow = psky->getCloudShadow();  		// Sunlight attenuation effect (hue and brightness) due to atmosphere  		// this is used later for sunlight modulation at various altitudes @@ -1210,6 +1238,7 @@ BOOL LLVOSky::updateGeometry(LLDrawable *drawable)  	}  	mCameraPosAgent = drawable->getPositionAgent(); +  	mEarthCenter.mV[0] = mCameraPosAgent.mV[0];  	mEarthCenter.mV[1] = mCameraPosAgent.mV[1]; @@ -1808,152 +1837,155 @@ void LLVOSky::updateReflectionGeometry(LLDrawable *drawable, F32 H,  	LLFace *face = mFace[FACE_REFLECTION];  -	if (!face->getVertexBuffer() || quads*4 != face->getGeomCount()) -	{ -		face->setSize(quads * 4, quads * 6); -		LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); -		buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE); -		face->setIndicesIndex(0); -		face->setGeomIndex(0); -		face->setVertexBuffer(buff); -	} -	 -	LLStrider<LLVector3> verticesp; -	LLStrider<LLVector3> normalsp; -	LLStrider<LLVector2> texCoordsp; -	LLStrider<U16> indicesp; -	S32 index_offset; -	 -	index_offset = face->getGeometry(verticesp,normalsp,texCoordsp, indicesp); -	if (-1 == index_offset) -	{ -		return; -	} - -	LLColor3 hb_col3 = HB.getInterpColor(); -	hb_col3.clamp(); -	const LLColor4 hb_col = LLColor4(hb_col3); - -	const F32 min_attenuation = 0.4f; -	const F32 max_attenuation = 0.7f; -	const F32 attenuation = min_attenuation -		+ cos_angle_of_view * (max_attenuation - min_attenuation); - -	LLColor4 hb_refl_col = (1-attenuation) * hb_col + attenuation * mFogColor; -	face->setFaceColor(hb_refl_col); -	 -	LLVector3 v_far[2]; -	v_far[0] = v_refl_corner[1]; -	v_far[1] = v_refl_corner[3]; - -	if(dt_clip > 0) -	{ -		if (dt_clip >= 1) -		{ -			for (S32 vtx = 0; vtx < 4; ++vtx) -			{ -				F32 ratio = far_clip / v_refl_corner[vtx].length(); -				*(verticesp++) = v_refl_corner[vtx] = ratio * v_refl_corner[vtx] + mCameraPosAgent; -			} -			const LLVector3 draw_pos = 0.25 * -				(v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); -			face->mCenterAgent = draw_pos; -		} -		else -		{ -			F32 ratio = far_clip / v_refl_corner[1].length(); -			v_sprite_corner[1] = v_refl_corner[1] * ratio; - -			ratio = far_clip / v_refl_corner[3].length(); -			v_sprite_corner[3] = v_refl_corner[3] * ratio; - -			v_refl_corner[1] = (1 - dt_clip) * v_refl_corner[1] + dt_clip * v_refl_corner[0]; -			v_refl_corner[3] = (1 - dt_clip) * v_refl_corner[3] + dt_clip * v_refl_corner[2]; -			v_sprite_corner[0] = v_refl_corner[1]; -			v_sprite_corner[2] = v_refl_corner[3]; - -			for (S32 vtx = 0; vtx < 4; ++vtx) -			{ -				*(verticesp++) = v_sprite_corner[vtx] + mCameraPosAgent; -			} - -			const LLVector3 draw_pos = 0.25 * -				(v_refl_corner[0] + v_sprite_corner[1] + v_refl_corner[2] + v_sprite_corner[3]); -			face->mCenterAgent = draw_pos; -		} - -		*(texCoordsp++) = TEX0tt; -		*(texCoordsp++) = TEX0t; -		*(texCoordsp++) = TEX1tt; -		*(texCoordsp++) = TEX1t; - -		*indicesp++ = index_offset + 0; -		*indicesp++ = index_offset + 2; -		*indicesp++ = index_offset + 1; - -		*indicesp++ = index_offset + 1; -		*indicesp++ = index_offset + 2; -		*indicesp++ = index_offset + 3; - -		index_offset += 4; -	} - -	if (dt_clip < 1) -	{ -		if (dt_clip <= 0) -		{ -			const LLVector3 draw_pos = 0.25 * -				(v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); -			face->mCenterAgent = draw_pos; -		} - -		const F32 raws_inv = 1.f/raws; -		const F32 cols_inv = 1.f/cols; -		LLVector3 left	= v_refl_corner[0] - v_refl_corner[1]; -		LLVector3 right = v_refl_corner[2] - v_refl_corner[3]; -		left *= raws_inv; -		right *= raws_inv; - -		F32 dt_raw = dt; - -		for (S32 raw = 0; raw < raws; ++raw) -		{ -			F32 dt_v0 = raw * raws_inv; -			F32 dt_v1 = (raw + 1) * raws_inv; -			const LLVector3 BL = v_refl_corner[1] + (F32)raw * left; -			const LLVector3 BR = v_refl_corner[3] + (F32)raw * right; -			const LLVector3 EL = BL + left; -			const LLVector3 ER = BR + right; -			dt_v0 = dt_raw; -			dt_raw = dt_v1 = dtReflection(EL, cos_dir_from_top[0], sin_dir_from_top, diff_angl_dir); -			for (S32 col = 0; col < cols; ++col) -			{ -				F32 dt_h0 = col * cols_inv; -				*(verticesp++) = (1 - dt_h0) * EL + dt_h0 * ER + mCameraPosAgent; -				*(verticesp++) = (1 - dt_h0) * BL + dt_h0 * BR + mCameraPosAgent; -				F32 dt_h1 = (col + 1) * cols_inv; -				*(verticesp++) = (1 - dt_h1) * EL + dt_h1 * ER + mCameraPosAgent; -				*(verticesp++) = (1 - dt_h1) * BL + dt_h1 * BR + mCameraPosAgent; - -				*(texCoordsp++) = LLVector2(dt_h0, dt_v1); -				*(texCoordsp++) = LLVector2(dt_h0, dt_v0); -				*(texCoordsp++) = LLVector2(dt_h1, dt_v1); -				*(texCoordsp++) = LLVector2(dt_h1, dt_v0); - -				*indicesp++ = index_offset + 0; -				*indicesp++ = index_offset + 2; -				*indicesp++ = index_offset + 1; - -				*indicesp++ = index_offset + 1; -				*indicesp++ = index_offset + 2; -				*indicesp++ = index_offset + 3; - -				index_offset += 4; -			} -		} -	} - -	face->getVertexBuffer()->flush(); +    if (face) +    { +        if (!face->getVertexBuffer() || quads * 4 != face->getGeomCount()) +        { +            face->setSize(quads * 4, quads * 6); +            LLVertexBuffer* buff = new LLVertexBuffer(LLDrawPoolWater::VERTEX_DATA_MASK, GL_STREAM_DRAW_ARB); +            buff->allocateBuffer(face->getGeomCount(), face->getIndicesCount(), TRUE); +            face->setIndicesIndex(0); +            face->setGeomIndex(0); +            face->setVertexBuffer(buff); +        } + +        LLStrider<LLVector3> verticesp; +        LLStrider<LLVector3> normalsp; +        LLStrider<LLVector2> texCoordsp; +        LLStrider<U16> indicesp; +        S32 index_offset; + +        index_offset = face->getGeometry(verticesp, normalsp, texCoordsp, indicesp); +        if (-1 == index_offset) +        { +            return; +        } + +        LLColor3 hb_col3 = HB.getInterpColor(); +        hb_col3.clamp(); +        const LLColor4 hb_col = LLColor4(hb_col3); + +        const F32 min_attenuation = 0.4f; +        const F32 max_attenuation = 0.7f; +        const F32 attenuation = min_attenuation +            + cos_angle_of_view * (max_attenuation - min_attenuation); + +        LLColor4 hb_refl_col = (1 - attenuation) * hb_col + attenuation * mFogColor; +        face->setFaceColor(hb_refl_col); + +        LLVector3 v_far[2]; +        v_far[0] = v_refl_corner[1]; +        v_far[1] = v_refl_corner[3]; + +        if (dt_clip > 0) +        { +            if (dt_clip >= 1) +            { +                for (S32 vtx = 0; vtx < 4; ++vtx) +                { +                    F32 ratio = far_clip / v_refl_corner[vtx].length(); +                    *(verticesp++) = v_refl_corner[vtx] = ratio * v_refl_corner[vtx] + mCameraPosAgent; +                } +                const LLVector3 draw_pos = 0.25 * +                    (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); +                face->mCenterAgent = draw_pos; +            } +            else +            { +                F32 ratio = far_clip / v_refl_corner[1].length(); +                v_sprite_corner[1] = v_refl_corner[1] * ratio; + +                ratio = far_clip / v_refl_corner[3].length(); +                v_sprite_corner[3] = v_refl_corner[3] * ratio; + +                v_refl_corner[1] = (1 - dt_clip) * v_refl_corner[1] + dt_clip * v_refl_corner[0]; +                v_refl_corner[3] = (1 - dt_clip) * v_refl_corner[3] + dt_clip * v_refl_corner[2]; +                v_sprite_corner[0] = v_refl_corner[1]; +                v_sprite_corner[2] = v_refl_corner[3]; + +                for (S32 vtx = 0; vtx < 4; ++vtx) +                { +                    *(verticesp++) = v_sprite_corner[vtx] + mCameraPosAgent; +                } + +                const LLVector3 draw_pos = 0.25 * +                    (v_refl_corner[0] + v_sprite_corner[1] + v_refl_corner[2] + v_sprite_corner[3]); +                face->mCenterAgent = draw_pos; +            } + +            *(texCoordsp++) = TEX0tt; +            *(texCoordsp++) = TEX0t; +            *(texCoordsp++) = TEX1tt; +            *(texCoordsp++) = TEX1t; + +            *indicesp++ = index_offset + 0; +            *indicesp++ = index_offset + 2; +            *indicesp++ = index_offset + 1; + +            *indicesp++ = index_offset + 1; +            *indicesp++ = index_offset + 2; +            *indicesp++ = index_offset + 3; + +            index_offset += 4; +        } + +        if (dt_clip < 1) +        { +            if (dt_clip <= 0) +            { +                const LLVector3 draw_pos = 0.25 * +                    (v_refl_corner[0] + v_refl_corner[1] + v_refl_corner[2] + v_refl_corner[3]); +                face->mCenterAgent = draw_pos; +            } + +            const F32 raws_inv = 1.f / raws; +            const F32 cols_inv = 1.f / cols; +            LLVector3 left = v_refl_corner[0] - v_refl_corner[1]; +            LLVector3 right = v_refl_corner[2] - v_refl_corner[3]; +            left *= raws_inv; +            right *= raws_inv; + +            F32 dt_raw = dt; + +            for (S32 raw = 0; raw < raws; ++raw) +            { +                F32 dt_v0 = raw * raws_inv; +                F32 dt_v1 = (raw + 1) * raws_inv; +                const LLVector3 BL = v_refl_corner[1] + (F32)raw * left; +                const LLVector3 BR = v_refl_corner[3] + (F32)raw * right; +                const LLVector3 EL = BL + left; +                const LLVector3 ER = BR + right; +                dt_v0 = dt_raw; +                dt_raw = dt_v1 = dtReflection(EL, cos_dir_from_top[0], sin_dir_from_top, diff_angl_dir); +                for (S32 col = 0; col < cols; ++col) +                { +                    F32 dt_h0 = col * cols_inv; +                    *(verticesp++) = (1 - dt_h0) * EL + dt_h0 * ER + mCameraPosAgent; +                    *(verticesp++) = (1 - dt_h0) * BL + dt_h0 * BR + mCameraPosAgent; +                    F32 dt_h1 = (col + 1) * cols_inv; +                    *(verticesp++) = (1 - dt_h1) * EL + dt_h1 * ER + mCameraPosAgent; +                    *(verticesp++) = (1 - dt_h1) * BL + dt_h1 * BR + mCameraPosAgent; + +                    *(texCoordsp++) = LLVector2(dt_h0, dt_v1); +                    *(texCoordsp++) = LLVector2(dt_h0, dt_v0); +                    *(texCoordsp++) = LLVector2(dt_h1, dt_v1); +                    *(texCoordsp++) = LLVector2(dt_h1, dt_v0); + +                    *indicesp++ = index_offset + 0; +                    *indicesp++ = index_offset + 2; +                    *indicesp++ = index_offset + 1; + +                    *indicesp++ = index_offset + 1; +                    *indicesp++ = index_offset + 2; +                    *indicesp++ = index_offset + 3; + +                    index_offset += 4; +                } +            } +        } + +        face->getVertexBuffer()->flush(); +    }  } diff --git a/indra/newview/llvosky.h b/indra/newview/llvosky.h index c865e8701c..32b5a7eba8 100644 --- a/indra/newview/llvosky.h +++ b/indra/newview/llvosky.h @@ -381,25 +381,25 @@ class LLVOSky : public LLStaticViewerObject  {  public:  	/// WL PARAMS -	F32 dome_radius; -	F32 dome_offset_ratio; -	LLColor3 sunlight_color; -	LLColor3 ambient; -	F32 gamma; +//	F32 dome_radius; +//	F32 dome_offset_ratio; +//	LLColor3 sunlight_color; +//	LLColor3 ambient; +//	F32 gamma;  	LLVector4 lightnorm;  	LLVector4 unclamped_lightnorm; -	LLColor3 blue_density; -	LLColor3 blue_horizon; -	F32 haze_density; -	F32 haze_horizon; -	F32 density_multiplier; -	F32 max_y; -	LLColor3 glow; -	F32 cloud_shadow; -	LLColor3 cloud_color; -	F32 cloud_scale; -	LLColor3 cloud_pos_density1; -	LLColor3 cloud_pos_density2; +//	LLColor3 blue_density; +//	LLColor3 blue_horizon; +//	F32 haze_density; +//	F32 haze_horizon; +//	F32 density_multiplier; +//	F32 max_y; +//	LLColor3 glow; +//	F32 cloud_shadow; +//	LLColor3 cloud_color; +//	F32 cloud_scale; +//	LLColor3 cloud_pos_density1; +//	LLColor3 cloud_pos_density2;  public:  	void initAtmospherics(void); diff --git a/indra/newview/llwaterparammanager.cpp b/indra/newview/llwaterparammanager.cpp index 689296a53a..6d1bb43258 100644 --- a/indra/newview/llwaterparammanager.cpp +++ b/indra/newview/llwaterparammanager.cpp @@ -187,7 +187,7 @@ void LLWaterParamManager::updateShaderUniforms(LLGLSLShader * shader)  {  	if (shader->mShaderGroup == LLGLSLShader::SG_WATER)  	{ -		shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLightDir().mV); +		shader->uniform4fv(LLViewerShaderMgr::LIGHTNORM, 1, LLEnvironment::instance().getRotatedLight().mV);          shader->uniform3fv(LLShaderMgr::WL_CAMPOSLOCAL, 1, LLViewerCamera::getInstance()->getOrigin().mV);  		shader->uniform4fv(LLShaderMgr::WATER_FOGCOLOR, 1, LLDrawPoolWater::sWaterFogColor.mV);  		shader->uniform4fv(LLShaderMgr::WATER_WATERPLANE, 1, mWaterPlane.mV);  | 
