PageRenderTime 67ms CodeModel.GetById 2ms app.highlight 57ms RepoModel.GetById 1ms app.codeStats 0ms

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