/indra/newview/llvosky.h

https://bitbucket.org/lindenlab/viewer-beta/ · C Header · 647 lines · 472 code · 122 blank · 53 comment · 5 complexity · 611477fc056639a78f429329cd4d4663 MD5 · raw file

  1. /**
  2. * @file llvosky.h
  3. * @brief LLVOSky class header file
  4. *
  5. * $LicenseInfo:firstyear=2001&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLVOSKY_H
  27. #define LL_LLVOSKY_H
  28. #include "stdtypes.h"
  29. #include "v3color.h"
  30. #include "v4coloru.h"
  31. #include "llviewertexture.h"
  32. #include "llviewerobject.h"
  33. #include "llframetimer.h"
  34. //////////////////////////////////
  35. //
  36. // Lots of constants
  37. //
  38. // Will clean these up at some point...
  39. //
  40. const F32 HORIZON_DIST = 1024.0f;
  41. const F32 SKY_BOX_MULT = 16.0f;
  42. const F32 HEAVENLY_BODY_DIST = HORIZON_DIST - 10.f;
  43. const F32 HEAVENLY_BODY_FACTOR = 0.1f;
  44. const F32 HEAVENLY_BODY_SCALE = HEAVENLY_BODY_DIST * HEAVENLY_BODY_FACTOR;
  45. const F32 EARTH_RADIUS = 6.4e6f; // exact radius = 6.37 x 10^6 m
  46. const F32 ATM_EXP_FALLOFF = 0.000126f;
  47. const F32 ATM_SEA_LEVEL_NDENS = 2.55e25f;
  48. // Somewhat arbitrary:
  49. const F32 ATM_HEIGHT = 100000.f;
  50. const F32 FIRST_STEP = 5000.f;
  51. const F32 INV_FIRST_STEP = 1.f/FIRST_STEP;
  52. const S32 NO_STEPS = 15;
  53. const F32 INV_NO_STEPS = 1.f/NO_STEPS;
  54. // constants used in calculation of scattering coeff of clear air
  55. const F32 sigma = 0.035f;
  56. const F32 fsigma = (6.f + 3.f * sigma) / (6.f-7.f*sigma);
  57. const F64 Ndens = 2.55e25;
  58. const F64 Ndens2 = Ndens*Ndens;
  59. // HACK: Allow server to change sun and moon IDs.
  60. // I can't figure out how to pass the appropriate
  61. // information into the LLVOSky constructor. JC
  62. extern LLUUID gSunTextureID;
  63. extern LLUUID gMoonTextureID;
  64. LL_FORCE_INLINE LLColor3 color_div(const LLColor3 &col1, const LLColor3 &col2)
  65. {
  66. return LLColor3(
  67. col1.mV[0] / col2.mV[0],
  68. col1.mV[1] / col2.mV[1],
  69. col1.mV[2] / col2.mV[2] );
  70. }
  71. LLColor3 color_norm(const LLColor3 &col);
  72. BOOL clip_quad_to_horizon(F32& t_left, F32& t_right, LLVector3 v_clipped[4],
  73. const LLVector3 v_corner[4], const F32 cos_max_angle);
  74. F32 clip_side_to_horizon(const LLVector3& v0, const LLVector3& v1, const F32 cos_max_angle);
  75. inline F32 color_intens ( const LLColor3 &col )
  76. {
  77. return col.mV[0] + col.mV[1] + col.mV[2];
  78. }
  79. inline F32 color_max(const LLColor3 &col)
  80. {
  81. return llmax(col.mV[0], col.mV[1], col.mV[2]);
  82. }
  83. inline F32 color_max(const LLColor4 &col)
  84. {
  85. return llmax(col.mV[0], col.mV[1], col.mV[2]);
  86. }
  87. inline F32 color_min(const LLColor3 &col)
  88. {
  89. return llmin(col.mV[0], col.mV[1], col.mV[2]);
  90. }
  91. class LLFace;
  92. class LLHaze;
  93. class LLSkyTex
  94. {
  95. friend class LLVOSky;
  96. private:
  97. static S32 sResolution;
  98. static S32 sComponents;
  99. LLPointer<LLViewerTexture> mTexture[2];
  100. LLPointer<LLImageRaw> mImageRaw[2];
  101. LLColor4 *mSkyData;
  102. LLVector3 *mSkyDirs; // Cache of sky direction vectors
  103. static S32 sCurrent;
  104. static F32 sInterpVal;
  105. public:
  106. static F32 getInterpVal() { return sInterpVal; }
  107. static void setInterpVal(const F32 v) { sInterpVal = v; }
  108. static BOOL doInterpolate() { return sInterpVal > 0.001f; }
  109. void bindTexture(BOOL curr = TRUE);
  110. protected:
  111. LLSkyTex();
  112. void init();
  113. void cleanupGL();
  114. void restoreGL();
  115. ~LLSkyTex();
  116. static S32 getResolution() { return sResolution; }
  117. static S32 getCurrent() { return sCurrent; }
  118. static S32 stepCurrent() { sCurrent++; sCurrent &= 1; return sCurrent; }
  119. static S32 getNext() { return ((sCurrent+1) & 1); }
  120. static S32 getWhich(const BOOL curr) { return curr ? sCurrent : getNext(); }
  121. void initEmpty(const S32 tex);
  122. void create(F32 brightness);
  123. void setDir(const LLVector3 &dir, const S32 i, const S32 j)
  124. {
  125. S32 offset = i * sResolution + j;
  126. mSkyDirs[offset] = dir;
  127. }
  128. const LLVector3 &getDir(const S32 i, const S32 j) const
  129. {
  130. S32 offset = i * sResolution + j;
  131. return mSkyDirs[offset];
  132. }
  133. void setPixel(const LLColor4 &col, const S32 i, const S32 j)
  134. {
  135. S32 offset = i * sResolution + j;
  136. mSkyData[offset] = col;
  137. }
  138. void setPixel(const LLColor4U &col, const S32 i, const S32 j)
  139. {
  140. S32 offset = (i * sResolution + j) * sComponents;
  141. U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);
  142. *pix = col.mAll;
  143. }
  144. LLColor4U getPixel(const S32 i, const S32 j)
  145. {
  146. LLColor4U col;
  147. S32 offset = (i * sResolution + j) * sComponents;
  148. U32* pix = (U32*) &(mImageRaw[sCurrent]->getData()[offset]);
  149. col.mAll = *pix;
  150. return col;
  151. }
  152. LLImageRaw* getImageRaw(BOOL curr=TRUE) { return mImageRaw[getWhich(curr)]; }
  153. void createGLImage(BOOL curr=TRUE);
  154. };
  155. /// TODO Move into the stars draw pool (and rename them appropriately).
  156. class LLHeavenBody
  157. {
  158. protected:
  159. LLVector3 mDirectionCached; // hack for events that shouldn't happen every frame
  160. LLColor3 mColor;
  161. LLColor3 mColorCached;
  162. F32 mIntensity;
  163. LLVector3 mDirection; // direction of the local heavenly body
  164. LLVector3 mAngularVelocity; // velocity of the local heavenly body
  165. F32 mDiskRadius;
  166. BOOL mDraw; // FALSE - do not draw.
  167. F32 mHorizonVisibility; // number [0, 1] due to how horizon
  168. F32 mVisibility; // same but due to other objects being in throng.
  169. BOOL mVisible;
  170. static F32 sInterpVal;
  171. LLVector3 mQuadCorner[4];
  172. LLVector3 mU;
  173. LLVector3 mV;
  174. LLVector3 mO;
  175. public:
  176. LLHeavenBody(const F32 rad) :
  177. mDirectionCached(LLVector3(0,0,0)),
  178. mDirection(LLVector3(0,0,0)),
  179. mIntensity(0.f),
  180. mDiskRadius(rad), mDraw(FALSE),
  181. mHorizonVisibility(1.f), mVisibility(1.f),
  182. mVisible(FALSE)
  183. {
  184. mColor.setToBlack();
  185. mColorCached.setToBlack();
  186. }
  187. ~LLHeavenBody() {}
  188. const LLVector3& getDirection() const { return mDirection; }
  189. void setDirection(const LLVector3 &direction) { mDirection = direction; }
  190. void setAngularVelocity(const LLVector3 &ang_vel) { mAngularVelocity = ang_vel; }
  191. const LLVector3& getAngularVelocity() const { return mAngularVelocity; }
  192. const LLVector3& getDirectionCached() const { return mDirectionCached; }
  193. void renewDirection() { mDirectionCached = mDirection; }
  194. const LLColor3& getColorCached() const { return mColorCached; }
  195. void setColorCached(const LLColor3& c) { mColorCached = c; }
  196. const LLColor3& getColor() const { return mColor; }
  197. void setColor(const LLColor3& c) { mColor = c; }
  198. void renewColor() { mColorCached = mColor; }
  199. static F32 interpVal() { return sInterpVal; }
  200. static void setInterpVal(const F32 v) { sInterpVal = v; }
  201. LLColor3 getInterpColor() const
  202. {
  203. return sInterpVal * mColor + (1 - sInterpVal) * mColorCached;
  204. }
  205. const F32& getHorizonVisibility() const { return mHorizonVisibility; }
  206. void setHorizonVisibility(const F32 c = 1) { mHorizonVisibility = c; }
  207. const F32& getVisibility() const { return mVisibility; }
  208. void setVisibility(const F32 c = 1) { mVisibility = c; }
  209. F32 getHaloBrighness() const
  210. {
  211. return llmax(0.f, llmin(0.9f, mHorizonVisibility)) * mVisibility;
  212. }
  213. BOOL isVisible() const { return mVisible; }
  214. void setVisible(const BOOL v) { mVisible = v; }
  215. const F32& getIntensity() const { return mIntensity; }
  216. void setIntensity(const F32 c) { mIntensity = c; }
  217. void setDiskRadius(const F32 radius) { mDiskRadius = radius; }
  218. F32 getDiskRadius() const { return mDiskRadius; }
  219. void setDraw(const BOOL draw) { mDraw = draw; }
  220. BOOL getDraw() const { return mDraw; }
  221. const LLVector3& corner(const S32 n) const { return mQuadCorner[n]; }
  222. LLVector3& corner(const S32 n) { return mQuadCorner[n]; }
  223. const LLVector3* corners() const { return mQuadCorner; }
  224. const LLVector3& getU() const { return mU; }
  225. const LLVector3& getV() const { return mV; }
  226. void setU(const LLVector3& u) { mU = u; }
  227. void setV(const LLVector3& v) { mV = v; }
  228. };
  229. LL_FORCE_INLINE LLColor3 refr_ind_calc(const LLColor3 &wave_length)
  230. {
  231. LLColor3 refr_ind;
  232. for (S32 i = 0; i < 3; ++i)
  233. {
  234. const F32 wl2 = wave_length.mV[i] * wave_length.mV[i] * 1e-6f;
  235. refr_ind.mV[i] = 6.43e3f + ( 2.95e6f / ( 146.0f - 1.f/wl2 ) ) + ( 2.55e4f / ( 41.0f - 1.f/wl2 ) );
  236. refr_ind.mV[i] *= 1.0e-8f;
  237. refr_ind.mV[i] += 1.f;
  238. }
  239. return refr_ind;
  240. }
  241. class LLHaze
  242. {
  243. public:
  244. LLHaze() : mG(0), mFalloff(1), mAbsCoef(0.f) {mSigSca.setToBlack();}
  245. LLHaze(const F32 g, const LLColor3& sca, const F32 fo = 2.f) :
  246. mG(g), mSigSca(0.25f/F_PI * sca), mFalloff(fo), mAbsCoef(0.f)
  247. {
  248. mAbsCoef = color_intens(mSigSca) / sAirScaIntense;
  249. }
  250. LLHaze(const F32 g, const F32 sca, const F32 fo = 2.f) : mG(g),
  251. mSigSca(0.25f/F_PI * LLColor3(sca, sca, sca)), mFalloff(fo)
  252. {
  253. mAbsCoef = 0.01f * sca / sAirScaAvg;
  254. }
  255. F32 getG() const { return mG; }
  256. void setG(const F32 g)
  257. {
  258. mG = g;
  259. }
  260. const LLColor3& getSigSca() const // sea level
  261. {
  262. return mSigSca;
  263. }
  264. void setSigSca(const LLColor3& s)
  265. {
  266. mSigSca = s;
  267. mAbsCoef = 0.01f * color_intens(mSigSca) / sAirScaIntense;
  268. }
  269. void setSigSca(const F32 s0, const F32 s1, const F32 s2)
  270. {
  271. mSigSca = sAirScaAvg * LLColor3 (s0, s1, s2);
  272. mAbsCoef = 0.01f * (s0 + s1 + s2) / 3;
  273. }
  274. F32 getFalloff() const
  275. {
  276. return mFalloff;
  277. }
  278. void setFalloff(const F32 fo)
  279. {
  280. mFalloff = fo;
  281. }
  282. F32 getAbsCoef() const
  283. {
  284. return mAbsCoef;
  285. }
  286. inline static F32 calcFalloff(const F32 h)
  287. {
  288. return (h <= 0) ? 1.0f : (F32)LL_FAST_EXP(-ATM_EXP_FALLOFF * h);
  289. }
  290. inline LLColor3 calcSigSca(const F32 h) const
  291. {
  292. return calcFalloff(h * mFalloff) * mSigSca;
  293. }
  294. inline void calcSigSca(const F32 h, LLColor3 &result) const
  295. {
  296. result = mSigSca;
  297. result *= calcFalloff(h * mFalloff);
  298. }
  299. LLColor3 calcSigExt(const F32 h) const
  300. {
  301. return calcFalloff(h * mFalloff) * (1 + mAbsCoef) * mSigSca;
  302. }
  303. F32 calcPhase(const F32 cos_theta) const;
  304. static inline LLColor3 calcAirSca(const F32 h);
  305. static inline void calcAirSca(const F32 h, LLColor3 &result);
  306. private:
  307. static LLColor3 const sAirScaSeaLevel;
  308. static F32 const sAirScaIntense;
  309. static F32 const sAirScaAvg;
  310. protected:
  311. F32 mG;
  312. LLColor3 mSigSca;
  313. F32 mFalloff; // 1 - slow, >1 - faster
  314. F32 mAbsCoef;
  315. };
  316. class LLCubeMap;
  317. // turn on floating point precision
  318. // in vs2003 for this class. Otherwise
  319. // black dots go everywhere from 7:10 - 8:50
  320. #if LL_MSVC && __MSVC_VER__ < 8
  321. #pragma optimize("p", on)
  322. #endif
  323. class LLVOSky : public LLStaticViewerObject
  324. {
  325. public:
  326. /// WL PARAMS
  327. F32 dome_radius;
  328. F32 dome_offset_ratio;
  329. LLColor3 sunlight_color;
  330. LLColor3 ambient;
  331. F32 gamma;
  332. LLVector4 lightnorm;
  333. LLVector4 unclamped_lightnorm;
  334. LLColor3 blue_density;
  335. LLColor3 blue_horizon;
  336. F32 haze_density;
  337. LLColor3 haze_horizon;
  338. F32 density_multiplier;
  339. F32 max_y;
  340. LLColor3 glow;
  341. F32 cloud_shadow;
  342. LLColor3 cloud_color;
  343. F32 cloud_scale;
  344. LLColor3 cloud_pos_density1;
  345. LLColor3 cloud_pos_density2;
  346. public:
  347. void initAtmospherics(void);
  348. void calcAtmospherics(void);
  349. LLColor3 createDiffuseFromWL(LLColor3 diffuse, LLColor3 ambient, LLColor3 sundiffuse, LLColor3 sunambient);
  350. LLColor3 createAmbientFromWL(LLColor3 ambient, LLColor3 sundiffuse, LLColor3 sunambient);
  351. void calcSkyColorWLVert(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLColor3 & vary_CloudColorSun,
  352. LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity,
  353. LLVector2 vary_HorizontalProjection[2]);
  354. LLColor3 calcSkyColorWLFrag(LLVector3 & Pn, LLColor3 & vary_HazeColor, LLColor3 & vary_CloudColorSun,
  355. LLColor3 & vary_CloudColorAmbient, F32 & vary_CloudDensity,
  356. LLVector2 vary_HorizontalProjection[2]);
  357. public:
  358. enum
  359. {
  360. FACE_SIDE0,
  361. FACE_SIDE1,
  362. FACE_SIDE2,
  363. FACE_SIDE3,
  364. FACE_SIDE4,
  365. FACE_SIDE5,
  366. FACE_SUN, // was 6
  367. FACE_MOON, // was 7
  368. FACE_BLOOM, // was 8
  369. FACE_REFLECTION, // was 10
  370. FACE_DUMMY, //for an ATI bug --bao
  371. FACE_COUNT
  372. };
  373. LLVOSky(const LLUUID &id, const LLPCode pcode, LLViewerRegion *regionp);
  374. // Initialize/delete data that's only inited once per class.
  375. void init();
  376. void initCubeMap();
  377. void initEmpty();
  378. void cleanupGL();
  379. void restoreGL();
  380. /*virtual*/ BOOL idleUpdate(LLAgent &agent, LLWorld &world, const F64 &time);
  381. BOOL updateSky();
  382. // Graphical stuff for objects - maybe broken out into render class
  383. // later?
  384. /*virtual*/ void updateTextures();
  385. /*virtual*/ LLDrawable* createDrawable(LLPipeline *pipeline);
  386. /*virtual*/ BOOL updateGeometry(LLDrawable *drawable);
  387. void initSkyTextureDirs(const S32 side, const S32 tile);
  388. void createSkyTexture(const S32 side, const S32 tile);
  389. LLColor4 calcSkyColorInDir(const LLVector3& dir, bool isShiny = false);
  390. LLColor3 calcRadianceAtPoint(const LLVector3& pos) const
  391. {
  392. F32 radiance = mBrightnessScaleGuess * mSun.getIntensity();
  393. return LLColor3(radiance, radiance, radiance);
  394. }
  395. const LLHeavenBody& getSun() const { return mSun; }
  396. const LLHeavenBody& getMoon() const { return mMoon; }
  397. const LLVector3& getToSunLast() const { return mSun.getDirectionCached(); }
  398. const LLVector3& getToSun() const { return mSun.getDirection(); }
  399. const LLVector3& getToMoon() const { return mMoon.getDirection(); }
  400. const LLVector3& getToMoonLast() const { return mMoon.getDirectionCached(); }
  401. BOOL isSunUp() const { return mSun.getDirectionCached().mV[2] > -0.05f; }
  402. void calculateColors();
  403. LLColor3 getSunDiffuseColor() const { return mSunDiffuse; }
  404. LLColor3 getMoonDiffuseColor() const { return mMoonDiffuse; }
  405. LLColor4 getSunAmbientColor() const { return mSunAmbient; }
  406. LLColor4 getMoonAmbientColor() const { return mMoonAmbient; }
  407. const LLColor4& getTotalAmbientColor() const { return mTotalAmbient; }
  408. LLColor4 getFogColor() const { return mFogColor; }
  409. LLColor4 getGLFogColor() const { return mGLFogCol; }
  410. BOOL isSameFace(S32 idx, const LLFace* face) const { return mFace[idx] == face; }
  411. void initSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity);
  412. void setSunDirection(const LLVector3 &sun_dir, const LLVector3 &sun_ang_velocity);
  413. BOOL updateHeavenlyBodyGeometry(LLDrawable *drawable, const S32 side, const BOOL is_sun,
  414. LLHeavenBody& hb, const F32 sin_max_angle,
  415. const LLVector3 &up, const LLVector3 &right);
  416. F32 cosHorizon(const F32 delta = 0) const
  417. {
  418. const F32 sin_angle = EARTH_RADIUS/(EARTH_RADIUS + mCameraPosAgent.mV[2]);
  419. return delta - (F32)sqrt(1.f - sin_angle * sin_angle);
  420. }
  421. void updateSunHaloGeometry(LLDrawable *drawable);
  422. void updateReflectionGeometry(LLDrawable *drawable, F32 H, const LLHeavenBody& HB);
  423. const LLHaze& getHaze() const { return mHaze; }
  424. LLHaze& getHaze() { return mHaze; }
  425. F32 getHazeConcentration() const { return mHazeConcentration; }
  426. void setHaze(const LLHaze& h) { mHaze = h; }
  427. F32 getWorldScale() const { return mWorldScale; }
  428. void setWorldScale(const F32 s) { mWorldScale = s; }
  429. void updateFog(const F32 distance);
  430. void setFogRatio(const F32 fog_ratio) { mFogRatio = fog_ratio; }
  431. LLColor4U getFadeColor() const { return mFadeColor; }
  432. F32 getFogRatio() const { return mFogRatio; }
  433. void setCloudDensity(F32 cloud_density) { mCloudDensity = cloud_density; }
  434. void setWind ( const LLVector3& wind ) { mWind = wind.length(); }
  435. const LLVector3 &getCameraPosAgent() const { return mCameraPosAgent; }
  436. LLVector3 getEarthCenter() const { return mEarthCenter; }
  437. LLCubeMap *getCubeMap() const { return mCubeMap; }
  438. S32 getDrawRefl() const { return mDrawRefl; }
  439. void setDrawRefl(const S32 r) { mDrawRefl = r; }
  440. BOOL isReflFace(const LLFace* face) const { return face == mFace[FACE_REFLECTION]; }
  441. LLFace* getReflFace() const { return mFace[FACE_REFLECTION]; }
  442. LLViewerTexture* getSunTex() const { return mSunTexturep; }
  443. LLViewerTexture* getMoonTex() const { return mMoonTexturep; }
  444. LLViewerTexture* getBloomTex() const { return mBloomTexturep; }
  445. void forceSkyUpdate(void) { mForceUpdate = TRUE; }
  446. public:
  447. LLFace *mFace[FACE_COUNT];
  448. LLVector3 mBumpSunDir;
  449. protected:
  450. ~LLVOSky();
  451. LLPointer<LLViewerFetchedTexture> mSunTexturep;
  452. LLPointer<LLViewerFetchedTexture> mMoonTexturep;
  453. LLPointer<LLViewerFetchedTexture> mBloomTexturep;
  454. static S32 sResolution;
  455. static S32 sTileResX;
  456. static S32 sTileResY;
  457. LLSkyTex mSkyTex[6];
  458. LLSkyTex mShinyTex[6];
  459. LLHeavenBody mSun;
  460. LLHeavenBody mMoon;
  461. LLVector3 mSunDefaultPosition;
  462. LLVector3 mSunAngVel;
  463. F32 mAtmHeight;
  464. LLVector3 mEarthCenter;
  465. LLVector3 mCameraPosAgent;
  466. F32 mBrightnessScale;
  467. LLColor3 mBrightestPoint;
  468. F32 mBrightnessScaleNew;
  469. LLColor3 mBrightestPointNew;
  470. F32 mBrightnessScaleGuess;
  471. LLColor3 mBrightestPointGuess;
  472. LLHaze mHaze;
  473. F32 mHazeConcentration;
  474. BOOL mWeatherChange;
  475. F32 mCloudDensity;
  476. F32 mWind;
  477. BOOL mInitialized;
  478. BOOL mForceUpdate; //flag to force instantaneous update of cubemap
  479. LLVector3 mLastLightingDirection;
  480. LLColor3 mLastTotalAmbient;
  481. F32 mAmbientScale;
  482. LLColor3 mNightColorShift;
  483. F32 mInterpVal;
  484. LLColor4 mFogColor;
  485. LLColor4 mGLFogCol;
  486. F32 mFogRatio;
  487. F32 mWorldScale;
  488. LLColor4 mSunAmbient;
  489. LLColor4 mMoonAmbient;
  490. LLColor4 mTotalAmbient;
  491. LLColor3 mSunDiffuse;
  492. LLColor3 mMoonDiffuse;
  493. LLColor4U mFadeColor; // Color to fade in from
  494. LLPointer<LLCubeMap> mCubeMap; // Cube map for the environment
  495. S32 mDrawRefl;
  496. LLFrameTimer mUpdateTimer;
  497. public:
  498. //by bao
  499. //fake vertex buffer updating
  500. //to guarantee at least updating one VBO buffer every frame
  501. //to work around the bug caused by ATI card --> DEV-3855
  502. //
  503. void createDummyVertexBuffer() ;
  504. void updateDummyVertexBuffer() ;
  505. BOOL mHeavenlyBodyUpdated ;
  506. };
  507. // turn it off
  508. #if LL_MSVC && __MSVC_VER__ < 8
  509. #pragma optimize("p", off)
  510. #endif
  511. // Utility functions
  512. F32 azimuth(const LLVector3 &v);
  513. F32 color_norm_pow(LLColor3& col, F32 e, BOOL postmultiply = FALSE);
  514. /* Proportion of light that is scattered into 'path' from 'in' over distance dt. */
  515. /* assumes that vectors 'path' and 'in' are normalized. Scattering coef / 2pi */
  516. inline LLColor3 LLHaze::calcAirSca(const F32 h)
  517. {
  518. return calcFalloff(h) * sAirScaSeaLevel;
  519. }
  520. inline void LLHaze::calcAirSca(const F32 h, LLColor3 &result)
  521. {
  522. result = sAirScaSeaLevel;
  523. result *= calcFalloff(h);
  524. }
  525. #endif