PageRenderTime 48ms CodeModel.GetById 17ms app.highlight 27ms RepoModel.GetById 1ms app.codeStats 0ms

/indra/newview/llviewershadermgr.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 349 lines | 254 code | 54 blank | 41 comment | 6 complexity | 88b0037c686fa488422d533a734906e4 MD5 | raw file
  1/** 
  2 * @file llviewershadermgr.h
  3 * @brief Viewer Shader Manager
  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_VIEWER_SHADER_MGR_H
 28#define LL_VIEWER_SHADER_MGR_H
 29
 30#include "llshadermgr.h"
 31
 32class LLViewerShaderMgr: public LLShaderMgr
 33{
 34public:
 35	static BOOL sInitialized;
 36	static bool sSkipReload;
 37
 38	LLViewerShaderMgr();
 39	/* virtual */ ~LLViewerShaderMgr();
 40
 41	// singleton pattern implementation
 42	static LLViewerShaderMgr * instance();
 43
 44	void initAttribsAndUniforms(void);
 45	void setShaders();
 46	void unloadShaders();
 47	S32 getVertexShaderLevel(S32 type);
 48	BOOL loadBasicShaders();
 49	BOOL loadShadersEffects();
 50	BOOL loadShadersDeferred();
 51	BOOL loadShadersObject();
 52	BOOL loadShadersAvatar();
 53	BOOL loadShadersEnvironment();
 54	BOOL loadShadersWater();
 55	BOOL loadShadersInterface();
 56	BOOL loadShadersWindLight();
 57
 58	std::vector<S32> mVertexShaderLevel;
 59	S32	mMaxAvatarShaderLevel;
 60
 61	enum EShaderClass
 62	{
 63		SHADER_LIGHTING,
 64		SHADER_OBJECT,
 65		SHADER_AVATAR,
 66		SHADER_ENVIRONMENT,
 67		SHADER_INTERFACE,
 68		SHADER_EFFECT,
 69		SHADER_WINDLIGHT,
 70		SHADER_WATER,
 71		SHADER_DEFERRED,
 72		SHADER_COUNT
 73	};
 74
 75	typedef enum
 76	{
 77		SHINY_ORIGIN = END_RESERVED_UNIFORMS
 78	} eShinyUniforms;
 79
 80	typedef enum
 81	{
 82		WATER_SCREENTEX = END_RESERVED_UNIFORMS,
 83		WATER_SCREENDEPTH,
 84		WATER_REFTEX,
 85		WATER_EYEVEC,
 86		WATER_TIME,
 87		WATER_WAVE_DIR1,
 88		WATER_WAVE_DIR2,
 89		WATER_LIGHT_DIR,
 90		WATER_SPECULAR,
 91		WATER_SPECULAR_EXP,
 92		WATER_FOGCOLOR,
 93		WATER_FOGDENSITY,
 94		WATER_REFSCALE,
 95		WATER_WATERHEIGHT,
 96	} eWaterUniforms;
 97
 98	typedef enum
 99	{
100		WL_CAMPOSLOCAL = END_RESERVED_UNIFORMS,
101		WL_WATERHEIGHT
102	} eWLUniforms;
103
104	typedef enum
105	{
106		TERRAIN_DETAIL0 = END_RESERVED_UNIFORMS,
107		TERRAIN_DETAIL1,
108		TERRAIN_DETAIL2,
109		TERRAIN_DETAIL3,
110		TERRAIN_ALPHARAMP
111	} eTerrainUniforms;
112
113	typedef enum
114	{
115		GLOW_DELTA = END_RESERVED_UNIFORMS
116	} eGlowUniforms;
117
118	typedef enum
119	{
120		AVATAR_MATRIX = END_RESERVED_UNIFORMS,
121		AVATAR_WIND,
122		AVATAR_SINWAVE,
123		AVATAR_GRAVITY,
124	} eAvatarUniforms;
125
126	// simple model of forward iterator
127	// http://www.sgi.com/tech/stl/ForwardIterator.html
128	class shader_iter
129	{
130	private:
131		friend bool operator == (shader_iter const & a, shader_iter const & b);
132		friend bool operator != (shader_iter const & a, shader_iter const & b);
133
134		typedef std::vector<LLGLSLShader *>::const_iterator base_iter_t;
135	public:
136		shader_iter()
137		{
138		}
139
140		shader_iter(base_iter_t iter) : mIter(iter)
141		{
142		}
143
144		LLGLSLShader & operator * () const
145		{
146			return **mIter;
147		}
148
149		LLGLSLShader * operator -> () const
150		{
151			return *mIter;
152		}
153
154		shader_iter & operator++ ()
155		{
156			++mIter;
157			return *this;
158		}
159
160		shader_iter operator++ (int)
161		{
162			return mIter++;
163		}
164
165	private:
166		base_iter_t mIter;
167	};
168
169	shader_iter beginShaders() const;
170	shader_iter endShaders() const;
171
172	/* virtual */ std::string getShaderDirPrefix(void);
173
174	/* virtual */ void updateShaderUniforms(LLGLSLShader * shader);
175
176private:
177	
178	std::vector<std::string> mShinyUniforms;
179
180	//water parameters
181	std::vector<std::string> mWaterUniforms;
182
183	std::vector<std::string> mWLUniforms;
184
185	//terrain parameters
186	std::vector<std::string> mTerrainUniforms;
187
188	//glow parameters
189	std::vector<std::string> mGlowUniforms;
190
191	std::vector<std::string> mGlowExtractUniforms;
192
193	std::vector<std::string> mAvatarUniforms;
194
195	// the list of shaders we need to propagate parameters to.
196	std::vector<LLGLSLShader *> mShaderList;
197
198}; //LLViewerShaderMgr
199
200inline bool operator == (LLViewerShaderMgr::shader_iter const & a, LLViewerShaderMgr::shader_iter const & b)
201{
202	return a.mIter == b.mIter;
203}
204
205inline bool operator != (LLViewerShaderMgr::shader_iter const & a, LLViewerShaderMgr::shader_iter const & b)
206{
207	return a.mIter != b.mIter;
208}
209
210extern LLVector4			gShinyOrigin;
211
212//utility shaders
213extern LLGLSLShader			gOcclusionProgram;
214extern LLGLSLShader			gCustomAlphaProgram;
215extern LLGLSLShader			gGlowCombineProgram;
216extern LLGLSLShader			gSplatTextureRectProgram;
217extern LLGLSLShader			gGlowCombineFXAAProgram;
218extern LLGLSLShader			gDebugProgram;
219extern LLGLSLShader			gAlphaMaskProgram;
220
221//output tex0[tc0] + tex1[tc1]
222extern LLGLSLShader			gTwoTextureAddProgram;
223						
224extern LLGLSLShader			gOneTextureNoColorProgram;
225
226//object shaders
227extern LLGLSLShader			gObjectSimpleProgram;
228extern LLGLSLShader			gObjectPreviewProgram;
229extern LLGLSLShader			gObjectSimpleAlphaMaskProgram;
230extern LLGLSLShader			gObjectSimpleWaterProgram;
231extern LLGLSLShader			gObjectSimpleWaterAlphaMaskProgram;
232extern LLGLSLShader			gObjectSimpleNonIndexedProgram;
233extern LLGLSLShader			gObjectSimpleNonIndexedTexGenProgram;
234extern LLGLSLShader			gObjectSimpleNonIndexedTexGenWaterProgram;
235extern LLGLSLShader			gObjectSimpleNonIndexedWaterProgram;
236extern LLGLSLShader			gObjectAlphaMaskNonIndexedProgram;
237extern LLGLSLShader			gObjectAlphaMaskNonIndexedWaterProgram;
238extern LLGLSLShader			gObjectAlphaMaskNoColorProgram;
239extern LLGLSLShader			gObjectAlphaMaskNoColorWaterProgram;
240extern LLGLSLShader			gObjectFullbrightProgram;
241extern LLGLSLShader			gObjectFullbrightWaterProgram;
242extern LLGLSLShader			gObjectFullbrightNoColorProgram;
243extern LLGLSLShader			gObjectFullbrightNoColorWaterProgram;
244extern LLGLSLShader			gObjectEmissiveProgram;
245extern LLGLSLShader			gObjectEmissiveWaterProgram;
246extern LLGLSLShader			gObjectFullbrightAlphaMaskProgram;
247extern LLGLSLShader			gObjectFullbrightWaterAlphaMaskProgram;
248extern LLGLSLShader			gObjectFullbrightNonIndexedProgram;
249extern LLGLSLShader			gObjectFullbrightNonIndexedWaterProgram;
250extern LLGLSLShader			gObjectEmissiveNonIndexedProgram;
251extern LLGLSLShader			gObjectEmissiveNonIndexedWaterProgram;
252extern LLGLSLShader			gObjectBumpProgram;
253extern LLGLSLShader			gTreeProgram;
254extern LLGLSLShader			gTreeWaterProgram;
255
256extern LLGLSLShader			gObjectSimpleLODProgram;
257extern LLGLSLShader			gObjectFullbrightLODProgram;
258
259extern LLGLSLShader			gObjectFullbrightShinyProgram;
260extern LLGLSLShader			gObjectFullbrightShinyWaterProgram;
261extern LLGLSLShader			gObjectFullbrightShinyNonIndexedProgram;
262extern LLGLSLShader			gObjectFullbrightShinyNonIndexedWaterProgram;
263
264extern LLGLSLShader			gObjectShinyProgram;
265extern LLGLSLShader			gObjectShinyWaterProgram;
266extern LLGLSLShader			gObjectShinyNonIndexedProgram;
267extern LLGLSLShader			gObjectShinyNonIndexedWaterProgram;
268
269extern LLGLSLShader			gSkinnedObjectSimpleProgram;
270extern LLGLSLShader			gSkinnedObjectFullbrightProgram;
271extern LLGLSLShader			gSkinnedObjectEmissiveProgram;
272extern LLGLSLShader			gSkinnedObjectFullbrightShinyProgram;
273extern LLGLSLShader			gSkinnedObjectShinySimpleProgram;
274
275extern LLGLSLShader			gSkinnedObjectSimpleWaterProgram;
276extern LLGLSLShader			gSkinnedObjectFullbrightWaterProgram;
277extern LLGLSLShader			gSkinnedObjectEmissiveWaterProgram;
278extern LLGLSLShader			gSkinnedObjectFullbrightShinyWaterProgram;
279extern LLGLSLShader			gSkinnedObjectShinySimpleWaterProgram;
280
281//environment shaders
282extern LLGLSLShader			gTerrainProgram;
283extern LLGLSLShader			gTerrainWaterProgram;
284extern LLGLSLShader			gWaterProgram;
285extern LLGLSLShader			gUnderWaterProgram;
286extern LLGLSLShader			gGlowProgram;
287extern LLGLSLShader			gGlowExtractProgram;
288
289//interface shaders
290extern LLGLSLShader			gHighlightProgram;
291
292// avatar shader handles
293extern LLGLSLShader			gAvatarProgram;
294extern LLGLSLShader			gAvatarWaterProgram;
295extern LLGLSLShader			gAvatarEyeballProgram;
296extern LLGLSLShader			gAvatarPickProgram;
297extern LLGLSLShader			gImpostorProgram;
298
299// WindLight shader handles
300extern LLGLSLShader			gWLSkyProgram;
301extern LLGLSLShader			gWLCloudProgram;
302
303// Post Process Shaders
304extern LLGLSLShader			gPostColorFilterProgram;
305extern LLGLSLShader			gPostNightVisionProgram;
306
307// Deferred rendering shaders
308extern LLGLSLShader			gDeferredImpostorProgram;
309extern LLGLSLShader			gDeferredWaterProgram;
310extern LLGLSLShader			gDeferredDiffuseProgram;
311extern LLGLSLShader			gDeferredDiffuseAlphaMaskProgram;
312extern LLGLSLShader			gDeferredNonIndexedDiffuseAlphaMaskProgram;
313extern LLGLSLShader			gDeferredNonIndexedDiffuseAlphaMaskNoColorProgram;
314extern LLGLSLShader			gDeferredNonIndexedDiffuseProgram;
315extern LLGLSLShader			gDeferredSkinnedDiffuseProgram;
316extern LLGLSLShader			gDeferredSkinnedBumpProgram;
317extern LLGLSLShader			gDeferredSkinnedAlphaProgram;
318extern LLGLSLShader			gDeferredBumpProgram;
319extern LLGLSLShader			gDeferredTerrainProgram;
320extern LLGLSLShader			gDeferredTreeProgram;
321extern LLGLSLShader			gDeferredTreeShadowProgram;
322extern LLGLSLShader			gDeferredLightProgram;
323extern LLGLSLShader			gDeferredMultiLightProgram;
324extern LLGLSLShader			gDeferredSpotLightProgram;
325extern LLGLSLShader			gDeferredMultiSpotLightProgram;
326extern LLGLSLShader			gDeferredSunProgram;
327extern LLGLSLShader			gDeferredBlurLightProgram;
328extern LLGLSLShader			gDeferredAvatarProgram;
329extern LLGLSLShader			gDeferredSoftenProgram;
330extern LLGLSLShader			gDeferredShadowProgram;
331extern LLGLSLShader			gDeferredShadowAlphaMaskProgram;
332extern LLGLSLShader			gDeferredPostProgram;
333extern LLGLSLShader			gDeferredCoFProgram;
334extern LLGLSLShader			gDeferredDoFCombineProgram;
335extern LLGLSLShader			gFXAAProgram;
336extern LLGLSLShader			gDeferredPostNoDoFProgram;
337extern LLGLSLShader			gDeferredAvatarShadowProgram;
338extern LLGLSLShader			gDeferredAttachmentShadowProgram;
339extern LLGLSLShader			gDeferredAlphaProgram;
340extern LLGLSLShader			gDeferredFullbrightProgram;
341extern LLGLSLShader			gDeferredEmissiveProgram;
342extern LLGLSLShader			gDeferredAvatarEyesProgram;
343extern LLGLSLShader			gDeferredAvatarAlphaProgram;
344extern LLGLSLShader			gDeferredWLSkyProgram;
345extern LLGLSLShader			gDeferredWLCloudProgram;
346extern LLGLSLShader			gDeferredStarProgram;
347extern LLGLSLShader			gNormalMapGenProgram;
348
349#endif